DEVEL15-rx-init-more-packets-20080529

LICENSE MIT

It is frequently the case that rx_getAllAddr() is called before
rx_Init() or rx_InitHost().  rx_getAllAddr() obtains the list of
interfaces by using rx_GetIFInfo() which in turn computes and
allocates the number of addition rx packets.  Unfortunately,
rxi_MorePackets() relies on the existence of an initialized mutex
and the mutex is not initialized (on Windows) until the rx_InitHost()
call.  Therefore, we must delay the rxi_MorePackets() call until
after rx_InitHost() if rx_getAllAddr() is called previously.

Failure to do so results in a panic.


(cherry picked from commit 749ae65481ebc70f310fdd79d2cb0139a636f27e)
This commit is contained in:
Jeffrey Altman 2008-05-29 14:33:29 +00:00
parent 040a4a93b5
commit 775630172b
2 changed files with 36 additions and 8 deletions

View File

@ -358,7 +358,10 @@ rx_SetEpoch(afs_uint32 epoch)
* by the kernel. Whether this will ever overlap anything in
* /etc/services is anybody's guess... Returns 0 on success, -1 on
* error. */
static int rxinit_status = 1;
#ifndef AFS_NT40_ENV
static
#endif
int rxinit_status = 1;
#ifdef AFS_PTHREAD_ENV
/*
* This mutex protects the following global variables:

View File

@ -325,15 +325,36 @@ rx_getAllAddr(afs_int32 * buffer, int maxSize)
#endif
#ifdef AFS_NT40_ENV
extern int rxinit_status;
void
rxi_InitMorePackets(void) {
int npackets, ncbufs;
ncbufs = (rx_maxJumboRecvSize - RX_FIRSTBUFFERSIZE);
if (ncbufs > 0) {
ncbufs = ncbufs / RX_CBUFFERSIZE;
npackets = rx_initSendWindow - 1;
rxi_MorePackets(npackets * (ncbufs + 1));
}
}
void
rx_GetIFInfo(void)
{
u_int maxsize;
u_int rxsize;
int npackets, ncbufs;
afs_uint32 i;
LOCK_IF_INIT;
if (Inited) {
if (Inited < 2 && rxinit_status == 0) {
/* We couldn't initialize more packets earlier.
* Do it now. */
rxi_InitMorePackets();
Inited = 2;
}
UNLOCK_IF_INIT;
return;
}
Inited = 1;
UNLOCK_IF_INIT;
@ -355,12 +376,16 @@ rx_GetIFInfo(void)
}
UNLOCK_IF;
ncbufs = (rx_maxJumboRecvSize - RX_FIRSTBUFFERSIZE);
if (ncbufs > 0) {
ncbufs = ncbufs / RX_CBUFFERSIZE;
npackets = rx_initSendWindow - 1;
rxi_MorePackets(npackets * (ncbufs + 1));
}
/*
* If rxinit_status is still set, rx_InitHost() has yet to be called
* and we therefore do not have any mutex locks initialized. As a
* result we cannot call rxi_MorePackets() without crashing.
*/
if (rxinit_status)
return;
rxi_InitMorePackets();
}
#endif