#else /* KERNEL */
# include <sys/types.h>
# include <string.h>
+# include <stdarg.h>
# include <errno.h>
#ifdef AFS_NT40_ENV
# include <stdlib.h>
# include <afs/rxgen_consts.h>
#endif /* KERNEL */
-int (*registerProgram) () = 0;
-int (*swapNameProgram) () = 0;
+#ifndef KERNEL
+#ifdef AFS_PTHREAD_ENV
+#ifndef AFS_NT40_ENV
+int (*registerProgram) (pid_t, char *) = 0;
+int (*swapNameProgram) (pid_t, const char *, char *) = 0;
+#endif
+#else
+int (*registerProgram) (PROCESS, char *) = 0;
+int (*swapNameProgram) (PROCESS, const char *, char *) = 0;
+#endif
+#endif
/* Local static routines */
static void rxi_DestroyConnectionNoLock(register struct rx_connection *conn);
#if defined(RX_ENABLE_LOCKS) && defined(KERNEL)
static afs_kmutex_t rx_rpc_stats;
-void rxi_StartUnlocked();
+void rxi_StartUnlocked(struct rxevent *event, void *call,
+ void *arg1, int istack);
#endif
/* We keep a "last conn pointer" in rxi_FindConnection. The odds are
rxi_nCalls = 0;
rx_connDeadTime = 12;
rx_tranquil = 0; /* reset flag */
- memset((char *)&rx_stats, 0, sizeof(struct rx_stats));
+ memset((char *)&rx_stats, 0, sizeof(struct rx_statistics));
htable = (char *)
osi_Alloc(rx_hashTableSize * sizeof(struct rx_connection *));
PIN(htable, rx_hashTableSize * sizeof(struct rx_connection *)); /* XXXXX */
rx_port = 0;
#else
struct sockaddr_in addr;
- int addrlen = sizeof(addr);
+#ifdef AFS_NT40_ENV
+ int addrlen = sizeof(addr);
+#else
+ socklen_t addrlen = sizeof(addr);
+#endif
if (getsockname((int)rx_socket, (struct sockaddr *)&addr, &addrlen)) {
rx_Finalize();
return -1;
}
/* Turn on reaping of idle server connections */
- rxi_ReapConnections();
+ rxi_ReapConnections(NULL, NULL, NULL);
USERPRI;
USERPRI;
}
+#ifdef AFS_GLOBAL_RXLOCK_KERNEL
/* Wait for the transmit queue to no longer be busy.
* requires the call->lock to be held */
static void rxi_WaitforTQBusy(struct rx_call *call) {
}
}
}
+#endif
+
/* Start a new rx remote procedure call, on the specified connection.
* If wait is set to 1, wait for a free call channel; otherwise return
* 0. Maxtime gives the maximum number of seconds this call may take,
MUTEX_ENTER(&call->lock);
rxi_WaitforTQBusy(call);
if (call->flags & RX_CALL_TQ_CLEARME) {
- rxi_ClearTransmitQueue(call, 0);
+ rxi_ClearTransmitQueue(call, 1);
queue_Init(&call->tq);
}
MUTEX_EXIT(&call->lock);
* kernel version, and may interrupt the macros rx_Read or
* rx_Write, which run at normal priority for efficiency. */
if (call->currentPacket) {
- queue_Prepend(&call->iovq, call->currentPacket);
+ call->currentPacket->flags &= ~RX_PKTFLAG_CP;
+ rxi_FreePacket(call->currentPacket);
call->currentPacket = (struct rx_packet *)0;
}
#ifdef AFS_GLOBAL_RXLOCK_KERNEL
/* Now, if TQ wasn't cleared earlier, do it now. */
if (call->flags & RX_CALL_TQ_CLEARME) {
- rxi_ClearTransmitQueue(call, 0);
+ rxi_ClearTransmitQueue(call, 1);
queue_Init(&call->tq);
}
#endif /* AFS_GLOBAL_RXLOCK_KERNEL */
}
}
} else {
- struct rx_peer *peer, *next;
+ struct rx_peer *peer;
hashIndex = PEER_HASH(host, port);
for (peer = rx_peerHashTable[hashIndex]; peer; peer = peer->next) {
if ((peer->host == host) && (peer->port == port)) {
* containing the network address. Both can be modified. The return value, if
* non-zero, indicates that the packet should be dropped. */
-int (*rx_justReceived) () = 0;
-int (*rx_almostSent) () = 0;
+int (*rx_justReceived) (struct rx_packet *, struct sockaddr_in *) = 0;
+int (*rx_almostSent) (struct rx_packet *, struct sockaddr_in *) = 0;
/* A packet has been received off the interface. Np is the packet, socket is
* the socket number it was received from (useful in determining which service
#endif /* KERNEL */
static void
-rxi_CheckReachEvent(struct rxevent *event, struct rx_connection *conn,
- struct rx_call *acall)
+rxi_CheckReachEvent(struct rxevent *event, void *arg1, void *arg2)
{
+ struct rx_connection *conn = arg1;
+ struct rx_call *acall = arg2;
struct rx_call *call = acall;
struct clock when, now;
int i, waiting;
/* It's the next packet. Stick it on the receive queue
* for this call. Set newPackets to make sure we wake
* the reader once all packets have been processed */
+ np->flags |= RX_PKTFLAG_RQ;
queue_Prepend(&call->rq, np);
call->nSoftAcks++;
np = NULL; /* We can't use this anymore */
#endif /* AFS_GLOBAL_RXLOCK_KERNEL */
{
queue_Remove(tp);
+ tp->flags &= ~RX_PKTFLAG_TQ;
rxi_FreePacket(tp); /* rxi_FreePacket mustn't wake up anyone, preemptively. */
}
}
}
void
-rxi_SendDelayedAck(struct rxevent *event, register struct rx_call *call,
- char *dummy)
+rxi_SendDelayedAck(struct rxevent *event, void *arg1, void *unused)
{
+ struct rx_call *call = arg1;
#ifdef RX_ENABLE_LOCKS
if (event) {
MUTEX_ENTER(&call->lock);
if (call->error)
error = call->error;
-#ifdef RX_GLOBAL_RXLOCK_KERNEL
+#ifdef AFS_GLOBAL_RXLOCK_KERNEL
if (!((call->flags & RX_CALL_TQ_BUSY) || (call->tqWaiters > 0))) {
rxi_ResetCall(call, 0);
}
MUTEX_EXIT(&peer->peer_lock);
flags = call->flags;
- rxi_ClearReceiveQueue(call);
#ifdef AFS_GLOBAL_RXLOCK_KERNEL
if (flags & RX_CALL_TQ_BUSY) {
call->flags = RX_CALL_TQ_CLEARME | RX_CALL_TQ_BUSY;
} else
#endif /* AFS_GLOBAL_RXLOCK_KERNEL */
{
- rxi_ClearTransmitQueue(call, 0);
- queue_Init(&call->tq);
+ rxi_ClearTransmitQueue(call, 1);
+ /* why init the queue if you just emptied it? queue_Init(&call->tq); */
if (call->tqWaiters || (flags & RX_CALL_TQ_WAIT)) {
dpf(("rcall %x has %d waiters and flags %d\n", call, call->tqWaiters, call->flags));
}
call->tqWaiters--;
}
}
- queue_Init(&call->rq);
+
+ rxi_ClearReceiveQueue(call);
+ /* why init the queue if you just emptied it? queue_Init(&call->rq); */
+
+ if (call->currentPacket) {
+ call->currentPacket->flags &= ~RX_PKTFLAG_CP;
+ rxi_FreePacket(call->currentPacket);
+ call->currentPacket = (struct rx_packet *)0;
+ }
+ call->curlen = call->nLeft = call->nFree = 0;
+
+ rxi_FreePackets(0, &call->iovq);
+
call->error = 0;
call->twind = call->conn->twind[call->channel];
call->rwind = call->conn->rwind[call->channel];
#ifdef RX_ENABLE_LOCKS
/* Call rxi_Start, below, but with the call lock held. */
void
-rxi_StartUnlocked(struct rxevent *event, register struct rx_call *call,
- void *arg1, int istack)
+rxi_StartUnlocked(struct rxevent *event,
+ void *arg0, void *arg1, int istack)
{
+ struct rx_call *call = arg0;
+
MUTEX_ENTER(&call->lock);
rxi_Start(event, call, arg1, istack);
MUTEX_EXIT(&call->lock);
* better optimized for new packets, the usual case, now that we've
* got rid of queues of send packets. XXXXXXXXXXX */
void
-rxi_Start(struct rxevent *event, register struct rx_call *call,
- void *arg1, int istack)
+rxi_Start(struct rxevent *event,
+ void *arg0, void *arg1, int istack)
{
+ struct rx_call *call = arg0;
+
struct rx_packet *p;
register struct rx_packet *nxp; /* Next pointer for queue_Scan */
struct rx_peer *peer = call->conn->peer;
if (p->header.seq < call->tfirst
&& (p->flags & RX_PKTFLAG_ACKED)) {
queue_Remove(p);
+ p->flags &= ~RX_PKTFLAG_TQ;
rxi_FreePacket(p);
} else
missing = 1;
afs_uint32 now;
afs_uint32 deadTime;
-#ifdef RX_GLOBAL_RXLOCK_KERNEL
+#ifdef AFS_GLOBAL_RXLOCK_KERNEL
if (call->flags & RX_CALL_TQ_BUSY) {
/* Call is active and will be reset by rxi_Start if it's
* in an error state.
* keep-alive packet (if we're actually trying to keep the call alive)
*/
void
-rxi_KeepAliveEvent(struct rxevent *event, register struct rx_call *call,
- char *dummy)
+rxi_KeepAliveEvent(struct rxevent *event, void *arg1, void *dummy)
{
+ struct rx_call *call = arg1;
struct rx_connection *conn;
afs_uint32 now;
* that have been delayed to throttle looping clients. */
void
rxi_SendDelayedConnAbort(struct rxevent *event,
- register struct rx_connection *conn, char *dummy)
+ void *arg1, void *unused)
{
+ struct rx_connection *conn = arg1;
+
afs_int32 error;
struct rx_packet *packet;
/* This routine is called to send call abort messages
* that have been delayed to throttle looping clients. */
void
-rxi_SendDelayedCallAbort(struct rxevent *event, register struct rx_call *call,
- char *dummy)
+rxi_SendDelayedCallAbort(struct rxevent *event,
+ void *arg1, void *dummy)
{
+ struct rx_call *call = arg1;
+
afs_int32 error;
struct rx_packet *packet;
* issues a challenge to the client, which is obtained from the
* security object associated with the connection */
void
-rxi_ChallengeEvent(struct rxevent *event, register struct rx_connection *conn,
- void *arg1, int tries)
+rxi_ChallengeEvent(struct rxevent *event,
+ void *arg0, void *arg1, int tries)
{
+ struct rx_connection *conn = arg0;
+
conn->challengeEvent = NULL;
if (RXS_CheckAuthentication(conn->securityObject, conn) != 0) {
register struct rx_packet *packet;
/* Find all server connections that have not been active for a long time, and
* toss them */
void
-rxi_ReapConnections(void)
+rxi_ReapConnections(struct rxevent *unused, void *unused1, void *unused2)
{
struct clock now, when;
clock_GetTime(&now);
/* Don't call this debugging routine directly; use dpf */
void
-rxi_DebugPrint(char *format, int a1, int a2, int a3, int a4, int a5, int a6,
- int a7, int a8, int a9, int a10, int a11, int a12, int a13,
- int a14, int a15)
+rxi_DebugPrint(char *format, ...)
{
#ifdef AFS_NT40_ENV
char msg[512];
len = _snprintf(tformat, sizeof(tformat), "tid[%d] %s", GetCurrentThreadId(), format);
if (len > 0) {
- len = _snprintf(msg, sizeof(msg)-2,
- tformat, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
- a11, a12, a13, a14, a15);
+ len = _vsnprintf(msg, sizeof(msg)-2, tformat, ap);
if (len > 0) {
if (msg[len-1] != '\n') {
msg[len] = '\n';
OutputDebugString(msg);
}
}
+ va_end(ap);
#else
struct clock now;
+ va_list ap;
+
+ va_start(ap, format);
+
clock_GetTime(&now);
fprintf(rx_Log, " %u.%.3u:", (unsigned int)now.sec,
(unsigned int)now.usec / 1000);
- fprintf(rx_Log, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12,
- a13, a14, a15);
+ vfprintf(rx_Log, format, ap);
putc('\n', rx_Log);
+ va_end(ap);
#endif
}
* checking.
*/
void
-rx_PrintTheseStats(FILE * file, struct rx_stats *s, int size,
+rx_PrintTheseStats(FILE * file, struct rx_statistics *s, int size,
afs_int32 freePackets, char version)
{
int i;
- if (size != sizeof(struct rx_stats)) {
+ if (size != sizeof(struct rx_statistics)) {
fprintf(file,
- "Unexpected size of stats structure: was %d, expected %d\n",
- size, sizeof(struct rx_stats));
+ "Unexpected size of stats structure: was %d, expected %lud\n",
+ size, sizeof(struct rx_statistics));
}
fprintf(file, "rx stats: free packets %d, allocs %d, ", (int)freePackets,
register afs_int32 code;
struct timeval tv_now, tv_wake, tv_delta;
struct sockaddr_in taddr, faddr;
+#ifdef AFS_NT40_ENV
int faddrLen;
+#else
+ socklen_t faddrLen;
+#endif
fd_set imask;
register char *tp;
afs_int32
rx_GetServerStats(osi_socket socket, afs_uint32 remoteAddr,
- afs_uint16 remotePort, struct rx_stats * stat,
+ afs_uint16 remotePort, struct rx_statistics * stat,
afs_uint32 * supportedValues)
{
struct rx_debugIn in;