From d7602d7d6808740658c9d49cee3366242a0ee3ad Mon Sep 17 00:00:00 2001 From: erickson Date: Fri, 7 Apr 2006 16:32:03 +0000 Subject: [PATCH] like the Perl server, you can now no longer re-bootstrap clients in a process that already has a client socket open. you can force it, which the forked children must do to get their own sockets, but in general, a single process will share the same connection git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@685 9efc2488-bf62-4759-914b-345cdb29e865 --- src/libstack/osrf_prefork.c | 4 ++++ src/libstack/osrf_system.c | 9 +++++++++ src/libstack/osrf_system.h | 9 +++++++++ 3 files changed, 22 insertions(+) diff --git a/src/libstack/osrf_prefork.c b/src/libstack/osrf_prefork.c index d2b0168..9678d26 100644 --- a/src/libstack/osrf_prefork.c +++ b/src/libstack/osrf_prefork.c @@ -112,6 +112,10 @@ void prefork_child_init_hook(prefork_child* child) { osrfLogDebug( OSRF_LOG_MARK, "Child init hook for child %d", child->pid); char* resc = va_list_to_string("%s_drone",child->appname); + /* we want to remove traces of our parents socket connection + * so we can have our own */ + osrfSystemIgnoreTransportClient(); + if(!osrf_system_bootstrap_client_resc( NULL, NULL, resc)) { osrfLogError( OSRF_LOG_MARK, "Unable to bootstrap client for osrf_prefork_run()"); free(resc); diff --git a/src/libstack/osrf_system.c b/src/libstack/osrf_system.c index 0a3b6f8..bf6adfe 100644 --- a/src/libstack/osrf_system.c +++ b/src/libstack/osrf_system.c @@ -11,6 +11,10 @@ transport_client* osrfSystemGetTransportClient() { return __osrfGlobalTransportClient; } +void osrfSystemIgnoreTransportClient() { + __osrfGlobalTransportClient = NULL; +} + transport_client* osrf_system_get_transport_client() { return __osrfGlobalTransportClient; } @@ -134,6 +138,11 @@ int osrfSystemBootstrap( char* hostname, char* configfile, char* contextNode ) { int osrf_system_bootstrap_client_resc( char* config_file, char* contextnode, char* resource ) { + if(osrfSystemGetTransportClient()) { + osrfLogInfo(OSRF_LOG_MARK, "Client is already bootstrapped"); + return 1; /* we already have a client connection */ + } + if( !( config_file && contextnode ) && ! osrfConfigHasDefaultConfig() ) { osrfLogError( OSRF_LOG_MARK, "No Config File Specified\n" ); return -1; diff --git a/src/libstack/osrf_system.h b/src/libstack/osrf_system.h index 34c2632..847928c 100644 --- a/src/libstack/osrf_system.h +++ b/src/libstack/osrf_system.h @@ -46,4 +46,13 @@ int osrf_system_shutdown(); int _osrfSystemInitCache(); + +/* this will clear the global transport client pointer without + * actually destroying the socket. this is useful for allowing + * children to have their own socket, even though their parent + * already created a socket + */ +void osrfSystemIgnoreTransportClient(); + + #endif -- 2.11.0