From c471145f680443a83e721bd6fbe79a178b090d4c Mon Sep 17 00:00:00 2001 From: scottmk Date: Sat, 31 Oct 2009 16:49:15 +0000 Subject: [PATCH 1/1] Fixed a bug in osrfRouterClassFree(). We were trying free 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 | 4 ++-- src/router/osrf_router_main.c | 13 +++---------- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/src/router/osrf_router.c b/src/router/osrf_router.c index 87b4709..ace136d 100644 --- a/src/router/osrf_router.c +++ b/src/router/osrf_router.c @@ -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); diff --git a/src/router/osrf_router_main.c b/src/router/osrf_router_main.c index 3e07669..0111e8b 100644 --- a/src/router/osrf_router_main.c +++ b/src/router/osrf_router_main.c @@ -29,25 +29,18 @@ 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 ); -- 2.43.2