added some additional logging and some cleanup functions for improving
authorerickson <erickson@9efc2488-bf62-4759-914b-345cdb29e865>
Fri, 7 Apr 2006 13:22:47 +0000 (13:22 +0000)
committererickson <erickson@9efc2488-bf62-4759-914b-345cdb29e865>
Fri, 7 Apr 2006 13:22:47 +0000 (13:22 +0000)
memory leak detection

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

src/gateway/osrf_json_gateway.c
src/libstack/osrfConfig.c
src/libstack/osrf_app_session.c
src/libstack/osrf_app_session.h
src/libstack/osrf_system.c
src/objson/object.c
src/utils/log.c
src/utils/log.h

index a6a4631..59c2f4f 100644 (file)
@@ -20,6 +20,7 @@ module AP_MODULE_DECLARE_DATA osrf_json_gateway_module;
 
 char* osrf_json_gateway_config_file = NULL;
 int bootstrapped = 0;
+int numserved = 0;
 
 static const char* osrf_json_gateway_set_config(cmd_parms *parms, void *config, const char *arg) {
        osrf_json_gateway_config  *cfg;
@@ -68,15 +69,14 @@ static int osrf_json_gateway_method_handler (request_rec *r) {
                return HTTP_INTERNAL_SERVER_ERROR;
        }
 
-
        osrfLogSetAppname("osrf_json_gw");
 
-       char* service                           = NULL; /* service to connect to */
-       char* method                            = NULL; /* method to perform */
-       char* format                            = NULL; /* method to perform */
-       char* a_l                               = NULL; /* request api level */
-       int   isXML                             = 0;
-       int   api_level                         = 1;
+       char* service           = NULL; /* service to connect to */
+       char* method            = NULL; /* method to perform */
+       char* format            = NULL; /* method to perform */
+       char* a_l                       = NULL; /* request api level */
+       int   isXML                     = 0;
+       int   api_level = 1;
 
        r->allowed |= (AP_METHOD_BIT << M_GET);
        r->allowed |= (AP_METHOD_BIT << M_POST);
@@ -166,6 +166,7 @@ static int osrf_json_gateway_method_handler (request_rec *r) {
 
                        if (isXML)
                                snprintf( buf, l, "<debug>\"%s : %s\"</debug>", statusname, statustext );
+
                        else {
                                char bb[l];
                                bzero(bb, l);
@@ -202,6 +203,8 @@ static int osrf_json_gateway_method_handler (request_rec *r) {
                osrf_app_session_destroy(session);
        }
 
+       osrfLogInfo(OSRF_LOG_MARK, "Completed processing service=%s, method=%s", service, method);
+       osrfLogDebug(OSRF_LOG_MARK, "Gateway served %d requests", ++numserved);
        string_array_destroy(params);
        string_array_destroy(mparams);
 
index d25f631..a172a2b 100644 (file)
@@ -116,6 +116,7 @@ int osrfConfigGetValueList(osrfConfig* cfg, osrfStringArray* arr, char* path, ..
                }
        }
 
+       jsonObjectFree(obj);
        return count;
 }
 
index d1ee5cb..c02b8b8 100644 (file)
@@ -27,6 +27,11 @@ osrf_app_request* _osrf_app_request_init(
 
 }
 
+
+void osrfAppSessionCleanup() {
+       osrfHashFree(osrfAppSessionCache);      
+}
+
 /** Frees memory used by an app_request object */
 void _osrf_app_request_free( void * req ){
        if( req == NULL ) return;
index 9efc8f9..9e357b6 100644 (file)
@@ -222,5 +222,7 @@ int osrfAppRequestRespondComplete( osrfAppSession* ses, int requestId, jsonObjec
 
 int osrfAppSessionStatus( osrfAppSession* ses, int type, char* name, int reqId, char* message );
 
+void osrfAppSessionCleanup();
+
 
 #endif
index 1f9f06a..0a3b6f8 100644 (file)
@@ -207,6 +207,7 @@ int osrf_system_bootstrap_client_resc( char* config_file, char* contextnode, cha
        free(password);
        free(port);     
        free(unixpath);
+       free(domain);
 
        if(__osrfGlobalTransportClient)
                return 1;
@@ -225,6 +226,8 @@ int osrf_system_shutdown() {
        osrfConfigCleanup();
        osrf_system_disconnect_client();
        osrf_settings_free_host_config(NULL);
+       osrfAppSessionCleanup();
+       osrfLogCleanup();
        return 1;
 }
 
index fa50b6f..4f3658d 100644 (file)
@@ -710,7 +710,8 @@ jsonObject* _jsonObjectFindPathRecurse(const jsonObject* obj, char* root, char*
                if(thing->type == JSON_ARRAY) {
                int i;
                                        for( i = 0; i != thing->size; i++ )
-                                               jsonObjectPush(newarr, jsonObjectGetIndex(thing,i));
+                                               jsonObjectPush(newarr, jsonObjectClone(jsonObjectGetIndex(thing,i)));
+                                       jsonObjectFree(thing);
 
                                } else {
                                        jsonObjectPush(newarr, thing);
index 755b8d0..8f3c2fc 100644 (file)
@@ -9,6 +9,12 @@ int __osrfLogLevel                             = OSRF_LOG_INFO;
 int __osrfLogActivityEnabled   = 1;
 
 
+void osrfLogCleanup() {
+       free(__osrfLogAppname);
+       free(__osrfLogFile);
+}
+
+
 void osrfLogInit( int type, const char* appname, int maxlevel ) {
        osrfLogSetType(type);
        if(appname) osrfLogSetAppname(appname);
index 61f59f3..8764443 100644 (file)
@@ -57,6 +57,8 @@ void osrfLogInternal( const char* file, int line, const char* msg, ... );
 /* Log an activity message */
 void osrfLogActivity( const char* file, int line, const char* msg, ... );
 
+void osrfLogCleanup();
+
 /* sets the activity flag */
 void osrfLogSetActivityEnabled( int enabled );