From: erickson Date: Fri, 7 Apr 2006 13:22:47 +0000 (+0000) Subject: added some additional logging and some cleanup functions for improving X-Git-Tag: osrf_rel_2_0_1~1190 X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=ac0de664f9c367010f5bfa600131e4ec3c1c1f2d;p=OpenSRF.git added some additional logging and some cleanup functions for improving memory leak detection git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@683 9efc2488-bf62-4759-914b-345cdb29e865 --- diff --git a/src/gateway/osrf_json_gateway.c b/src/gateway/osrf_json_gateway.c index a6a4631..59c2f4f 100644 --- a/src/gateway/osrf_json_gateway.c +++ b/src/gateway/osrf_json_gateway.c @@ -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, "\"%s : %s\"", 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); diff --git a/src/libstack/osrfConfig.c b/src/libstack/osrfConfig.c index d25f631..a172a2b 100644 --- a/src/libstack/osrfConfig.c +++ b/src/libstack/osrfConfig.c @@ -116,6 +116,7 @@ int osrfConfigGetValueList(osrfConfig* cfg, osrfStringArray* arr, char* path, .. } } + jsonObjectFree(obj); return count; } diff --git a/src/libstack/osrf_app_session.c b/src/libstack/osrf_app_session.c index d1ee5cb..c02b8b8 100644 --- a/src/libstack/osrf_app_session.c +++ b/src/libstack/osrf_app_session.c @@ -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; diff --git a/src/libstack/osrf_app_session.h b/src/libstack/osrf_app_session.h index 9efc8f9..9e357b6 100644 --- a/src/libstack/osrf_app_session.h +++ b/src/libstack/osrf_app_session.h @@ -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 diff --git a/src/libstack/osrf_system.c b/src/libstack/osrf_system.c index 1f9f06a..0a3b6f8 100644 --- a/src/libstack/osrf_system.c +++ b/src/libstack/osrf_system.c @@ -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; } diff --git a/src/objson/object.c b/src/objson/object.c index fa50b6f..4f3658d 100644 --- a/src/objson/object.c +++ b/src/objson/object.c @@ -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); diff --git a/src/utils/log.c b/src/utils/log.c index 755b8d0..8f3c2fc 100644 --- a/src/utils/log.c +++ b/src/utils/log.c @@ -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); diff --git a/src/utils/log.h b/src/utils/log.h index 61f59f3..8764443 100644 --- a/src/utils/log.h +++ b/src/utils/log.h @@ -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 );