From: erickson Date: Thu, 3 Aug 2006 19:58:11 +0000 (+0000) Subject: when a backend child is not able to connect to jabber, the child now goes away X-Git-Tag: osrf_rel_2_0_1~1122 X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=3e410d100312b208f79915bcdfaf123b8670b809;p=OpenSRF.git when a backend child is not able to connect to jabber, the child now goes away so it's not sitting around polluting the server pool git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@753 9efc2488-bf62-4759-914b-345cdb29e865 --- diff --git a/src/libstack/osrf_prefork.c b/src/libstack/osrf_prefork.c index 1246236..5778e54 100644 --- a/src/libstack/osrf_prefork.c +++ b/src/libstack/osrf_prefork.c @@ -120,9 +120,9 @@ void osrf_prefork_register_routers( char* appname ) { osrfStringArrayFree(arr); } -void prefork_child_init_hook(prefork_child* child) { +int prefork_child_init_hook(prefork_child* child) { - if(!child) return; + if(!child) return -1; osrfLogDebug( OSRF_LOG_MARK, "Child init hook for child %d", child->pid); char* resc = va_list_to_string("%s_drone",child->appname); @@ -133,7 +133,7 @@ void prefork_child_init_hook(prefork_child* child) { if(!osrf_system_bootstrap_client_resc( NULL, NULL, resc)) { osrfLogError( OSRF_LOG_MARK, "Unable to bootstrap client for osrf_prefork_run()"); free(resc); - return; + return -1; } free(resc); @@ -142,9 +142,11 @@ void prefork_child_init_hook(prefork_child* child) { osrfLogDebug(OSRF_LOG_MARK, "Prefork child_init succeeded\n"); } else { osrfLogError(OSRF_LOG_MARK, "Prefork child_init failed\n"); + return -1; } set_proc_title( "OpenSRF Drone [%s]", child->appname ); + return 0; } void prefork_child_process_request(prefork_child* child, char* data) { @@ -287,7 +289,11 @@ prefork_child* launch_child( prefork_simple* forker ) { close( child->read_status_fd ); /* do the initing */ - prefork_child_init_hook(child); + if( prefork_child_init_hook(child) == -1 ) { + osrfLogError(OSRF_LOG_MARK, + "Forker child going away because we could not connect to OpenSRF..."); + exit(1); + } prefork_child_wait( child ); exit(0); /* just to be sure */ diff --git a/src/libstack/osrf_prefork.h b/src/libstack/osrf_prefork.h index 0e14259..d191105 100644 --- a/src/libstack/osrf_prefork.h +++ b/src/libstack/osrf_prefork.h @@ -77,7 +77,7 @@ void del_prefork_child( prefork_simple* forker, pid_t pid ); void check_children( prefork_simple* forker ); void prefork_child_process_request(prefork_child*, char* data); -void prefork_child_init_hook(prefork_child*); +int prefork_child_init_hook(prefork_child*); prefork_child* prefork_child_init( int max_requests, int read_data_fd, int write_data_fd,