rx-flag-all-packets-20080925
[openafs.git] / src / rx / rx_rdwr.c
index 5baff8a..1417144 100644 (file)
@@ -137,6 +137,7 @@ rxi_ReadProc(register struct rx_call *call, register char *buf,
                        afs_int32 error;
                        register struct rx_connection *conn = call->conn;
                        queue_Remove(rp);
+                       rp->flags &= ~RX_PKTFLAG_RQ;
 
                        /* RXS_CheckPacket called to undo RXS_PreparePacket's
                         * work.  It may reduce the length of the packet by up
@@ -161,6 +162,7 @@ rxi_ReadProc(register struct rx_call *call, register char *buf,
                        }
                        call->rnext++;
                        cp = call->currentPacket = rp;
+                       call->currentPacket->flags |= RX_PKTFLAG_CP;
                        call->curvec = 1;       /* 0th vec is always header */
                        /* begin at the beginning [ more or less ], continue 
                         * on until the end, then stop. */
@@ -263,6 +265,7 @@ MTUXXX  doesn't there need to be an "else" here ???
 
                if (!call->nLeft) {
                    /* out of packet.  Get another one. */
+                   call->currentPacket->flags &= ~RX_PKTFLAG_CP;
                    rxi_FreePacket(cp);
                    cp = call->currentPacket = (struct rx_packet *)0;
                } else if (!call->curlen) {
@@ -270,6 +273,7 @@ MTUXXX  doesn't there need to be an "else" here ???
                    if (++call->curvec >= cp->niovecs) {
                        /* current packet is exhausted, get ready for another */
                        /* don't worry about curvec and stuff, they get set somewhere else */
+                       call->currentPacket->flags &= ~RX_PKTFLAG_CP;
                        rxi_FreePacket(cp);
                        cp = call->currentPacket = (struct rx_packet *)0;
                        call->nLeft = 0;
@@ -436,6 +440,7 @@ rxi_FillReadVec(struct rx_call *call, afs_uint32 serial)
                    afs_int32 error;
                    register struct rx_connection *conn = call->conn;
                    queue_Remove(rp);
+                   rp->flags &= ~RX_PKTFLAG_RQ;
 
                    /* RXS_CheckPacket called to undo RXS_PreparePacket's
                     * work.  It may reduce the length of the packet by up
@@ -459,6 +464,7 @@ rxi_FillReadVec(struct rx_call *call, afs_uint32 serial)
                    }
                    call->rnext++;
                    curp = call->currentPacket = rp;
+                   call->currentPacket->flags |= RX_PKTFLAG_CP;
                    call->curvec = 1;   /* 0th vec is always header */
                    cur_iov = &curp->wirevec[1];
                    /* begin at the beginning [ more or less ], continue 
@@ -513,6 +519,8 @@ rxi_FillReadVec(struct rx_call *call, afs_uint32 serial)
 
            if (!call->nLeft) {
                /* out of packet.  Get another one. */
+                curp->flags &= ~RX_PKTFLAG_CP;
+                curp->flags |= RX_PKTFLAG_IOVQ;
                queue_Append(&call->iovq, curp);
                curp = call->currentPacket = (struct rx_packet *)0;
            } else if (!call->curlen) {
@@ -520,6 +528,8 @@ rxi_FillReadVec(struct rx_call *call, afs_uint32 serial)
                if (++call->curvec >= curp->niovecs) {
                    /* current packet is exhausted, get ready for another */
                    /* don't worry about curvec and stuff, they get set somewhere else */
+                   curp->flags &= ~RX_PKTFLAG_CP;
+                   curp->flags |= RX_PKTFLAG_IOVQ;
                    queue_Append(&call->iovq, curp);
                    curp = call->currentPacket = (struct rx_packet *)0;
                    call->nLeft = 0;
@@ -670,6 +680,7 @@ rxi_WriteProc(register struct rx_call *call, register char *buf,
            && (call->mode == RX_MODE_RECEIVING)) {
            call->mode = RX_MODE_SENDING;
            if (cp) {
+               cp->flags &= ~RX_PKTFLAG_CP;
                rxi_FreePacket(cp);
                cp = call->currentPacket = (struct rx_packet *)0;
                call->nLeft = 0;
@@ -707,14 +718,20 @@ rxi_WriteProc(register struct rx_call *call, register char *buf,
                 * conn->securityMaxTrailerSize */
                hadd32(call->bytesSent, cp->length);
                rxi_PrepareSendPacket(call, cp, 0);
+               cp->flags &= ~RX_PKTFLAG_CP;
+               cp->flags |= RX_PKTFLAG_TQ;
                queue_Append(&call->tq, cp);
-               cp = call->currentPacket = NULL;
+               cp = call->currentPacket = (struct rx_packet *)0;
                if (!
                    (call->
                     flags & (RX_CALL_FAST_RECOVER |
                              RX_CALL_FAST_RECOVER_WAIT))) {
                    rxi_Start(0, call, 0, 0);
                }
+           } else else if (cp) {
+               cp->flags &= ~RX_PKTFLAG_CP;
+               rxi_FreePacket(cp);
+               cp = call->currentPacket = (struct rx_packet *)0;
            }
            /* Wait for transmit window to open up */
            while (!call->error
@@ -737,6 +754,7 @@ rxi_WriteProc(register struct rx_call *call, register char *buf,
 #endif /* RX_ENABLE_LOCKS */
            }
            if ((cp = rxi_AllocSendPacket(call, nbytes))) {
+               cp->flags |= RX_PKTFLAG_CP;
                call->currentPacket = cp;
                call->nFree = cp->length;
                call->curvec = 1;       /* 0th vec is always header */
@@ -750,6 +768,7 @@ rxi_WriteProc(register struct rx_call *call, register char *buf,
            }
            if (call->error) {
                if (cp) {
+                   cp->flags &= ~RX_PKTFLAG_CP;
                    rxi_FreePacket(cp);
                    call->currentPacket = NULL;
                }
@@ -944,6 +963,7 @@ rxi_WritevAlloc(struct rx_call *call, struct iovec *iov, int *nio, int maxio,
            && (call->mode == RX_MODE_RECEIVING)) {
            call->mode = RX_MODE_SENDING;
            if (cp) {
+               cp->flags &= ~RX_PKTFLAG_CP;
                rxi_FreePacket(cp);
                cp = call->currentPacket = (struct rx_packet *)0;
                call->nLeft = 0;
@@ -970,6 +990,7 @@ rxi_WritevAlloc(struct rx_call *call, struct iovec *iov, int *nio, int maxio,
                *nio = nextio;
                return requestCount - nbytes;
            }
+           cp->flags |= RX_PKTFLAG_IOVQ;
            queue_Append(&call->iovq, cp);
            tnFree = cp->length;
            tcurvec = 1;
@@ -1073,8 +1094,10 @@ rxi_WritevProc(struct rx_call *call, struct iovec *iov, int nio, int nbytes)
 
     if (call->error) {
        if (cp) {
+            cp->flags &= ~RX_PKTFLAG_CP;
+            cp->flags |= RX_PKTFLAG_IOVQ;
            queue_Prepend(&call->iovq, cp);
-           cp = call->currentPacket = NULL;
+           cp = call->currentPacket = (struct rx_packet *)0;
        }
        rxi_FreePackets(0, &call->iovq);
        return 0;
@@ -1096,18 +1119,20 @@ rxi_WritevProc(struct rx_call *call, struct iovec *iov, int nio, int nbytes)
             * conn->securityMaxTrailerSize */
            hadd32(call->bytesSent, cp->length);
            rxi_PrepareSendPacket(call, cp, 0);
+           cp->flags |= RX_PKTFLAG_TQ;
            queue_Append(&tmpq, cp);
 
            /* The head of the iovq is now the current packet */
            if (nbytes) {
                if (queue_IsEmpty(&call->iovq)) {
                    call->error = RX_PROTOCOL_ERROR;
-                   cp = call->currentPacket = NULL;
                    rxi_FreePackets(0, &tmpq);
                    return 0;
                }
                cp = queue_First(&call->iovq, rx_packet);
                queue_Remove(cp);
+                cp->flags &= ~RX_PKTFLAG_IOVQ;
+                cp->flags |= RX_PKTFLAG_CP;
                call->currentPacket = cp;
                call->nFree = cp->length;
                call->curvec = 1;
@@ -1125,8 +1150,8 @@ rxi_WritevProc(struct rx_call *call, struct iovec *iov, int nio, int nbytes)
                || iov[nextio].iov_len > (int)call->curlen) {
                call->error = RX_PROTOCOL_ERROR;
                if (cp) {
+                   cp->flags &= ~RX_PKTFLAG_CP;
                    queue_Prepend(&tmpq, cp);
-                   call->currentPacket = NULL;
                }
                rxi_FreePackets(0, &tmpq);
                return 0;
@@ -1170,8 +1195,8 @@ rxi_WritevProc(struct rx_call *call, struct iovec *iov, int nio, int nbytes)
 
     if (call->error) {
        if (cp) {
+           cp->flags &= ~RX_PKTFLAG_CP;
            rxi_FreePacket(cp);
-           cp = call->currentPacket = NULL;
        }
        return 0;
     }
@@ -1242,6 +1267,7 @@ rxi_FlushWrite(register struct rx_call *call)
            /* cp->length is only supposed to be the user's data */
            /* cp->length was already set to (then-current) 
             * MaxUserDataSize or less. */
+           cp->flags &= ~RX_PKTFLAG_CP;
            cp->length -= call->nFree;
            call->currentPacket = (struct rx_packet *)0;
            call->nFree = 0;
@@ -1259,6 +1285,7 @@ rxi_FlushWrite(register struct rx_call *call)
        /* The 1 specifies that this is the last packet */
        hadd32(call->bytesSent, cp->length);
        rxi_PrepareSendPacket(call, cp, 1);
+       cp->flags |= RX_PKTFLAG_TQ;
        queue_Append(&call->tq, cp);
        if (!
            (call->