added some cleanup code on child exit to ensure friendly shutdown of sockets
authorerickson <erickson@9efc2488-bf62-4759-914b-345cdb29e865>
Tue, 24 Jun 2008 20:47:49 +0000 (20:47 +0000)
committererickson <erickson@9efc2488-bf62-4759-914b-345cdb29e865>
Tue, 24 Jun 2008 20:47:49 +0000 (20:47 +0000)
git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@1347 9efc2488-bf62-4759-914b-345cdb29e865

src/gateway/osrf_json_gateway.c

index 5e21e95..2921c6b 100644 (file)
@@ -85,6 +85,11 @@ static void* osrf_json_gateway_create_dir_config( apr_pool_t* p, char* dir) {
        return (void*) cfg;
 }
 
+static apr_status_t child_exit(void* data) {
+    osrfLogInfo(OSRF_LOG_MARK, "Disconnecting on child cleanup...");
+    osrf_system_shutdown();
+    return OK;
+}
 
 static void osrf_json_gateway_child_init(apr_pool_t *p, server_rec *s) {
 
@@ -109,6 +114,10 @@ static void osrf_json_gateway_child_init(apr_pool_t *p, server_rec *s) {
                ap_log_error( APLOG_MARK, APLOG_DEBUG, 0, s, 
                        "allowed service: %s\n", osrfStringArrayGetString(allowedServices, i));
        }
+
+    // when this pool is cleaned up, it means the child 
+    // process is going away.  register some cleanup code
+    apr_pool_cleanup_register(p, NULL, child_exit, NULL);
 }
 
 static int osrf_json_gateway_method_handler (request_rec *r) {