You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@celix.apache.org by bp...@apache.org on 2014/12/07 16:39:44 UTC

svn commit: r1643685 - in /celix/trunk/remote_services/discovery/private/src: discovery.c endpoint_discovery_poller.c

Author: bpetri
Date: Sun Dec  7 15:39:44 2014
New Revision: 1643685

URL: http://svn.apache.org/r1643685
Log:
CELIX-190: fixed memory leak in endpoint description poller

Modified:
    celix/trunk/remote_services/discovery/private/src/discovery.c
    celix/trunk/remote_services/discovery/private/src/endpoint_discovery_poller.c

Modified: celix/trunk/remote_services/discovery/private/src/discovery.c
URL: http://svn.apache.org/viewvc/celix/trunk/remote_services/discovery/private/src/discovery.c?rev=1643685&r1=1643684&r2=1643685&view=diff
==============================================================================
--- celix/trunk/remote_services/discovery/private/src/discovery.c (original)
+++ celix/trunk/remote_services/discovery/private/src/discovery.c Sun Dec  7 15:39:44 2014
@@ -201,7 +201,7 @@ celix_status_t discovery_addDiscoveredEn
 	char* endpointId = endpoint->id;
 	bool exists = hashMap_get(discovery->discoveredServices, endpointId) != NULL;
 	if (!exists) {
-		hashMap_put(discovery->discoveredServices, endpointId, endpoint);
+		hashMap_put(discovery->discoveredServices, strdup(endpointId), endpoint);
 	}
 
 	status = celixThreadMutex_unlock(&discovery->discoveredServicesMutex);

Modified: celix/trunk/remote_services/discovery/private/src/endpoint_discovery_poller.c
URL: http://svn.apache.org/viewvc/celix/trunk/remote_services/discovery/private/src/endpoint_discovery_poller.c?rev=1643685&r1=1643684&r2=1643685&view=diff
==============================================================================
--- celix/trunk/remote_services/discovery/private/src/endpoint_discovery_poller.c (original)
+++ celix/trunk/remote_services/discovery/private/src/endpoint_discovery_poller.c Sun Dec  7 15:39:44 2014
@@ -233,14 +233,14 @@ static void *endpointDiscoveryPoller_pol
 				continue;
 			}
 
-			for (int i = 0; i < arrayList_size(currentEndpoints); i++) {
-				endpoint_description_pt endpoint = arrayList_get(currentEndpoints, i);
+			for (int i = arrayList_size(currentEndpoints); i > 0  ; i--) {
+				endpoint_description_pt endpoint = arrayList_remove(currentEndpoints, 0);
 				if (!arrayList_contains(updatedEndpoints, endpoint)) {
 					status = discovery_removeDiscoveredEndpoint(poller->discovery, endpoint);
 				}
+				endpointDescription_destroy(endpoint);
 			}
 
-			arrayList_clear(currentEndpoints);
 			if (updatedEndpoints) {
 				arrayList_addAll(currentEndpoints, updatedEndpoints);
 				arrayList_destroy(updatedEndpoints);