rx: wake up send after 'twind' has been updated 25/12625/2
authorJeffrey Altman <jaltman@auristor.com>
Sat, 27 May 2017 18:59:04 +0000 (14:59 -0400)
committerBenjamin Kaduk <kaduk@mit.edu>
Tue, 30 May 2017 03:58:28 +0000 (23:58 -0400)
Beginning in AFS 3.4 and 3.5 the ack trailer includes the size of the
peer's receive window.  This value is used to update the sender's
transmit window (twind).  When the twind is increased the application
thread is signaled to indicate that more packets can be sent.

This change wakes the application thread after twind is updated by
the peer's receive window instead of beforehand.  Failure to do so
can result in 100ms transmit delays when the receive window transitions
from closed to open.

Change-Id: Id129ea93e94612a4b8cce9f8cbddde9c779ff26b
Reviewed-on: https://gerrit.openafs.org/12625
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

src/rx/rx.c

index be9949b..97faa43 100644 (file)
@@ -4420,24 +4420,6 @@ rxi_ReceiveAckPacket(struct rx_call *call, struct rx_packet *np,
      * queue - they're not addressed by the contents of this ACK packet.
      */
 
-    /* If the window has been extended by this acknowledge packet,
-     * then wakeup a sender waiting in alloc for window space, or try
-     * sending packets now, if he's been sitting on packets due to
-     * lack of window space */
-    if (call->tnext < (call->tfirst + call->twind)) {
-#ifdef RX_ENABLE_LOCKS
-       CV_SIGNAL(&call->cv_twind);
-#else
-       if (call->flags & RX_CALL_WAIT_WINDOW_ALLOC) {
-           call->flags &= ~RX_CALL_WAIT_WINDOW_ALLOC;
-           osi_rxWakeup(&call->twind);
-       }
-#endif
-       if (call->flags & RX_CALL_WAIT_WINDOW_SEND) {
-           call->flags &= ~RX_CALL_WAIT_WINDOW_SEND;
-       }
-    }
-
     /* if the ack packet has a receivelen field hanging off it,
      * update our state */
     if (np->length >= rx_AckDataSize(ap->nAcks) + 2 * sizeof(afs_int32)) {
@@ -4544,6 +4526,24 @@ rxi_ReceiveAckPacket(struct rx_call *call, struct rx_packet *np,
        call->MTU = OLD_MAX_PACKET_SIZE;
     }
 
+    /* If the window has been extended by this acknowledge packet,
+     * then wakeup a sender waiting in alloc for window space, or try
+     * sending packets now, if he's been sitting on packets due to
+     * lack of window space */
+    if (call->tnext < (call->tfirst + call->twind)) {
+#ifdef RX_ENABLE_LOCKS
+       CV_SIGNAL(&call->cv_twind);
+#else
+       if (call->flags & RX_CALL_WAIT_WINDOW_ALLOC) {
+           call->flags &= ~RX_CALL_WAIT_WINDOW_ALLOC;
+           osi_rxWakeup(&call->twind);
+       }
+#endif
+       if (call->flags & RX_CALL_WAIT_WINDOW_SEND) {
+           call->flags &= ~RX_CALL_WAIT_WINDOW_SEND;
+       }
+    }
+
     if (nNacked) {
        /*
         * Calculate how many datagrams were successfully received after