You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@celix.apache.org by ab...@apache.org on 2014/08/13 14:54:24 UTC

svn commit: r1617718 - in /celix/trunk: framework/private/src/ remote_services/discovery_configured/private/include/ remote_services/discovery_configured/private/src/

Author: abroekhuis
Date: Wed Aug 13 12:54:24 2014
New Revision: 1617718

URL: http://svn.apache.org/r1617718
Log:
CELIX-136: Applied patch

Modified:
    celix/trunk/framework/private/src/service_registry.c
    celix/trunk/remote_services/discovery_configured/private/include/endpoint_discovery_poller.h
    celix/trunk/remote_services/discovery_configured/private/include/endpoint_discovery_server.h
    celix/trunk/remote_services/discovery_configured/private/src/discovery.c
    celix/trunk/remote_services/discovery_configured/private/src/discovery_activator.c
    celix/trunk/remote_services/discovery_configured/private/src/endpoint_discovery_poller.c
    celix/trunk/remote_services/discovery_configured/private/src/endpoint_discovery_server.c

Modified: celix/trunk/framework/private/src/service_registry.c
URL: http://svn.apache.org/viewvc/celix/trunk/framework/private/src/service_registry.c?rev=1617718&r1=1617717&r2=1617718&view=diff
==============================================================================
--- celix/trunk/framework/private/src/service_registry.c (original)
+++ celix/trunk/framework/private/src/service_registry.c Wed Aug 13 12:54:24 2014
@@ -254,7 +254,9 @@ celix_status_t serviceRegistry_unregiste
 		}
 		arrayList_destroy(clients);
 
-		// Disabled for now, since a reference can already be destroyed here.
+		// Disabled since a reference normally already is destroyed here.
+		// Compared to Java OSGi, this might result in crashes, since the references for the service are all destroyed
+		// Anyone still holding a pointer to such a reference is in risk, hence, always use a service tracker or similar!
 //		serviceReference_invalidate(reference);
 	}
 	serviceRegistration_invalidate(registration);

Modified: celix/trunk/remote_services/discovery_configured/private/include/endpoint_discovery_poller.h
URL: http://svn.apache.org/viewvc/celix/trunk/remote_services/discovery_configured/private/include/endpoint_discovery_poller.h?rev=1617718&r1=1617717&r2=1617718&view=diff
==============================================================================
--- celix/trunk/remote_services/discovery_configured/private/include/endpoint_discovery_poller.h (original)
+++ celix/trunk/remote_services/discovery_configured/private/include/endpoint_discovery_poller.h Wed Aug 13 12:54:24 2014
@@ -33,7 +33,7 @@
 typedef struct endpoint_discovery_poller *endpoint_discovery_poller_pt;
 
 celix_status_t endpointDiscoveryPoller_create(discovery_pt discovery, bundle_context_pt context, endpoint_discovery_poller_pt *poller);
-celix_status_t endpointDiscoveryPoller_destroy(endpoint_discovery_poller_pt *poller);
+celix_status_t endpointDiscoveryPoller_destroy(endpoint_discovery_poller_pt poller);
 
 celix_status_t endpointDiscoveryPoller_addDiscoveryEndpoint(endpoint_discovery_poller_pt poller, char *url);
 celix_status_t endpointDiscoveryPoller_removeDiscoveryEndpoint(endpoint_discovery_poller_pt poller, char *url);

Modified: celix/trunk/remote_services/discovery_configured/private/include/endpoint_discovery_server.h
URL: http://svn.apache.org/viewvc/celix/trunk/remote_services/discovery_configured/private/include/endpoint_discovery_server.h?rev=1617718&r1=1617717&r2=1617718&view=diff
==============================================================================
--- celix/trunk/remote_services/discovery_configured/private/include/endpoint_discovery_server.h (original)
+++ celix/trunk/remote_services/discovery_configured/private/include/endpoint_discovery_server.h Wed Aug 13 12:54:24 2014
@@ -45,10 +45,10 @@ celix_status_t endpointDiscoveryServer_c
 /**
  * Stops and destroys a given instance of an endpoint discovery server.
  *
- * @param server [out] the pointer to the instance to destroy.
+ * @param server [in] the pointer to the instance to destroy.
  * @return CELIX_SUCCESS when successful.
  */
-celix_status_t endpointDiscoveryServer_destroy(endpoint_discovery_server_pt *server);
+celix_status_t endpointDiscoveryServer_destroy(endpoint_discovery_server_pt server);
 
 /**
  * Adds a given endpoint description to expose through the given discovery server.

Modified: celix/trunk/remote_services/discovery_configured/private/src/discovery.c
URL: http://svn.apache.org/viewvc/celix/trunk/remote_services/discovery_configured/private/src/discovery.c?rev=1617718&r1=1617717&r2=1617718&view=diff
==============================================================================
--- celix/trunk/remote_services/discovery_configured/private/src/discovery.c (original)
+++ celix/trunk/remote_services/discovery_configured/private/src/discovery.c Wed Aug 13 12:54:24 2014
@@ -100,12 +100,12 @@ celix_status_t discovery_start(discovery
 celix_status_t discovery_stop(discovery_pt discovery) {
 	celix_status_t status;
 
-	status = endpointDiscoveryServer_destroy(&discovery->server);
+	status = endpointDiscoveryServer_destroy(discovery->server);
 	if (status != CELIX_SUCCESS) {
 		return CELIX_BUNDLE_EXCEPTION;
 	}
 
-	status = endpointDiscoveryPoller_destroy(&discovery->poller);
+	status = endpointDiscoveryPoller_destroy(discovery->poller);
 	if (status != CELIX_SUCCESS) {
 		return CELIX_BUNDLE_EXCEPTION;
 	}

Modified: celix/trunk/remote_services/discovery_configured/private/src/discovery_activator.c
URL: http://svn.apache.org/viewvc/celix/trunk/remote_services/discovery_configured/private/src/discovery_activator.c?rev=1617718&r1=1617717&r2=1617718&view=diff
==============================================================================
--- celix/trunk/remote_services/discovery_configured/private/src/discovery_activator.c (original)
+++ celix/trunk/remote_services/discovery_configured/private/src/discovery_activator.c Wed Aug 13 12:54:24 2014
@@ -129,6 +129,9 @@ celix_status_t bundleActivator_start(voi
 		status = discovery_start(activator->discovery);
 	}
 
+	// We can release the scope, as properties_set makes a copy of the key & value...
+	free(scope);
+
 	return status;
 }
 
@@ -160,5 +163,7 @@ celix_status_t bundleActivator_destroy(v
 	activator->discovery = NULL;
 	activator->context = NULL;
 
+	free(activator);
+
 	return status;
 }

Modified: celix/trunk/remote_services/discovery_configured/private/src/endpoint_discovery_poller.c
URL: http://svn.apache.org/viewvc/celix/trunk/remote_services/discovery_configured/private/src/endpoint_discovery_poller.c?rev=1617718&r1=1617717&r2=1617718&view=diff
==============================================================================
--- celix/trunk/remote_services/discovery_configured/private/src/endpoint_discovery_poller.c (original)
+++ celix/trunk/remote_services/discovery_configured/private/src/endpoint_discovery_poller.c Wed Aug 13 12:54:24 2014
@@ -124,23 +124,23 @@ celix_status_t endpointDiscoveryPoller_c
 /**
  * Destroys and frees up memory for a given endpoint_discovery_poller struct.
  */
-celix_status_t endpointDiscoveryPoller_destroy(endpoint_discovery_poller_pt *poller) {
+celix_status_t endpointDiscoveryPoller_destroy(endpoint_discovery_poller_pt poller) {
     celix_status_t status = CELIX_SUCCESS;
 
-    (*poller)->running = false;
+    poller->running = false;
 
-    celixThread_join((*poller)->pollerThread, NULL);
+    celixThread_join(poller->pollerThread, NULL);
 
-    status = celixThreadMutex_lock(&(*poller)->pollerLock);
+    status = celixThreadMutex_lock(&poller->pollerLock);
     if (status != CELIX_SUCCESS) {
         return CELIX_BUNDLE_EXCEPTION;
     }
 
-	hashMap_destroy((*poller)->entries, true, false);
+	hashMap_destroy(poller->entries, true, false);
 
-    status = celixThreadMutex_unlock(&(*poller)->pollerLock);
+    status = celixThreadMutex_unlock(&poller->pollerLock);
 
-    free(*poller);
+    free(poller);
 
 	return status;
 }

Modified: celix/trunk/remote_services/discovery_configured/private/src/endpoint_discovery_server.c
URL: http://svn.apache.org/viewvc/celix/trunk/remote_services/discovery_configured/private/src/endpoint_discovery_server.c?rev=1617718&r1=1617717&r2=1617718&view=diff
==============================================================================
--- celix/trunk/remote_services/discovery_configured/private/src/endpoint_discovery_server.c (original)
+++ celix/trunk/remote_services/discovery_configured/private/src/endpoint_discovery_server.c Wed Aug 13 12:54:24 2014
@@ -111,22 +111,22 @@ celix_status_t endpointDiscoveryServer_c
 	return status;
 }
 
-celix_status_t endpointDiscoveryServer_destroy(endpoint_discovery_server_pt *server) {
+celix_status_t endpointDiscoveryServer_destroy(endpoint_discovery_server_pt server) {
 	celix_status_t status = CELIX_SUCCESS;
 
 	// stop & block until the actual server is shut down...
-	mg_stop((*server)->ctx);
-	(*server)->ctx = NULL;
+	mg_stop(server->ctx);
+	server->ctx = NULL;
 
-	status = celixThreadMutex_lock(&(*server)->serverLock);
+	status = celixThreadMutex_lock(&server->serverLock);
 
-	hashMap_destroy((*server)->entries, true /* freeKeys */, false /* freeValues */);
+	hashMap_destroy(server->entries, true /* freeKeys */, false /* freeValues */);
 
-	status = celixThreadMutex_unlock(&(*server)->serverLock);
-	status = celixThreadMutex_destroy(&(*server)->serverLock);
+	status = celixThreadMutex_unlock(&server->serverLock);
+	status = celixThreadMutex_destroy(&server->serverLock);
 
-	free((void*) (*server)->path);
-	free(*server);
+	free((void*) server->path);
+	free(server);
 
 	return status;
 }