[Opensrf-commits] r1207 - trunk/src/gateway

svn at svn.open-ils.org svn at svn.open-ils.org
Sun Jan 6 21:24:39 EST 2008


Author: miker
Date: 2008-01-06 21:00:25 -0500 (Sun, 06 Jan 2008)
New Revision: 1207

Modified:
   trunk/src/gateway/osrf_json_gateway.c
Log:
Memory leak fixes for the old-style gateway:

1. osrf_locale, allocated by either buffer_release() or strdup().

2. A series of buffers allocated by apacheGetFirstParamValue():

   param_locale
   service
   method
   format
   input_format
   a_l
   tout



Modified: trunk/src/gateway/osrf_json_gateway.c
===================================================================
--- trunk/src/gateway/osrf_json_gateway.c	2008-01-07 01:57:18 UTC (rev 1206)
+++ trunk/src/gateway/osrf_json_gateway.c	2008-01-07 02:00:25 UTC (rev 1207)
@@ -172,9 +172,9 @@
 	mparams			= apacheGetParamValues( params, "param" ); /* free me */
 
 	if(format == NULL)
-		format = "json";
+		format = strdup( "json" );
 	if(input_format == NULL)
-		input_format = format;
+		input_format = strdup( format );
 
 	/* set the user defined timeout value */
 	int timeout = 60;
@@ -182,10 +182,13 @@
 	if( tout ) {
 		timeout = atoi(tout);
 		osrfLogDebug(OSRF_LOG_MARK, "Client supplied timeout of %d", timeout);
+		free( tout );
 	}
 
-	if (a_l)
+	if (a_l) {
 		api_level = atoi(a_l);
+		free( a_l );
+	}
 
 	if (!strcasecmp(format, "xml")) {
 		isXML = 1;
@@ -194,6 +197,7 @@
 		ap_set_content_type(r, "text/plain");
 	}
 
+	free( format );
 	int ret = OK;
 
 	/* ----------------------------------------------------------------- */
@@ -285,7 +289,7 @@
 
 
 		if( req_id == -1 ) {
-			osrfLogError(OSRF_LOG_MARK, "I am unable to communcate with opensrf..going away...");
+			osrfLogError(OSRF_LOG_MARK, "I am unable to communicate with opensrf..going away...");
 			/* we don't want to spawn an intense re-forking storm 
 			 * if there is no jabber server.. so give it some time before we die */
 			usleep( 100000 ); /* 100 milliseconds */
@@ -417,6 +421,10 @@
 	osrfLogInfo(OSRF_LOG_MARK, "Completed processing service=%s, method=%s", service, method);
 	string_array_destroy(params);
 	string_array_destroy(mparams);
+	free( osrf_locale );
+	free( input_format );
+	free( method );
+	free( service );
 
 	osrfLogDebug(OSRF_LOG_MARK, "Gateway served %d requests", ++numserved);
 	osrfLogClearXid();



More information about the opensrf-commits mailing list