From: Zoran V. <vas...@us...> - 2005-10-20 16:50:56
|
Update of /cvsroot/naviserver/naviserver/nsd In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21973/nsd Modified Files: callbacks.c Log Message: Untabified, indented... Index: callbacks.c =================================================================== RCS file: /cvsroot/naviserver/naviserver/nsd/callbacks.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** callbacks.c 20 Oct 2005 16:41:36 -0000 1.3 --- callbacks.c 20 Oct 2005 16:50:44 -0000 1.4 *************** *** 1,7 **** /* ! * The contents of this file are subject to the AOLserver Public License * Version 1.1 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at ! * http://aolserver.lcs.mit.edu/. * * Software distributed under the License is distributed on an "AS IS" --- 1,7 ---- /* ! * The contents of this file are subject to the Mozilla Public License * Version 1.1 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at ! * http://mozilla.org/. * * Software distributed under the License is distributed on an "AS IS" *************** *** 31,38 **** * callbacks.c -- * ! * Support for Callbacks * ! * These functions allow the registration of callbacks ! * that are run at various points during the server's execution. */ --- 31,38 ---- * callbacks.c -- * ! * Support for Callbacks * ! * These functions allow the registration of callbacks ! * that are run at various points during the server's execution. */ *************** *** 57,64 **** static Ns_ThreadProc RunThread; ! static void RunCallbacks(Callback *firstPtr, int reverse); ! static void RunStart(Callback **firstPtrPtr, Ns_Thread *threadPtr); ! static void RunWait(Callback **firstPtrPtr, Ns_Thread *threadPtr, Ns_Time *toPtr); ! static void *RegisterAt(Callback **firstPtrPtr, Ns_Callback *proc, void *arg); /* --- 57,65 ---- static Ns_ThreadProc RunThread; ! ! static void RunCallbacks(Callback *firstPtr, int reverse); ! static void RunStart(Callback **firstPtrPtr, Ns_Thread *threadPtr); ! static void *RegisterAt(Callback **firstPtrPtr, Ns_Callback *proc, void *arg); ! static void RunWait(Callback **firstPtrPtr, Ns_Thread *threadPtr, Ns_Time *toPtr); /* *************** *** 75,79 **** static Ns_Mutex lock; static Ns_Cond cond; ! static int shutdownPending; static Ns_Thread serverShutdownThread; --- 76,80 ---- static Ns_Mutex lock; static Ns_Cond cond; ! static int shutdownPending; static Ns_Thread serverShutdownThread; *************** *** 96,106 **** * Ns_RegisterAtStartup -- * ! * Register a callback to run at server startup * * Results: ! * None * * Side effects: ! * The callback will be registered * *---------------------------------------------------------------------- --- 97,107 ---- * Ns_RegisterAtStartup -- * ! * Register a callback to run at server startup * * Results: ! * None * * Side effects: ! * The callback will be registered * *---------------------------------------------------------------------- *************** *** 119,129 **** * Ns_RegisterAtPreStartup -- * ! * Register a callback to run at pre-server startup * * Results: ! * None * * Side effects: ! * The callback will be registered * *---------------------------------------------------------------------- --- 120,130 ---- * Ns_RegisterAtPreStartup -- * ! * Register a callback to run at pre-server startup * * Results: ! * None * * Side effects: ! * The callback will be registered * *---------------------------------------------------------------------- *************** *** 142,152 **** * Ns_RegisterAtSignal -- * ! * Register a callback to run when a signal arrives * * Results: ! * None * * Side effects: ! * The callback will be registered * *---------------------------------------------------------------------- --- 143,153 ---- * Ns_RegisterAtSignal -- * ! * Register a callback to run when a signal arrives * * Results: ! * None * * Side effects: ! * The callback will be registered * *---------------------------------------------------------------------- *************** *** 165,177 **** * Ns_RegisterAtServerShutdown -- * ! * Register a callback to run at server shutdown. This is ! * identical to Ns_RegisterShutdown and only exists for ! * historical reasons. * * Results: ! * None. * * Side effects: ! * The callback will be registered * *---------------------------------------------------------------------- --- 166,178 ---- * Ns_RegisterAtServerShutdown -- * ! * Register a callback to run at server shutdown. This is ! * identical to Ns_RegisterShutdown and only exists for ! * historical reasons. * * Results: ! * None. * * Side effects: ! * The callback will be registered * *---------------------------------------------------------------------- *************** *** 196,206 **** * Ns_RegisterAtShutdown -- * ! * Register a callback to run at server shutdown. * * Results: ! * None. * * Side effects: ! * The callback will be registered. * *---------------------------------------------------------------------- --- 197,207 ---- * Ns_RegisterAtShutdown -- * ! * Register a callback to run at server shutdown. * * Results: ! * None. * * Side effects: ! * The callback will be registered. * *---------------------------------------------------------------------- *************** *** 219,223 **** } - /* --- 220,223 ---- *************** *** 226,236 **** * Ns_RegisterAtExit -- * ! * Register a callback to be run at server exit. * * Results: ! * None. * * Side effects: ! * The callback will be registerd. * *---------------------------------------------------------------------- --- 226,236 ---- * Ns_RegisterAtExit -- * ! * Register a callback to be run at server exit. * * Results: ! * None. * * Side effects: ! * The callback will be registered. * *---------------------------------------------------------------------- *************** *** 249,259 **** * NsRunStartupProcs -- * ! * Run any callbacks registered for server startup. * * Results: ! * None. * * Side effects: ! * Callbacks called back. * *---------------------------------------------------------------------- --- 249,259 ---- * NsRunStartupProcs -- * ! * Run any callbacks registered for server startup. * * Results: ! * None. * * Side effects: ! * Callbacks called back. * *---------------------------------------------------------------------- *************** *** 272,282 **** * NsRunPreStartupProcs -- * ! * Run any callbacks registered for pre-server startup. * * Results: ! * None. * * Side effects: ! * Callbacks called back. * *---------------------------------------------------------------------- --- 272,282 ---- * NsRunPreStartupProcs -- * ! * Run any callbacks registered for pre-server startup. * * Results: ! * None. * * Side effects: ! * Callbacks called back. * *---------------------------------------------------------------------- *************** *** 295,305 **** * NsRunSignalProcs -- * ! * Run any callbacks registered for when a signal arrives * * Results: ! * None. * * Side effects: ! * Callbacks called back. * *---------------------------------------------------------------------- --- 295,305 ---- * NsRunSignalProcs -- * ! * Run any callbacks registered for when a signal arrives * * Results: ! * None. * * Side effects: ! * Callbacks called back. * *---------------------------------------------------------------------- *************** *** 318,329 **** * NsRunExitProcs -- * ! * Run any callbacks registered for server startup, then ! * shutdown, then exit. * * Results: ! * None. * * Side effects: ! * Callbacks called back. * *---------------------------------------------------------------------- --- 318,329 ---- * NsRunExitProcs -- * ! * Run any callbacks registered for server startup, then ! * shutdown, then exit. * * Results: ! * None. * * Side effects: ! * Callbacks called back. * *---------------------------------------------------------------------- *************** *** 336,339 **** --- 336,340 ---- shutdownPending = 1; Ns_MutexUnlock(&lock); + RunStart(&firstServerShutdown, &serverShutdownThread); } *************** *** 361,371 **** * RegisterAt -- * ! * A generic function that registers callbacks for any event * * Results: ! * A pointer to the newly-allocated Callback structure * * Side effects: ! * A Callback struct will be alloacated and put in the linked list. * *---------------------------------------------------------------------- --- 362,372 ---- * RegisterAt -- * ! * Generic function that registers callbacks for any event * * Results: ! * Pointer to the newly-allocated Callback structure * * Side effects: ! * Callback struct will be alloacated and put in the linked list. * *---------------------------------------------------------------------- *************** *** 375,379 **** RegisterAt(Callback **firstPtrPtr, Ns_Callback *proc, void *arg) { ! Callback *cbPtr; static int first = 1; --- 376,380 ---- RegisterAt(Callback **firstPtrPtr, Ns_Callback *proc, void *arg) { ! Callback *cbPtr; static int first = 1; *************** *** 387,391 **** } if (shutdownPending) { ! ns_free(cbPtr); cbPtr = NULL; } else if (*firstPtrPtr == NULL) { --- 388,392 ---- } if (shutdownPending) { ! ns_free(cbPtr); cbPtr = NULL; } else if (*firstPtrPtr == NULL) { *************** *** 400,403 **** --- 401,405 ---- } Ns_MutexUnlock(&lock); + return (void *) cbPtr; } *************** *** 409,419 **** * RunCallbacks -- * ! * Run all callbacks in the passed-in linked list. * * Results: ! * None * * Side effects: ! * Callbacks called back. * *---------------------------------------------------------------------- --- 411,421 ---- * RunCallbacks -- * ! * Run all callbacks in the passed-in linked list. * * Results: ! * None * * Side effects: ! * Callbacks called back. * *---------------------------------------------------------------------- *************** *** 444,450 **** Ns_MutexLock(&lock); if (*firstPtrPtr != NULL) { ! Ns_ThreadCreate(RunThread, firstPtrPtr, 0, threadPtr); } else { ! *threadPtr = NULL; } Ns_MutexUnlock(&lock); --- 446,452 ---- Ns_MutexLock(&lock); if (*firstPtrPtr != NULL) { ! Ns_ThreadCreate(RunThread, firstPtrPtr, 0, threadPtr); } else { ! *threadPtr = NULL; } Ns_MutexUnlock(&lock); *************** *** 460,470 **** Ns_MutexLock(&lock); while (status == NS_OK && *firstPtrPtr != NULL) { ! status = Ns_CondTimedWait(&cond, &lock, toPtr); } Ns_MutexUnlock(&lock); if (status != NS_OK) { ! Ns_Log(Warning, "callbacks: timeout waiting for shutdown procs"); } else if (*threadPtr != NULL) { ! Ns_ThreadJoin(threadPtr, NULL); } } --- 462,472 ---- Ns_MutexLock(&lock); while (status == NS_OK && *firstPtrPtr != NULL) { ! status = Ns_CondTimedWait(&cond, &lock, toPtr); } Ns_MutexUnlock(&lock); if (status != NS_OK) { ! Ns_Log(Warning, "callbacks: timeout waiting for shutdown procs"); } else if (*threadPtr != NULL) { ! Ns_ThreadJoin(threadPtr, NULL); } } *************** *** 486,492 **** Ns_MutexLock(&lock); while (*firstPtrPtr != NULL) { ! firstPtr = *firstPtrPtr; ! *firstPtrPtr = firstPtr->nextPtr; ! ns_free(firstPtr); } Ns_CondSignal(&cond); --- 488,494 ---- Ns_MutexLock(&lock); while (*firstPtrPtr != NULL) { ! firstPtr = *firstPtrPtr; ! *firstPtrPtr = firstPtr->nextPtr; ! ns_free(firstPtr); } Ns_CondSignal(&cond); *************** *** 494,498 **** } - static void AppendList(Tcl_DString *dsPtr, char *list, Callback *firstPtr, int reverse) --- 496,499 ---- |