Index: nsd/driver.c =================================================================== RCS file: /cvsroot/aolserver/aolserver/nsd/driver.c,v retrieving revision 1.19 diff -u -r1.19 driver.c --- nsd/driver.c 15 Feb 2004 16:29:01 -0000 1.19 +++ nsd/driver.c 23 Feb 2004 20:46:09 -0000 @@ -564,6 +564,47 @@ /* *---------------------------------------------------------------------- * + * NsWaitDriversStartup -- + * + * Wait for startup of all DriverThreads. Current behavior is to + * just wait until all sockets are bound to. + * + * Results: + * None. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + +void +NsWaitDriversStartup(void) +{ + Driver *drvPtr = firstDrvPtr; + int status = NS_OK; + Ns_Time timeout; + + Ns_GetTime(&timeout); + Ns_IncrTime(&timeout, 10, 0); + + while (drvPtr != NULL) { + Ns_MutexLock(&drvPtr->lock); + while (!drvPtr->started && status == NS_OK) { + status = Ns_CondTimedWait(&drvPtr->cond, &drvPtr->lock, &timeout); + } + Ns_MutexUnlock(&drvPtr->lock); + if (status != NS_OK) { + Ns_Log(Warning, "driver: startup timeout: %s", drvPtr->module); + } + drvPtr = drvPtr->nextPtr; + } +} + + +/* + *---------------------------------------------------------------------- + * * NsStopDrivers -- * * Trigger the DriverThread to begin shutdown. @@ -784,6 +825,10 @@ drvPtr->address, drvPtr->port, ns_sockstrerror(ns_sockerrno)); } Ns_SockSetNonBlocking(drvPtr->sock); + Ns_MutexLock(&drvPtr->lock); + drvPtr->started = 1; + Ns_CondBroadcast(&drvPtr->cond); + Ns_MutexUnlock(&drvPtr->lock); /* * Pre-allocate Sock structures. Index: nsd/nsd.h =================================================================== RCS file: /cvsroot/aolserver/aolserver/nsd/nsd.h,v retrieving revision 1.78 diff -u -r1.78 nsd.h --- nsd/nsd.h 16 Nov 2003 15:04:13 -0000 1.78 +++ nsd/nsd.h 23 Feb 2004 20:46:10 -0000 @@ -317,6 +317,7 @@ struct Sock *firstReadyPtr; /* Sock's returning from reader threads. */ int trigger[2]; /* Wakeup trigger pipe. */ + int started; /* Startup complete. */ int shutdown; /* Shutdown pending. */ int stopped; /* Shutdown complete. */ Index: nsd/nsmain.c =================================================================== RCS file: /cvsroot/aolserver/aolserver/nsd/nsmain.c,v retrieving revision 1.53 diff -u -r1.53 nsmain.c --- nsd/nsmain.c 16 Nov 2003 17:54:22 -0000 1.53 +++ nsd/nsmain.c 23 Feb 2004 20:46:10 -0000 @@ -579,6 +579,7 @@ */ NsStartDrivers(); + NsWaitDriversStartup(); #ifndef _WIN32 NsClosePreBound(); #endif