quic: call quic_send_packets only once per ctx 95/24095/3
authorAloys Augustin <aloaugus@cisco.com>
Fri, 20 Dec 2019 12:14:00 +0000 (13:14 +0100)
committerDave Wallace <dwallacelf@gmail.com>
Mon, 6 Jan 2020 14:11:55 +0000 (14:11 +0000)
This prevents unnecessary calls to quic_send_packets.

Type: fix
Change-Id: I7abe509aa8b7b9d5a01c9876046cf0f4507a79cf
Signed-off-by: Aloys Augustin <aloaugus@cisco.com>
src/plugins/quic/quic.c

index dc3b1d4..fd848b0 100644 (file)
@@ -2153,7 +2153,7 @@ static int
 quic_udp_session_rx_callback (session_t * udp_session)
 {
   /*  Read data from UDP rx_fifo and pass it to the quicly conn. */
-  quic_ctx_t *ctx = NULL;
+  quic_ctx_t *ctx = NULL, *prev_ctx = NULL;
   svm_fifo_t *f = udp_session->rx_fifo;
   u32 max_deq;
   u64 udp_session_handle = session_handle (udp_session);
@@ -2234,8 +2234,10 @@ rx_start:
          break;
        }
     }
+  ctx = prev_ctx = NULL;
   for (i = 0; i < max_packets; i++)
     {
+      prev_ctx = ctx;
       switch (packets_ctx[i].ptype)
        {
        case QUIC_PACKET_TYPE_RECEIVE:
@@ -2250,9 +2252,11 @@ rx_start:
                              packets_ctx[i].thread_index);
          break;
        default:
-         continue;
+         continue;             /* this exits the for loop since other packet types are
+                                  necessarily the last in the batch */
        }
-      quic_send_packets (ctx);
+      if (ctx != prev_ctx)
+       quic_send_packets (ctx);
     }
 
   udp_session = session_get_from_handle (udp_session_handle);  /*  session alloc might have happened */