rx: Move transmit queue clearing
authorSimon Wilkinson <sxw@your-file-system.com>
Fri, 26 Oct 2012 14:37:52 +0000 (15:37 +0100)
committerDerrick Brashear <shadow@your-file-system.com>
Mon, 29 Oct 2012 20:36:44 +0000 (13:36 -0700)
When the client receives a data packet from the server, it means that
the server has completed processing the client's request. This, in turn,
implies that the transmit queue can be cleared. However, we were doing
this with every incoming data packet.

Move the transmit queue clearing to the code which handles the rest of
the data packet, and make the function only run if the transmit queue
is non-empty.

Now that there's no client specific logic in the ReceiveCall section,
clean up this code to reduce duplication.

Change-Id: Ia4f9024720c676cbcc6d8426d4b94a0acded20bc
Reviewed-on: http://gerrit.openafs.org/8301
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

src/rx/rx.c

index 84ffd7b..bb3a852 100644 (file)
@@ -3534,23 +3534,14 @@ rxi_ReceivePacket(struct rx_packet *np, osi_socket socket,
        }
     }
 
-    if (type == RX_SERVER_CONNECTION) {
+    if (type == RX_SERVER_CONNECTION)
        call = rxi_ReceiveServerCall(socket, np, conn);
-       if (call == NULL) {
-           putConnection(conn);
-           return np;
-        }
-    } else {
+    else
        call = rxi_ReceiveClientCall(np, conn);
-       if (call == NULL) {
-           putConnection(conn);
-           return np;
-       }
 
-       /* If we're receiving the response, then all transmit packets are
-        * implicitly acknowledged.  Get rid of them. */
-       if (np->header.type == RX_PACKET_TYPE_DATA)
-           rxi_AckAllInTransmitQueue(call);
+    if (call == NULL) {
+       putConnection(conn);
+       return np;
     }
 
     osirx_AssertMine(&call->lock, "rxi_ReceivePacket middle");
@@ -3560,6 +3551,11 @@ rxi_ReceivePacket(struct rx_packet *np, osi_socket socket,
     /* Now do packet type-specific processing */
     switch (np->header.type) {
     case RX_PACKET_TYPE_DATA:
+       /* If we're a client, and receiving a response, then all the packets
+        * we transmitted packets are implicitly acknowledged. */
+       if (type == RX_CLIENT_CONNECTION && !opr_queue_IsEmpty(&call->tq))
+           rxi_AckAllInTransmitQueue(call);
+
        np = rxi_ReceiveDataPacket(call, np, 1, socket, host, port, tnop,
                                   newcallp);
        break;