Fixed a bug in osrfRouterClassFree(). We were trying free
authorscottmk <scottmk@9efc2488-bf62-4759-914b-345cdb29e865>
Sat, 31 Oct 2009 16:49:15 +0000 (16:49 +0000)
committerscottmk <scottmk@9efc2488-bf62-4759-914b-345cdb29e865>
Sat, 31 Oct 2009 16:49:15 +0000 (16:49 +0000)
the same osrfRouterClass twice -- once directly, and once
by an unintended recursion.

M    src/router/osrf_router.c
M    src/router/osrf_router_main.c

git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@1835 9efc2488-bf62-4759-914b-345cdb29e865

src/router/osrf_router.c
src/router/osrf_router_main.c

index 87b4709..ace136d 100644 (file)
@@ -9,7 +9,7 @@
        @brief Maintains a set of server nodes belonging to the same class.
 */
 struct _osrfRouterClassStruct {
-       osrfRouter* router;         /**< The osrfRouter that owns this osrfRouterClass */
+       osrfRouter* router;         /**< The osrfRouter that owns this osrfRouterClass. */
        osrfHashIterator* itr;      /**< Iterator for set of osrfRouterNodes. */
        /**
                @brief Hash store of server nodes.
@@ -552,7 +552,7 @@ static void osrfRouterClassFree( char* classname, void* c ) {
        osrfRouterNode* node;
 
        while( (node = osrfHashIteratorNext(rclass->itr)) )
-               osrfRouterClassRemoveNode( rclass->router, classname, node->remoteId );
+               osrfHashRemove( rclass->nodes, node->remoteId );
 
        osrfHashIteratorFree(rclass->itr);
        osrfHashFree(rclass->nodes);
index 3e07669..0111e8b 100644 (file)
 static osrfRouter* router = NULL;
 
 /**
-       @brief Respond to signal by exiting immediately.
+       @brief Respond to signal by cleaning up and exiting immediately.
        @param signo The signal number.
 */
 void routerSignalHandler( int signo ) {
        osrfLogWarning( OSRF_LOG_MARK, "Received signal [%d], cleaning up...", signo );
 
-    /* for now, just forcibly exit.  This is not a friendly way to clean up, but
-     * there is a bug in osrfRouterFree() (in particular with cleaning up sockets),
-     * that can cause the router process to stick around.  If we do this, we
-     * are guaranteed to exit.
-     */
-    _exit(0);
-
        osrfConfigCleanup();
        osrfRouterFree(router);
+       osrfLogWarning( OSRF_LOG_MARK, "Cleanup successful.  Re-raising signal" );
        router = NULL;
 
-       // Exit by re-raising the signal so that the parent
-       // process can detect it
+       // Re-raise the signal so that the parent process can detect it.
        
        signal( signo, SIG_DFL );
        raise( signo );