4af9ab7a0815c28a66bf8495ef9d15388b3383ba
[openafs.git] / src / rx / rx_rdwr.c
1  /*
2   * Copyright 2000, International Business Machines Corporation and others.
3   * All Rights Reserved.
4   *
5   * This software has been released under the terms of the IBM Public
6   * License.  For details, see the LICENSE file in the top-level source
7   * directory or online at http://www.openafs.org/dl/license10.html
8   */
9
10 #include <afsconfig.h>
11 #include <afs/param.h>
12
13 #ifdef KERNEL
14 # ifndef UKERNEL
15 #  ifdef RX_KERNEL_TRACE
16 #   include "rx_kcommon.h"
17 #  endif
18 #  if defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
19 #   include "afs/sysincludes.h"
20 #  else
21 #   include "h/types.h"
22 #   include "h/time.h"
23 #   include "h/stat.h"
24 #   if defined(AFS_AIX_ENV) || defined(AFS_AUX_ENV) || defined(AFS_SUN5_ENV)
25 #    include "h/systm.h"
26 #   endif
27 #   ifdef       AFS_OSF_ENV
28 #    include <net/net_globals.h>
29 #   endif /* AFS_OSF_ENV */
30 #   ifdef AFS_LINUX20_ENV
31 #    include "h/socket.h"
32 #   endif
33 #   include "netinet/in.h"
34 #   if defined(AFS_SGI_ENV)
35 #    include "afs/sysincludes.h"
36 #   endif
37 #  endif
38 #  include "afs/afs_args.h"
39 #  if   (defined(AFS_AUX_ENV) || defined(AFS_AIX_ENV))
40 #   include "h/systm.h"
41 #  endif
42 # else /* !UKERNEL */
43 #  include "afs/sysincludes.h"
44 # endif /* !UKERNEL */
45
46 # ifdef RXDEBUG
47 #  undef RXDEBUG                        /* turn off debugging */
48 # endif /* RXDEBUG */
49
50 # include "afs/afs_osi.h"
51 # include "rx_kmutex.h"
52 # include "rx/rx_kernel.h"
53 # include "afs/lock.h"
54 #else /* KERNEL */
55 # include <roken.h>
56 # include <afs/opr.h>
57 #endif /* KERNEL */
58
59 #include "rx.h"
60 #include "rx_clock.h"
61 #include "rx_globals.h"
62 #include "rx_atomic.h"
63 #include "rx_internal.h"
64 #include "rx_conn.h"
65 #include "rx_call.h"
66 #include "rx_packet.h"
67
68 #ifdef RX_LOCKS_DB
69 /* rxdb_fileID is used to identify the lock location, along with line#. */
70 static int rxdb_fileID = RXDB_FILE_RX_RDWR;
71 #endif /* RX_LOCKS_DB */
72
73 /* Get the next packet in the receive queue
74  *
75  * Dispose of the call's currentPacket, and move the next packet in the
76  * receive queue into the currentPacket field. If the next packet isn't
77  * available, then currentPacket is left NULL.
78  *
79  * @param call
80  *      The RX call to manipulate
81  * @returns
82  *      0 on success, an error code on failure
83  *
84  * @notes
85  *      Must be called with the call locked. Unlocks the call if returning
86  *      with an error.
87  */
88
89 static int
90 rxi_GetNextPacket(struct rx_call *call) {
91     struct rx_packet *rp;
92     int error;
93
94     if (call->app.currentPacket != NULL) {
95 #ifdef RX_TRACK_PACKETS
96         call->app.currentPacket->flags |= RX_PKTFLAG_CP;
97 #endif
98         rxi_FreePacket(call->app.currentPacket);
99         call->app.currentPacket = NULL;
100     }
101
102     if (opr_queue_IsEmpty(&call->rq))
103         return 0;
104
105     /* Check that next packet available is next in sequence */
106     rp = opr_queue_First(&call->rq, struct rx_packet, entry);
107     if (rp->header.seq != call->rnext)
108         return 0;
109
110     opr_queue_Remove(&rp->entry);
111 #ifdef RX_TRACK_PACKETS
112     rp->flags &= ~RX_PKTFLAG_RQ;
113 #endif
114 #ifdef RXDEBUG_PACKET
115     call->rqc--;
116 #endif /* RXDEBUG_PACKET */
117
118     /* RXS_CheckPacket called to undo RXS_PreparePacket's work.  It may
119      * reduce the length of the packet by up to conn->maxTrailerSize,
120      * to reflect the length of the data + the header. */
121     if ((error = RXS_CheckPacket(call->conn->securityObject, call, rp))) {
122         /* Used to merely shut down the call, but now we shut down the whole
123          * connection since this may indicate an attempt to hijack it */
124
125         MUTEX_EXIT(&call->lock);
126         rxi_ConnectionError(call->conn, error);
127         MUTEX_ENTER(&call->conn->conn_data_lock);
128         rp = rxi_SendConnectionAbort(call->conn, rp, 0, 0);
129         MUTEX_EXIT(&call->conn->conn_data_lock);
130         rxi_FreePacket(rp);
131
132         return error;
133      }
134
135     call->rnext++;
136     call->app.currentPacket = rp;
137 #ifdef RX_TRACK_PACKETS
138     call->app.currentPacket->flags |= RX_PKTFLAG_CP;
139 #endif
140     call->app.curvec = 1;       /* 0th vec is always header */
141
142     /* begin at the beginning [ more or less ], continue on until the end,
143      * then stop. */
144     call->app.curpos = (char *)call->app.currentPacket->wirevec[1].iov_base +
145                    call->conn->securityHeaderSize;
146     call->app.curlen = call->app.currentPacket->wirevec[1].iov_len -
147                    call->conn->securityHeaderSize;
148
149     call->app.nLeft = call->app.currentPacket->length;
150     call->app.bytesRcvd += call->app.currentPacket->length;
151
152     call->nHardAcks++;
153
154     return 0;
155 }
156
157 /* rxi_ReadProc -- internal version.
158  *
159  * LOCKS USED -- called at netpri
160  */
161 int
162 rxi_ReadProc(struct rx_call *call, char *buf,
163              int nbytes)
164 {
165     int requestCount;
166     int code;
167     unsigned int t;
168
169 /* XXXX took out clock_NewTime from here.  Was it needed? */
170     requestCount = nbytes;
171
172     /* Free any packets from the last call to ReadvProc/WritevProc */
173     if (!opr_queue_IsEmpty(&call->app.iovq)) {
174 #ifdef RXDEBUG_PACKET
175         call->iovqc -=
176 #endif /* RXDEBUG_PACKET */
177             rxi_FreePackets(0, &call->app.iovq);
178     }
179
180     do {
181         if (call->app.nLeft == 0) {
182             /* Get next packet */
183             MUTEX_ENTER(&call->lock);
184             for (;;) {
185                 if (call->error || (call->app.mode != RX_MODE_RECEIVING)) {
186                     if (call->error) {
187                         call->app.mode = RX_MODE_ERROR;
188                         MUTEX_EXIT(&call->lock);
189                         return 0;
190                     }
191                     if (call->app.mode == RX_MODE_SENDING) {
192                         MUTEX_EXIT(&call->lock);
193                         rxi_FlushWrite(call);
194                         MUTEX_ENTER(&call->lock);
195                         continue;
196                     }
197                 }
198
199                 code = rxi_GetNextPacket(call);
200                 if (code)
201                      return 0;
202
203                 if (call->app.currentPacket) {
204                     if (!(call->flags & RX_CALL_RECEIVE_DONE)) {
205                         if (call->nHardAcks > (u_short) rxi_HardAckRate) {
206                             rxevent_Cancel(&call->delayedAckEvent, call,
207                                            RX_CALL_REFCOUNT_DELAY);
208                             rxi_SendAck(call, 0, 0, RX_ACK_DELAY, 0);
209                         } else {
210                             /* Delay to consolidate ack packets */
211                             rxi_PostDelayedAckEvent(call, &rx_hardAckDelay);
212                         }
213                     }
214                     break;
215                 }
216
217                 /*
218                  * If we reach this point either we have no packets in the
219                  * receive queue or the next packet in the queue is not the
220                  * one we are looking for.  There is nothing else for us to
221                  * do but wait for another packet to arrive.
222                  */
223
224                 /* Are there ever going to be any more packets? */
225                 if (call->flags & RX_CALL_RECEIVE_DONE) {
226                     MUTEX_EXIT(&call->lock);
227                     return requestCount - nbytes;
228                 }
229                 /* Wait for in-sequence packet */
230                 call->flags |= RX_CALL_READER_WAIT;
231                 clock_NewTime();
232                 call->startWait = clock_Sec();
233                 while (call->flags & RX_CALL_READER_WAIT) {
234 #ifdef  RX_ENABLE_LOCKS
235                     CV_WAIT(&call->cv_rq, &call->lock);
236 #else
237                     osi_rxSleep(&call->rq);
238 #endif
239                 }
240
241                 call->startWait = 0;
242 #ifdef RX_ENABLE_LOCKS
243                 if (call->error) {
244                     MUTEX_EXIT(&call->lock);
245                     return 0;
246                 }
247 #endif /* RX_ENABLE_LOCKS */
248             }
249             MUTEX_EXIT(&call->lock);
250         } else
251             /* osi_Assert(cp); */
252             /* MTUXXX  this should be replaced by some error-recovery code before shipping */
253             /* yes, the following block is allowed to be the ELSE clause (or not) */
254             /* It's possible for call->app.nLeft to be smaller than any particular
255              * iov_len.  Usually, recvmsg doesn't change the iov_len, since it
256              * reflects the size of the buffer.  We have to keep track of the
257              * number of bytes read in the length field of the packet struct.  On
258              * the final portion of a received packet, it's almost certain that
259              * call->app.nLeft will be smaller than the final buffer. */
260             while (nbytes && call->app.currentPacket) {
261                 t = MIN((int)call->app.curlen, nbytes);
262                 t = MIN(t, (int)call->app.nLeft);
263                 memcpy(buf, call->app.curpos, t);
264                 buf += t;
265                 nbytes -= t;
266                 call->app.curpos += t;
267                 call->app.curlen -= t;
268                 call->app.nLeft -= t;
269
270                 if (!call->app.nLeft) {
271                     /* out of packet.  Get another one. */
272 #ifdef RX_TRACK_PACKETS
273                     call->app.currentPacket->flags &= ~RX_PKTFLAG_CP;
274 #endif
275                     rxi_FreePacket(call->app.currentPacket);
276                     call->app.currentPacket = NULL;
277                 } else if (!call->app.curlen) {
278                     /* need to get another struct iov */
279                     if (++call->app.curvec >= call->app.currentPacket->niovecs) {
280                         /* current packet is exhausted, get ready for another */
281                         /* don't worry about curvec and stuff, they get set somewhere else */
282 #ifdef RX_TRACK_PACKETS
283                         call->app.currentPacket->flags &= ~RX_PKTFLAG_CP;
284 #endif
285                         rxi_FreePacket(call->app.currentPacket);
286                         call->app.currentPacket = NULL;
287                         call->app.nLeft = 0;
288                     } else {
289                         call->app.curpos =
290                             call->app.currentPacket->wirevec[call->app.curvec].iov_base;
291                         call->app.curlen =
292                             call->app.currentPacket->wirevec[call->app.curvec].iov_len;
293                     }
294                 }
295             }
296         if (!nbytes) {
297             /* user buffer is full, return */
298             return requestCount;
299         }
300
301     } while (nbytes);
302
303     return requestCount;
304 }
305
306 int
307 rx_ReadProc(struct rx_call *call, char *buf, int nbytes)
308 {
309     int bytes;
310     SPLVAR;
311
312     /* Free any packets from the last call to ReadvProc/WritevProc */
313     if (!opr_queue_IsEmpty(&call->app.iovq)) {
314 #ifdef RXDEBUG_PACKET
315         call->iovqc -=
316 #endif /* RXDEBUG_PACKET */
317             rxi_FreePackets(0, &call->app.iovq);
318     }
319
320     /*
321      * Most common case, all of the data is in the current iovec.
322      * We are relying on nLeft being zero unless the call is in receive mode.
323      */
324     if (!call->error && call->app.curlen > nbytes && call->app.nLeft > nbytes) {
325         memcpy(buf, call->app.curpos, nbytes);
326
327         call->app.curpos += nbytes;
328         call->app.curlen -= nbytes;
329         call->app.nLeft  -= nbytes;
330
331         if (!call->app.nLeft && call->app.currentPacket != NULL) {
332             /* out of packet.  Get another one. */
333             rxi_FreePacket(call->app.currentPacket);
334             call->app.currentPacket = NULL;
335         }
336         return nbytes;
337     }
338
339     NETPRI;
340     bytes = rxi_ReadProc(call, buf, nbytes);
341     USERPRI;
342     return bytes;
343 }
344
345 /* Optimization for unmarshalling 32 bit integers */
346 int
347 rx_ReadProc32(struct rx_call *call, afs_int32 * value)
348 {
349     int bytes;
350     SPLVAR;
351
352     /* Free any packets from the last call to ReadvProc/WritevProc */
353     if (!opr_queue_IsEmpty(&call->app.iovq)) {
354 #ifdef RXDEBUG_PACKET
355         call->iovqc -=
356 #endif /* RXDEBUG_PACKET */
357             rxi_FreePackets(0, &call->app.iovq);
358     }
359
360     /*
361      * Most common case, all of the data is in the current iovec.
362      * We are relying on nLeft being zero unless the call is in receive mode.
363      */
364     if (!call->error && call->app.curlen >= sizeof(afs_int32)
365         && call->app.nLeft >= sizeof(afs_int32)) {
366
367         memcpy((char *)value, call->app.curpos, sizeof(afs_int32));
368
369         call->app.curpos += sizeof(afs_int32);
370         call->app.curlen -= sizeof(afs_int32);
371         call->app.nLeft  -= sizeof(afs_int32);
372
373         if (!call->app.nLeft && call->app.currentPacket != NULL) {
374             /* out of packet.  Get another one. */
375             rxi_FreePacket(call->app.currentPacket);
376             call->app.currentPacket = NULL;
377         }
378         return sizeof(afs_int32);
379     }
380
381     NETPRI;
382     bytes = rxi_ReadProc(call, (char *)value, sizeof(afs_int32));
383     USERPRI;
384
385     return bytes;
386 }
387
388 /* rxi_FillReadVec
389  *
390  * Uses packets in the receive queue to fill in as much of the
391  * current iovec as possible. Does not block if it runs out
392  * of packets to complete the iovec. Return true if an ack packet
393  * was sent, otherwise return false */
394 int
395 rxi_FillReadVec(struct rx_call *call, afs_uint32 serial)
396 {
397     int didConsume = 0;
398     int didHardAck = 0;
399     int code;
400     unsigned int t;
401     struct iovec *call_iov;
402     struct iovec *cur_iov = NULL;
403
404     if (call->app.currentPacket) {
405         cur_iov = &call->app.currentPacket->wirevec[call->app.curvec];
406     }
407     call_iov = &call->iov[call->iovNext];
408
409     while (!call->error && call->iovNBytes && call->iovNext < call->iovMax) {
410         if (call->app.nLeft == 0) {
411             /* Get next packet */
412             code = rxi_GetNextPacket(call);
413             if (code) {
414                 MUTEX_ENTER(&call->lock);
415                 return 1;
416             }
417
418             if (call->app.currentPacket) {
419                 cur_iov = &call->app.currentPacket->wirevec[1];
420                 didConsume = 1;
421                 continue;
422             } else {
423                 break;
424             }
425         }
426
427         /* It's possible for call->app.nLeft to be smaller than any particular
428          * iov_len.  Usually, recvmsg doesn't change the iov_len, since it
429          * reflects the size of the buffer.  We have to keep track of the
430          * number of bytes read in the length field of the packet struct.  On
431          * the final portion of a received packet, it's almost certain that
432          * call->app.nLeft will be smaller than the final buffer. */
433         while (call->iovNBytes
434                && call->iovNext < call->iovMax
435                && call->app.currentPacket) {
436
437             t = MIN((int)call->app.curlen, call->iovNBytes);
438             t = MIN(t, (int)call->app.nLeft);
439             call_iov->iov_base = call->app.curpos;
440             call_iov->iov_len = t;
441             call_iov++;
442             call->iovNext++;
443             call->iovNBytes -= t;
444             call->app.curpos += t;
445             call->app.curlen -= t;
446             call->app.nLeft -= t;
447
448             if (!call->app.nLeft) {
449                 /* out of packet.  Get another one. */
450 #ifdef RX_TRACK_PACKETS
451                 call->app.currentPacket->flags &= ~RX_PKTFLAG_CP;
452                 call->app.currentPacket->flags |= RX_PKTFLAG_IOVQ;
453 #endif
454                 opr_queue_Append(&call->app.iovq,
455                                  &call->app.currentPacket->entry);
456 #ifdef RXDEBUG_PACKET
457                 call->iovqc++;
458 #endif /* RXDEBUG_PACKET */
459                 call->app.currentPacket = NULL;
460             } else if (!call->app.curlen) {
461                 /* need to get another struct iov */
462                 if (++call->app.curvec >= call->app.currentPacket->niovecs) {
463                     /* current packet is exhausted, get ready for another */
464                     /* don't worry about curvec and stuff, they get set somewhere else */
465 #ifdef RX_TRACK_PACKETS
466                     call->app.currentPacket->flags &= ~RX_PKTFLAG_CP;
467                     call->app.currentPacket->flags |= RX_PKTFLAG_IOVQ;
468 #endif
469                     opr_queue_Append(&call->app.iovq,
470                                      &call->app.currentPacket->entry);
471 #ifdef RXDEBUG_PACKET
472                     call->iovqc++;
473 #endif /* RXDEBUG_PACKET */
474                     call->app.currentPacket = NULL;
475                     call->app.nLeft = 0;
476                 } else {
477                     cur_iov++;
478                     call->app.curpos = (char *)cur_iov->iov_base;
479                     call->app.curlen = cur_iov->iov_len;
480                 }
481             }
482         }
483     }
484
485     /* If we consumed any packets then check whether we need to
486      * send a hard ack. */
487     if (didConsume && (!(call->flags & RX_CALL_RECEIVE_DONE))) {
488         if (call->nHardAcks > (u_short) rxi_HardAckRate) {
489             rxevent_Cancel(&call->delayedAckEvent, call,
490                            RX_CALL_REFCOUNT_DELAY);
491             rxi_SendAck(call, 0, serial, RX_ACK_DELAY, 0);
492             didHardAck = 1;
493         } else {
494             /* Delay to consolidate ack packets */
495             rxi_PostDelayedAckEvent(call, &rx_hardAckDelay);
496         }
497     }
498     return didHardAck;
499 }
500
501
502 /* rxi_ReadvProc -- internal version.
503  *
504  * Fills in an iovec with pointers to the packet buffers. All packets
505  * except the last packet (new current packet) are moved to the iovq
506  * while the application is processing the data.
507  *
508  * LOCKS USED -- called at netpri.
509  */
510 int
511 rxi_ReadvProc(struct rx_call *call, struct iovec *iov, int *nio, int maxio,
512               int nbytes)
513 {
514     int bytes;
515
516     /* Free any packets from the last call to ReadvProc/WritevProc */
517     if (!opr_queue_IsEmpty(&call->app.iovq)) {
518 #ifdef RXDEBUG_PACKET
519         call->iovqc -=
520 #endif /* RXDEBUG_PACKET */
521             rxi_FreePackets(0, &call->app.iovq);
522     }
523
524     if (call->app.mode == RX_MODE_SENDING) {
525         rxi_FlushWrite(call);
526     }
527
528     MUTEX_ENTER(&call->lock);
529     if (call->error)
530         goto error;
531
532     /* Get whatever data is currently available in the receive queue.
533      * If rxi_FillReadVec sends an ack packet then it is possible
534      * that we will receive more data while we drop the call lock
535      * to send the packet. Set the RX_CALL_IOVEC_WAIT flag
536      * here to avoid a race with the receive thread if we send
537      * hard acks in rxi_FillReadVec. */
538     call->flags |= RX_CALL_IOVEC_WAIT;
539     call->iovNBytes = nbytes;
540     call->iovMax = maxio;
541     call->iovNext = 0;
542     call->iov = iov;
543     rxi_FillReadVec(call, 0);
544
545     /* if we need more data then sleep until the receive thread has
546      * filled in the rest. */
547     if (!call->error && call->iovNBytes && call->iovNext < call->iovMax
548         && !(call->flags & RX_CALL_RECEIVE_DONE)) {
549         call->flags |= RX_CALL_READER_WAIT;
550         clock_NewTime();
551         call->startWait = clock_Sec();
552         while (call->flags & RX_CALL_READER_WAIT) {
553 #ifdef  RX_ENABLE_LOCKS
554             CV_WAIT(&call->cv_rq, &call->lock);
555 #else
556             osi_rxSleep(&call->rq);
557 #endif
558         }
559         call->startWait = 0;
560     }
561     call->flags &= ~RX_CALL_IOVEC_WAIT;
562
563     if (call->error)
564         goto error;
565
566     call->iov = NULL;
567     *nio = call->iovNext;
568     bytes = nbytes - call->iovNBytes;
569     MUTEX_EXIT(&call->lock);
570     return bytes;
571
572   error:
573     MUTEX_EXIT(&call->lock);
574     call->app.mode = RX_MODE_ERROR;
575     return 0;
576 }
577
578 int
579 rx_ReadvProc(struct rx_call *call, struct iovec *iov, int *nio, int maxio,
580              int nbytes)
581 {
582     int bytes;
583     SPLVAR;
584
585     NETPRI;
586     bytes = rxi_ReadvProc(call, iov, nio, maxio, nbytes);
587     USERPRI;
588     return bytes;
589 }
590
591 /* rxi_WriteProc -- internal version.
592  *
593  * LOCKS USED -- called at netpri
594  */
595
596 int
597 rxi_WriteProc(struct rx_call *call, char *buf,
598               int nbytes)
599 {
600     struct rx_connection *conn = call->conn;
601     unsigned int t;
602     int requestCount = nbytes;
603
604     /* Free any packets from the last call to ReadvProc/WritevProc */
605     if (!opr_queue_IsEmpty(&call->app.iovq)) {
606 #ifdef RXDEBUG_PACKET
607         call->iovqc -=
608 #endif /* RXDEBUG_PACKET */
609             rxi_FreePackets(0, &call->app.iovq);
610     }
611
612     if (call->app.mode != RX_MODE_SENDING) {
613         if ((conn->type == RX_SERVER_CONNECTION)
614             && (call->app.mode == RX_MODE_RECEIVING)) {
615             call->app.mode = RX_MODE_SENDING;
616             if (call->app.currentPacket) {
617 #ifdef RX_TRACK_PACKETS
618                 call->app.currentPacket->flags &= ~RX_PKTFLAG_CP;
619 #endif
620                 rxi_FreePacket(call->app.currentPacket);
621                 call->app.currentPacket = NULL;
622                 call->app.nLeft = 0;
623                 call->app.nFree = 0;
624             }
625         } else {
626             return 0;
627         }
628     }
629
630     /* Loop condition is checked at end, so that a write of 0 bytes
631      * will force a packet to be created--specially for the case where
632      * there are 0 bytes on the stream, but we must send a packet
633      * anyway. */
634     do {
635         if (call->app.nFree == 0) {
636             MUTEX_ENTER(&call->lock);
637             if (call->error)
638                 call->app.mode = RX_MODE_ERROR;
639             if (!call->error && call->app.currentPacket) {
640                 clock_NewTime();        /* Bogus:  need new time package */
641                 /* The 0, below, specifies that it is not the last packet:
642                  * there will be others. PrepareSendPacket may
643                  * alter the packet length by up to
644                  * conn->securityMaxTrailerSize */
645                 call->app.bytesSent += call->app.currentPacket->length;
646                 rxi_PrepareSendPacket(call, call->app.currentPacket, 0);
647                 /* PrepareSendPacket drops the call lock */
648                 rxi_WaitforTQBusy(call);
649 #ifdef RX_TRACK_PACKETS
650                 call->app.currentPacket->flags |= RX_PKTFLAG_TQ;
651 #endif
652                 opr_queue_Append(&call->tq,
653                                  &call->app.currentPacket->entry);
654 #ifdef RXDEBUG_PACKET
655                 call->tqc++;
656 #endif /* RXDEBUG_PACKET */
657 #ifdef RX_TRACK_PACKETS
658                 call->app.currentPacket->flags &= ~RX_PKTFLAG_CP;
659 #endif
660                 call->app.currentPacket = NULL;
661
662                 /* If the call is in recovery, let it exhaust its current
663                  * retransmit queue before forcing it to send new packets
664                  */
665                 if (!(call->flags & (RX_CALL_FAST_RECOVER))) {
666                     rxi_Start(call, 0);
667                 }
668             } else if (call->app.currentPacket) {
669 #ifdef RX_TRACK_PACKETS
670                 call->app.currentPacket->flags &= ~RX_PKTFLAG_CP;
671 #endif
672                 rxi_FreePacket(call->app.currentPacket);
673                 call->app.currentPacket = NULL;
674             }
675             /* Wait for transmit window to open up */
676             while (!call->error
677                    && call->tnext + 1 > call->tfirst + (2 * call->twind)) {
678                 clock_NewTime();
679                 call->startWait = clock_Sec();
680
681 #ifdef  RX_ENABLE_LOCKS
682                 CV_WAIT(&call->cv_twind, &call->lock);
683 #else
684                 call->flags |= RX_CALL_WAIT_WINDOW_ALLOC;
685                 osi_rxSleep(&call->twind);
686 #endif
687
688                 call->startWait = 0;
689 #ifdef RX_ENABLE_LOCKS
690                 if (call->error) {
691                     call->app.mode = RX_MODE_ERROR;
692                     MUTEX_EXIT(&call->lock);
693                     return 0;
694                 }
695 #endif /* RX_ENABLE_LOCKS */
696             }
697             if ((call->app.currentPacket = rxi_AllocSendPacket(call, nbytes))) {
698 #ifdef RX_TRACK_PACKETS
699                 call->app.currentPacket->flags |= RX_PKTFLAG_CP;
700 #endif
701                 call->app.nFree = call->app.currentPacket->length;
702                 call->app.curvec = 1;   /* 0th vec is always header */
703                 /* begin at the beginning [ more or less ], continue
704                  * on until the end, then stop. */
705                 call->app.curpos =
706                     (char *) call->app.currentPacket->wirevec[1].iov_base +
707                     call->conn->securityHeaderSize;
708                 call->app.curlen =
709                     call->app.currentPacket->wirevec[1].iov_len -
710                     call->conn->securityHeaderSize;
711             }
712             if (call->error) {
713                 call->app.mode = RX_MODE_ERROR;
714                 if (call->app.currentPacket) {
715 #ifdef RX_TRACK_PACKETS
716                     call->app.currentPacket->flags &= ~RX_PKTFLAG_CP;
717 #endif
718                     rxi_FreePacket(call->app.currentPacket);
719                     call->app.currentPacket = NULL;
720                 }
721                 MUTEX_EXIT(&call->lock);
722                 return 0;
723             }
724             MUTEX_EXIT(&call->lock);
725         }
726
727         if (call->app.currentPacket && (int)call->app.nFree < nbytes) {
728             /* Try to extend the current buffer */
729             int len, mud;
730             len = call->app.currentPacket->length;
731             mud = rx_MaxUserDataSize(call);
732             if (mud > len) {
733                 int want;
734                 want = MIN(nbytes - (int)call->app.nFree, mud - len);
735                 rxi_AllocDataBuf(call->app.currentPacket, want,
736                                  RX_PACKET_CLASS_SEND_CBUF);
737                 if (call->app.currentPacket->length > (unsigned)mud)
738                     call->app.currentPacket->length = mud;
739                 call->app.nFree += (call->app.currentPacket->length - len);
740             }
741         }
742
743         /* If the remaining bytes fit in the buffer, then store them
744          * and return.  Don't ship a buffer that's full immediately to
745          * the peer--we don't know if it's the last buffer yet */
746
747         if (!call->app.currentPacket) {
748             call->app.nFree = 0;
749         }
750
751         while (nbytes && call->app.nFree) {
752
753             t = MIN((int)call->app.curlen, nbytes);
754             t = MIN((int)call->app.nFree, t);
755             memcpy(call->app.curpos, buf, t);
756             buf += t;
757             nbytes -= t;
758             call->app.curpos += t;
759             call->app.curlen -= (u_short)t;
760             call->app.nFree -= (u_short)t;
761
762             if (!call->app.curlen) {
763                 /* need to get another struct iov */
764                 if (++call->app.curvec >= call->app.currentPacket->niovecs) {
765                     /* current packet is full, extend or send it */
766                     call->app.nFree = 0;
767                 } else {
768                     call->app.curpos =
769                         call->app.currentPacket->wirevec[call->app.curvec].iov_base;
770                     call->app.curlen =
771                         call->app.currentPacket->wirevec[call->app.curvec].iov_len;
772                 }
773             }
774         }                       /* while bytes to send and room to send them */
775
776         /* might be out of space now */
777         if (!nbytes) {
778             return requestCount;
779         } else;                 /* more data to send, so get another packet and keep going */
780     } while (nbytes);
781
782     return requestCount - nbytes;
783 }
784
785 int
786 rx_WriteProc(struct rx_call *call, char *buf, int nbytes)
787 {
788     int bytes;
789     int tcurlen;
790     int tnFree;
791     char *tcurpos;
792     SPLVAR;
793
794     /* Free any packets from the last call to ReadvProc/WritevProc */
795     if (!opr_queue_IsEmpty(&call->app.iovq)) {
796 #ifdef RXDEBUG_PACKET
797         call->iovqc -=
798 #endif /* RXDEBUG_PACKET */
799             rxi_FreePackets(0, &call->app.iovq);
800     }
801
802     /*
803      * Most common case: all of the data fits in the current iovec.
804      * We are relying on nFree being zero unless the call is in send mode.
805      */
806     tcurlen = (int)call->app.curlen;
807     tnFree = (int)call->app.nFree;
808     if (!call->error && tcurlen >= nbytes && tnFree >= nbytes) {
809         tcurpos = call->app.curpos;
810
811         memcpy(tcurpos, buf, nbytes);
812         call->app.curpos = tcurpos + nbytes;
813         call->app.curlen = (u_short)(tcurlen - nbytes);
814         call->app.nFree = (u_short)(tnFree - nbytes);
815         return nbytes;
816     }
817
818     NETPRI;
819     bytes = rxi_WriteProc(call, buf, nbytes);
820     USERPRI;
821     return bytes;
822 }
823
824 /* Optimization for marshalling 32 bit arguments */
825 int
826 rx_WriteProc32(struct rx_call *call, afs_int32 * value)
827 {
828     int bytes;
829     int tcurlen;
830     int tnFree;
831     char *tcurpos;
832     SPLVAR;
833
834     if (!opr_queue_IsEmpty(&call->app.iovq)) {
835 #ifdef RXDEBUG_PACKET
836         call->iovqc -=
837 #endif /* RXDEBUG_PACKET */
838             rxi_FreePackets(0, &call->app.iovq);
839     }
840
841     /*
842      * Most common case: all of the data fits in the current iovec.
843      * We are relying on nFree being zero unless the call is in send mode.
844      */
845     tcurlen = call->app.curlen;
846     tnFree = call->app.nFree;
847     if (!call->error && tcurlen >= sizeof(afs_int32)
848         && tnFree >= sizeof(afs_int32)) {
849         tcurpos = call->app.curpos;
850
851         if (!((size_t)tcurpos & (sizeof(afs_int32) - 1))) {
852             *((afs_int32 *) (tcurpos)) = *value;
853         } else {
854             memcpy(tcurpos, (char *)value, sizeof(afs_int32));
855         }
856         call->app.curpos = tcurpos + sizeof(afs_int32);
857         call->app.curlen = (u_short)(tcurlen - sizeof(afs_int32));
858         call->app.nFree = (u_short)(tnFree - sizeof(afs_int32));
859         return sizeof(afs_int32);
860     }
861
862     NETPRI;
863     bytes = rxi_WriteProc(call, (char *)value, sizeof(afs_int32));
864     USERPRI;
865     return bytes;
866 }
867
868 /* rxi_WritevAlloc -- internal version.
869  *
870  * Fill in an iovec to point to data in packet buffers. The application
871  * calls rxi_WritevProc when the buffers are full.
872  *
873  * LOCKS USED -- called at netpri.
874  */
875
876 static int
877 rxi_WritevAlloc(struct rx_call *call, struct iovec *iov, int *nio, int maxio,
878                 int nbytes)
879 {
880     struct rx_connection *conn = call->conn;
881     struct rx_packet *cp;
882     int requestCount;
883     int nextio;
884     /* Temporary values, real work is done in rxi_WritevProc */
885     int tnFree;
886     unsigned int tcurvec;
887     char *tcurpos;
888     int tcurlen;
889
890     requestCount = nbytes;
891     nextio = 0;
892
893     /* Free any packets from the last call to ReadvProc/WritevProc */
894     if (!opr_queue_IsEmpty(&call->app.iovq)) {
895 #ifdef RXDEBUG_PACKET
896         call->iovqc -=
897 #endif /* RXDEBUG_PACKET */
898             rxi_FreePackets(0, &call->app.iovq);
899     }
900
901     if (call->app.mode != RX_MODE_SENDING) {
902         if ((conn->type == RX_SERVER_CONNECTION)
903             && (call->app.mode == RX_MODE_RECEIVING)) {
904             call->app.mode = RX_MODE_SENDING;
905             if (call->app.currentPacket) {
906 #ifdef RX_TRACK_PACKETS
907                 call->app.currentPacket->flags &= ~RX_PKTFLAG_CP;
908 #endif
909                 rxi_FreePacket(call->app.currentPacket);
910                 call->app.currentPacket = NULL;
911                 call->app.nLeft = 0;
912                 call->app.nFree = 0;
913             }
914         } else {
915             return 0;
916         }
917     }
918
919     /* Set up the iovec to point to data in packet buffers. */
920     tnFree = call->app.nFree;
921     tcurvec = call->app.curvec;
922     tcurpos = call->app.curpos;
923     tcurlen = call->app.curlen;
924     cp = call->app.currentPacket;
925     do {
926         int t;
927
928         if (tnFree == 0) {
929             /* current packet is full, allocate a new one */
930             MUTEX_ENTER(&call->lock);
931             cp = rxi_AllocSendPacket(call, nbytes);
932             MUTEX_EXIT(&call->lock);
933             if (cp == NULL) {
934                 /* out of space, return what we have */
935                 *nio = nextio;
936                 return requestCount - nbytes;
937             }
938 #ifdef RX_TRACK_PACKETS
939             cp->flags |= RX_PKTFLAG_IOVQ;
940 #endif
941             opr_queue_Append(&call->app.iovq, &cp->entry);
942 #ifdef RXDEBUG_PACKET
943             call->iovqc++;
944 #endif /* RXDEBUG_PACKET */
945             tnFree = cp->length;
946             tcurvec = 1;
947             tcurpos =
948                 (char *)cp->wirevec[1].iov_base +
949                 call->conn->securityHeaderSize;
950             tcurlen = cp->wirevec[1].iov_len - call->conn->securityHeaderSize;
951         }
952
953         if (tnFree < nbytes) {
954             /* try to extend the current packet */
955             int len, mud;
956             len = cp->length;
957             mud = rx_MaxUserDataSize(call);
958             if (mud > len) {
959                 int want;
960                 want = MIN(nbytes - tnFree, mud - len);
961                 rxi_AllocDataBuf(cp, want, RX_PACKET_CLASS_SEND_CBUF);
962                 if (cp->length > (unsigned)mud)
963                     cp->length = mud;
964                 tnFree += (cp->length - len);
965                 if (cp == call->app.currentPacket) {
966                     call->app.nFree += (cp->length - len);
967                 }
968             }
969         }
970
971         /* fill in the next entry in the iovec */
972         t = MIN(tcurlen, nbytes);
973         t = MIN(tnFree, t);
974         iov[nextio].iov_base = tcurpos;
975         iov[nextio].iov_len = t;
976         nbytes -= t;
977         tcurpos += t;
978         tcurlen -= t;
979         tnFree -= t;
980         nextio++;
981
982         if (!tcurlen) {
983             /* need to get another struct iov */
984             if (++tcurvec >= cp->niovecs) {
985                 /* current packet is full, extend it or move on to next packet */
986                 tnFree = 0;
987             } else {
988                 tcurpos = (char *)cp->wirevec[tcurvec].iov_base;
989                 tcurlen = cp->wirevec[tcurvec].iov_len;
990             }
991         }
992     } while (nbytes && nextio < maxio);
993     *nio = nextio;
994     return requestCount - nbytes;
995 }
996
997 int
998 rx_WritevAlloc(struct rx_call *call, struct iovec *iov, int *nio, int maxio,
999                int nbytes)
1000 {
1001     int bytes;
1002     SPLVAR;
1003
1004     NETPRI;
1005     bytes = rxi_WritevAlloc(call, iov, nio, maxio, nbytes);
1006     USERPRI;
1007     return bytes;
1008 }
1009
1010 /* rxi_WritevProc -- internal version.
1011  *
1012  * Send buffers allocated in rxi_WritevAlloc.
1013  *
1014  * LOCKS USED -- called at netpri.
1015  */
1016 int
1017 rxi_WritevProc(struct rx_call *call, struct iovec *iov, int nio, int nbytes)
1018 {
1019 #ifdef RX_TRACK_PACKETS
1020     struct opr_queue *cursor;
1021 #endif
1022     int nextio;
1023     int requestCount;
1024     struct opr_queue tmpq;
1025 #ifdef RXDEBUG_PACKET
1026     u_short tmpqc;
1027 #endif
1028
1029     requestCount = nbytes;
1030     nextio = 0;
1031
1032     MUTEX_ENTER(&call->lock);
1033     if (call->error) {
1034         call->app.mode = RX_MODE_ERROR;
1035     } else if (call->app.mode != RX_MODE_SENDING) {
1036         call->error = RX_PROTOCOL_ERROR;
1037     }
1038     rxi_WaitforTQBusy(call);
1039
1040     if (call->error) {
1041         call->app.mode = RX_MODE_ERROR;
1042         MUTEX_EXIT(&call->lock);
1043         if (call->app.currentPacket) {
1044 #ifdef RX_TRACK_PACKETS
1045             call->app.currentPacket->flags &= ~RX_PKTFLAG_CP;
1046             call->app.currentPacket->flags |= RX_PKTFLAG_IOVQ;
1047 #endif
1048             opr_queue_Prepend(&call->app.iovq,
1049                               &call->app.currentPacket->entry);
1050 #ifdef RXDEBUG_PACKET
1051             call->iovqc++;
1052 #endif /* RXDEBUG_PACKET */
1053             call->app.currentPacket = NULL;
1054         }
1055 #ifdef RXDEBUG_PACKET
1056         call->iovqc -=
1057 #endif /* RXDEBUG_PACKET */
1058             rxi_FreePackets(0, &call->app.iovq);
1059         return 0;
1060     }
1061
1062     /* Loop through the I/O vector adjusting packet pointers.
1063      * Place full packets back onto the iovq once they are ready
1064      * to send. Set RX_PROTOCOL_ERROR if any problems are found in
1065      * the iovec. We put the loop condition at the end to ensure that
1066      * a zero length write will push a short packet. */
1067     nextio = 0;
1068     opr_queue_Init(&tmpq);
1069 #ifdef RXDEBUG_PACKET
1070     tmpqc = 0;
1071 #endif /* RXDEBUG_PACKET */
1072     do {
1073         if (call->app.nFree == 0 && call->app.currentPacket) {
1074             clock_NewTime();    /* Bogus:  need new time package */
1075             /* The 0, below, specifies that it is not the last packet:
1076              * there will be others. PrepareSendPacket may
1077              * alter the packet length by up to
1078              * conn->securityMaxTrailerSize */
1079             call->app.bytesSent += call->app.currentPacket->length;
1080             rxi_PrepareSendPacket(call, call->app.currentPacket, 0);
1081             /* PrepareSendPacket drops the call lock */
1082             rxi_WaitforTQBusy(call);
1083             opr_queue_Append(&tmpq, &call->app.currentPacket->entry);
1084 #ifdef RXDEBUG_PACKET
1085             tmpqc++;
1086 #endif /* RXDEBUG_PACKET */
1087             call->app.currentPacket = NULL;
1088
1089             /* The head of the iovq is now the current packet */
1090             if (nbytes) {
1091                 if (opr_queue_IsEmpty(&call->app.iovq)) {
1092                     MUTEX_EXIT(&call->lock);
1093                     call->error = RX_PROTOCOL_ERROR;
1094 #ifdef RXDEBUG_PACKET
1095                     tmpqc -=
1096 #endif /* RXDEBUG_PACKET */
1097                         rxi_FreePackets(0, &tmpq);
1098                     return 0;
1099                 }
1100                 call->app.currentPacket
1101                         = opr_queue_First(&call->app.iovq, struct rx_packet,
1102                                           entry);
1103                 opr_queue_Remove(&call->app.currentPacket->entry);
1104 #ifdef RX_TRACK_PACKETS
1105                 call->app.currentPacket->flags &= ~RX_PKTFLAG_IOVQ;
1106                 call->app.currentPacket->flags |= RX_PKTFLAG_CP;
1107 #endif
1108 #ifdef RXDEBUG_PACKET
1109                 call->iovqc--;
1110 #endif /* RXDEBUG_PACKET */
1111                 call->app.nFree = call->app.currentPacket->length;
1112                 call->app.curvec = 1;
1113                 call->app.curpos =
1114                     (char *) call->app.currentPacket->wirevec[1].iov_base +
1115                     call->conn->securityHeaderSize;
1116                 call->app.curlen =
1117                     call->app.currentPacket->wirevec[1].iov_len -
1118                     call->conn->securityHeaderSize;
1119             }
1120         }
1121
1122         if (nbytes) {
1123             /* The next iovec should point to the current position */
1124             if (iov[nextio].iov_base != call->app.curpos
1125                 || iov[nextio].iov_len > (int)call->app.curlen) {
1126                 call->error = RX_PROTOCOL_ERROR;
1127                 MUTEX_EXIT(&call->lock);
1128                 if (call->app.currentPacket) {
1129 #ifdef RX_TRACK_PACKETS
1130                     call->app.currentPacket->flags &= ~RX_PKTFLAG_CP;
1131 #endif
1132                     opr_queue_Prepend(&tmpq,
1133                                       &call->app.currentPacket->entry);
1134 #ifdef RXDEBUG_PACKET
1135                     tmpqc++;
1136 #endif /* RXDEBUG_PACKET */
1137                     call->app.currentPacket = NULL;
1138                 }
1139 #ifdef RXDEBUG_PACKET
1140                 tmpqc -=
1141 #endif /* RXDEBUG_PACKET */
1142                     rxi_FreePackets(0, &tmpq);
1143                 return 0;
1144             }
1145             nbytes -= iov[nextio].iov_len;
1146             call->app.curpos += iov[nextio].iov_len;
1147             call->app.curlen -= iov[nextio].iov_len;
1148             call->app.nFree -= iov[nextio].iov_len;
1149             nextio++;
1150             if (call->app.curlen == 0) {
1151                 if (++call->app.curvec > call->app.currentPacket->niovecs) {
1152                     call->app.nFree = 0;
1153                 } else {
1154                     call->app.curpos =
1155                         call->app.currentPacket->wirevec[call->app.curvec].iov_base;
1156                     call->app.curlen =
1157                         call->app.currentPacket->wirevec[call->app.curvec].iov_len;
1158                 }
1159             }
1160         }
1161     } while (nbytes && nextio < nio);
1162
1163     /* Move the packets from the temporary queue onto the transmit queue.
1164      * We may end up with more than call->twind packets on the queue. */
1165
1166 #ifdef RX_TRACK_PACKETS
1167     for (opr_queue_Scan(&tmpq, cursor))
1168     {
1169         struct rx_packet *p = opr_queue_Entry(cursor, struct rx_packet, entry);
1170         p->flags |= RX_PKTFLAG_TQ;
1171     }
1172 #endif
1173     if (call->error)
1174         call->app.mode = RX_MODE_ERROR;
1175
1176     opr_queue_SpliceAppend(&call->tq, &tmpq);
1177
1178     /* If the call is in recovery, let it exhaust its current retransmit
1179      * queue before forcing it to send new packets
1180      */
1181     if (!(call->flags & RX_CALL_FAST_RECOVER)) {
1182         rxi_Start(call, 0);
1183     }
1184
1185     /* Wait for the length of the transmit queue to fall below call->twind */
1186     while (!call->error && call->tnext + 1 > call->tfirst + (2 * call->twind)) {
1187         clock_NewTime();
1188         call->startWait = clock_Sec();
1189 #ifdef  RX_ENABLE_LOCKS
1190         CV_WAIT(&call->cv_twind, &call->lock);
1191 #else
1192         call->flags |= RX_CALL_WAIT_WINDOW_ALLOC;
1193         osi_rxSleep(&call->twind);
1194 #endif
1195         call->startWait = 0;
1196     }
1197
1198     if (call->error) {
1199         call->app.mode = RX_MODE_ERROR;
1200         call->app.currentPacket = NULL;
1201         MUTEX_EXIT(&call->lock);
1202         if (call->app.currentPacket) {
1203 #ifdef RX_TRACK_PACKETS
1204             call->app.currentPacket->flags &= ~RX_PKTFLAG_CP;
1205 #endif
1206             rxi_FreePacket(call->app.currentPacket);
1207         }
1208         return 0;
1209     }
1210     MUTEX_EXIT(&call->lock);
1211
1212     return requestCount - nbytes;
1213 }
1214
1215 int
1216 rx_WritevProc(struct rx_call *call, struct iovec *iov, int nio, int nbytes)
1217 {
1218     int bytes;
1219     SPLVAR;
1220
1221     NETPRI;
1222     bytes = rxi_WritevProc(call, iov, nio, nbytes);
1223     USERPRI;
1224     return bytes;
1225 }
1226
1227 /* Flush any buffered data to the stream, switch to read mode
1228  * (clients) or to EOF mode (servers)
1229  *
1230  * LOCKS HELD: called at netpri.
1231  */
1232 void
1233 rxi_FlushWrite(struct rx_call *call)
1234 {
1235     struct rx_packet *cp = NULL;
1236
1237     /* Free any packets from the last call to ReadvProc/WritevProc */
1238     if (!opr_queue_IsEmpty(&call->app.iovq)) {
1239 #ifdef RXDEBUG_PACKET
1240         call->iovqc -=
1241 #endif /* RXDEBUG_PACKET */
1242             rxi_FreePackets(0, &call->app.iovq);
1243     }
1244
1245     if (call->app.mode == RX_MODE_SENDING) {
1246
1247         call->app.mode =
1248             (call->conn->type ==
1249              RX_CLIENT_CONNECTION ? RX_MODE_RECEIVING : RX_MODE_EOF);
1250
1251 #ifdef RX_KERNEL_TRACE
1252         {
1253             int glockOwner = ISAFS_GLOCK();
1254             if (!glockOwner)
1255                 AFS_GLOCK();
1256             afs_Trace3(afs_iclSetp, CM_TRACE_WASHERE, ICL_TYPE_STRING,
1257                        __FILE__, ICL_TYPE_INT32, __LINE__, ICL_TYPE_POINTER,
1258                        call);
1259             if (!glockOwner)
1260                 AFS_GUNLOCK();
1261         }
1262 #endif
1263
1264         MUTEX_ENTER(&call->lock);
1265         if (call->error)
1266             call->app.mode = RX_MODE_ERROR;
1267
1268         call->flags |= RX_CALL_FLUSH;
1269
1270         cp = call->app.currentPacket;
1271
1272         if (cp) {
1273             /* cp->length is only supposed to be the user's data */
1274             /* cp->length was already set to (then-current)
1275              * MaxUserDataSize or less. */
1276 #ifdef RX_TRACK_PACKETS
1277             cp->flags &= ~RX_PKTFLAG_CP;
1278 #endif
1279             cp->length -= call->app.nFree;
1280             call->app.currentPacket = NULL;
1281             call->app.nFree = 0;
1282         } else {
1283             cp = rxi_AllocSendPacket(call, 0);
1284             if (!cp) {
1285                 /* Mode can no longer be MODE_SENDING */
1286                 return;
1287             }
1288             cp->length = 0;
1289             cp->niovecs = 2;    /* header + space for rxkad stuff */
1290             call->app.nFree = 0;
1291         }
1292
1293         /* The 1 specifies that this is the last packet */
1294         call->app.bytesSent += cp->length;
1295         rxi_PrepareSendPacket(call, cp, 1);
1296         /* PrepareSendPacket drops the call lock */
1297         rxi_WaitforTQBusy(call);
1298 #ifdef RX_TRACK_PACKETS
1299         cp->flags |= RX_PKTFLAG_TQ;
1300 #endif
1301         opr_queue_Append(&call->tq, &cp->entry);
1302 #ifdef RXDEBUG_PACKET
1303         call->tqc++;
1304 #endif /* RXDEBUG_PACKET */
1305
1306         /* If the call is in recovery, let it exhaust its current retransmit
1307          * queue before forcing it to send new packets
1308          */
1309         if (!(call->flags & RX_CALL_FAST_RECOVER)) {
1310             rxi_Start(call, 0);
1311         }
1312         MUTEX_EXIT(&call->lock);
1313     }
1314 }
1315
1316 /* Flush any buffered data to the stream, switch to read mode
1317  * (clients) or to EOF mode (servers) */
1318 void
1319 rx_FlushWrite(struct rx_call *call)
1320 {
1321     SPLVAR;
1322     NETPRI;
1323     rxi_FlushWrite(call);
1324     USERPRI;
1325 }