# include "afs/lock.h"
#else /* KERNEL */
# include <roken.h>
-# include <sys/types.h>
-# include <string.h>
-# ifdef AFS_NT40_ENV
-# include <winsock2.h>
-# else /* !AFS_NT40_ENV */
-# include <sys/socket.h>
-# include <sys/file.h>
-# include <netdb.h>
-# include <netinet/in.h>
-# include <sys/stat.h>
-# include <sys/time.h>
-# include <unistd.h>
-# endif /* !AFS_NT40_ENV */
#endif /* KERNEL */
#include "rx.h"
#include "rx_queue.h"
#include "rx_globals.h"
+#include "rx_conn.h"
+#include "rx_call.h"
+#include "rx_packet.h"
+
#ifdef RX_LOCKS_DB
/* rxdb_fileID is used to identify the lock location, along with line#. */
static int rxdb_fileID = RXDB_FILE_RX_RDWR;
call->nHardAcks++;
if (!(call->flags & RX_CALL_RECEIVE_DONE)) {
if (call->nHardAcks > (u_short) rxi_HardAckRate) {
- rxevent_Cancel(call->delayedAckEvent, call,
+ rxevent_Cancel(&call->delayedAckEvent, call,
RX_CALL_REFCOUNT_DELAY);
rxi_SendAck(call, 0, 0, RX_ACK_DELAY, 0);
} else {
- struct clock when, now;
- clock_GetTime(&now);
- when = now;
/* Delay to consolidate ack packets */
- clock_Add(&when, &rx_hardAckDelay);
- if (!call->delayedAckEvent
- || clock_Gt(&call->delayedAckEvent->
- eventTime, &when)) {
- rxevent_Cancel(call->delayedAckEvent,
- call,
- RX_CALL_REFCOUNT_DELAY);
- MUTEX_ENTER(&rx_refcnt_mutex);
- CALL_HOLD(call, RX_CALL_REFCOUNT_DELAY);
- MUTEX_EXIT(&rx_refcnt_mutex);
- call->delayedAckEvent =
- rxevent_PostNow(&when, &now,
- rxi_SendDelayedAck, call,
- 0);
- }
+ rxi_PostDelayedAckEvent(call,
+ &rx_hardAckDelay);
}
}
break;
rx_ReadProc(struct rx_call *call, char *buf, int nbytes)
{
int bytes;
- int tcurlen;
- int tnLeft;
- char *tcurpos;
SPLVAR;
/* Free any packets from the last call to ReadvProc/WritevProc */
* Most common case, all of the data is in the current iovec.
* We are relying on nLeft being zero unless the call is in receive mode.
*/
- tcurlen = call->curlen;
- tnLeft = call->nLeft;
- if (!call->error && tcurlen > nbytes && tnLeft > nbytes) {
- tcurpos = call->curpos;
- memcpy(buf, tcurpos, nbytes);
+ if (!call->error && call->curlen > nbytes && call->nLeft > nbytes) {
+ memcpy(buf, call->curpos, nbytes);
- call->curpos = tcurpos + nbytes;
- call->curlen = tcurlen - nbytes;
- call->nLeft = tnLeft - nbytes;
+ call->curpos += nbytes;
+ call->curlen -= nbytes;
+ call->nLeft -= nbytes;
if (!call->nLeft && call->currentPacket != NULL) {
/* out of packet. Get another one. */
rx_ReadProc32(struct rx_call *call, afs_int32 * value)
{
int bytes;
- int tcurlen;
- int tnLeft;
- char *tcurpos;
SPLVAR;
/* Free any packets from the last call to ReadvProc/WritevProc */
* Most common case, all of the data is in the current iovec.
* We are relying on nLeft being zero unless the call is in receive mode.
*/
- tcurlen = call->curlen;
- tnLeft = call->nLeft;
- if (!call->error && tcurlen >= sizeof(afs_int32)
- && tnLeft >= sizeof(afs_int32)) {
- tcurpos = call->curpos;
+ if (!call->error && call->curlen >= sizeof(afs_int32)
+ && call->nLeft >= sizeof(afs_int32)) {
- memcpy((char *)value, tcurpos, sizeof(afs_int32));
+ memcpy((char *)value, call->curpos, sizeof(afs_int32));
+
+ call->curpos += sizeof(afs_int32);
+ call->curlen -= sizeof(afs_int32);
+ call->nLeft -= sizeof(afs_int32);
- call->curpos = tcurpos + sizeof(afs_int32);
- call->curlen = (u_short)(tcurlen - sizeof(afs_int32));
- call->nLeft = (u_short)(tnLeft - sizeof(afs_int32));
if (!call->nLeft && call->currentPacket != NULL) {
/* out of packet. Get another one. */
rxi_FreePacket(call->currentPacket);
* send a hard ack. */
if (didConsume && (!(call->flags & RX_CALL_RECEIVE_DONE))) {
if (call->nHardAcks > (u_short) rxi_HardAckRate) {
- rxevent_Cancel(call->delayedAckEvent, call,
+ rxevent_Cancel(&call->delayedAckEvent, call,
RX_CALL_REFCOUNT_DELAY);
rxi_SendAck(call, 0, serial, RX_ACK_DELAY, 0);
didHardAck = 1;
} else {
- struct clock when, now;
- clock_GetTime(&now);
- when = now;
/* Delay to consolidate ack packets */
- clock_Add(&when, &rx_hardAckDelay);
- if (!call->delayedAckEvent
- || clock_Gt(&call->delayedAckEvent->eventTime, &when)) {
- rxevent_Cancel(call->delayedAckEvent, call,
- RX_CALL_REFCOUNT_DELAY);
- MUTEX_ENTER(&rx_refcnt_mutex);
- CALL_HOLD(call, RX_CALL_REFCOUNT_DELAY);
- MUTEX_EXIT(&rx_refcnt_mutex);
- call->delayedAckEvent =
- rxevent_PostNow(&when, &now, rxi_SendDelayedAck, call, 0);
- }
+ rxi_PostDelayedAckEvent(call, &rx_hardAckDelay);
}
}
return didHardAck;
call->tqc++;
#endif /* RXDEBUG_PACKET */
cp = (struct rx_packet *)0;
- if (!
- (call->
- flags & (RX_CALL_FAST_RECOVER |
- RX_CALL_FAST_RECOVER_WAIT))) {
- rxi_Start(0, call, 0, 0);
+ /* If the call is in recovery, let it exhaust its current
+ * retransmit queue before forcing it to send new packets
+ */
+ if (!(call->flags & (RX_CALL_FAST_RECOVER))) {
+ rxi_Start(call, 0);
}
} else if (cp) {
#ifdef RX_TRACK_PACKETS
* LOCKS USED -- called at netpri.
*/
-int
+static int
rxi_WritevAlloc(struct rx_call *call, struct iovec *iov, int *nio, int maxio,
int nbytes)
{
queue_SpliceAppend(&call->tq, &tmpq);
- if (!(call->flags & (RX_CALL_FAST_RECOVER | RX_CALL_FAST_RECOVER_WAIT))) {
- rxi_Start(0, call, 0, 0);
+ /* If the call is in recovery, let it exhaust its current retransmit
+ * queue before forcing it to send new packets
+ */
+ if (!(call->flags & RX_CALL_FAST_RECOVER)) {
+ rxi_Start(call, 0);
}
/* Wait for the length of the transmit queue to fall below call->twind */
#ifdef RXDEBUG_PACKET
call->tqc++;
#endif /* RXDEBUG_PACKET */
- if (!
- (call->
- flags & (RX_CALL_FAST_RECOVER | RX_CALL_FAST_RECOVER_WAIT))) {
- rxi_Start(0, call, 0, 0);
+
+ /* If the call is in recovery, let it exhaust its current retransmit
+ * queue before forcing it to send new packets
+ */
+ if (!(call->flags & RX_CALL_FAST_RECOVER)) {
+ rxi_Start(call, 0);
}
MUTEX_EXIT(&call->lock);
}