celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bpe...@apache.org
Subject svn commit: r1643070 - in /celix/trunk/remote_services: discovery/private/src/endpoint_discovery_server.c remote_service_admin_http/private/src/remote_service_admin_impl.c
Date Mon, 15 Dec 2014 17:12:18 GMT
Author: bpetri
Date: Wed Dec  3 08:45:36 2014
New Revision: 1643070

URL: http://svn.apache.org/r1643070
Log:
CELIX-190: fixed memory leak in port handling

Modified:
    celix/trunk/remote_services/discovery/private/src/endpoint_discovery_server.c
    celix/trunk/remote_services/remote_service_admin_http/private/src/remote_service_admin_impl.c

Modified: celix/trunk/remote_services/discovery/private/src/endpoint_discovery_server.c
URL: http://svn.apache.org/viewvc/celix/trunk/remote_services/discovery/private/src/endpoint_discovery_server.c?rev=1643070&r1=1643069&r2=1643070&view=diff
==============================================================================
--- celix/trunk/remote_services/discovery/private/src/endpoint_discovery_server.c (original)
+++ celix/trunk/remote_services/discovery/private/src/endpoint_discovery_server.c Wed Dec
 3 08:45:36 2014
@@ -143,6 +143,7 @@ celix_status_t endpointDiscoveryServer_c
 	unsigned int port_counter = 0;
 
 	do {
+		char newPort[10];
 		const char *options[] = {
 			"listening_ports", port,
 			"num_threads", DEFAULT_SERVER_THREADS,
@@ -157,7 +158,6 @@ celix_status_t endpointDiscoveryServer_c
 		}
 		else {
 			errno = 0;
-			char newPort[10];
 	        char* endptr = port;
 	        int currentPort = strtol(port, &endptr, 10);
 

Modified: celix/trunk/remote_services/remote_service_admin_http/private/src/remote_service_admin_impl.c
URL: http://svn.apache.org/viewvc/celix/trunk/remote_services/remote_service_admin_http/private/src/remote_service_admin_impl.c?rev=1643070&r1=1643069&r2=1643070&view=diff
==============================================================================
--- celix/trunk/remote_services/remote_service_admin_http/private/src/remote_service_admin_impl.c
(original)
+++ celix/trunk/remote_services/remote_service_admin_http/private/src/remote_service_admin_impl.c
Wed Dec  3 08:45:36 2014
@@ -156,31 +156,34 @@ celix_status_t remoteServiceAdmin_create
 		callbacks.begin_request = remoteServiceAdmin_callback;
 
 		do {
+			char newPort[10];
 			const char *options[] = { "listening_ports", port, NULL};
 
 			(*admin)->ctx = mg_start(&callbacks, (*admin), options);
 
 			if ((*admin)->ctx != NULL) {
 				logHelper_log((*admin)->loghelper, OSGI_LOGSERVICE_INFO, "RSA: Start webserver: %s",
port);
-				(*admin)->port = port;
+				(*admin)->port = apr_pstrdup(pool, port);
+
 			}
 			else {
-				errno = 0;
-				char* newPort = calloc(10, sizeof(*newPort));
 		        char* endptr = port;
 		        int currentPort = strtol(port, &endptr, 10);
 
+				errno = 0;
+
 		        if (*endptr || errno != 0) {
 		            currentPort = strtol(DEFAULT_PORT, NULL, 10);
 		        }
 
 		        port_counter++;
-				snprintf(newPort, 6,  "%d", (currentPort+1));
+				snprintf(&newPort[0], 6,  "%d", (currentPort+1));
 
 				logHelper_log((*admin)->loghelper, OSGI_LOGSERVICE_ERROR, "Error while starting rsa
server on port %s - retrying on port %s...", port, newPort);
 				port = newPort;
 			}
 		} while(((*admin)->ctx == NULL) && (port_counter < MAX_NUMBER_OF_RESTARTS));
+
 	}
 	return status;
 }



Mime
View raw message