celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ejans...@apache.org
Subject [1/2] celix git commit: [CELIX-256] Fixed deadlock issue in the event publisher when restarting the event admin
Date Tue, 23 Aug 2016 08:11:56 GMT
Repository: celix
Updated Branches:
  refs/heads/feature/event_admin fe8faa5ad -> 1db2379c1


[CELIX-256] Fixed deadlock issue in the event publisher when restarting the event admin


Project: http://git-wip-us.apache.org/repos/asf/celix/repo
Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/3b19906e
Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/3b19906e
Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/3b19906e

Branch: refs/heads/feature/event_admin
Commit: 3b19906ec7641fdbe05ee15f4335407911640031
Parents: fe8faa5
Author: Erik Jansman <ejansman@apache.org>
Authored: Tue Aug 23 09:40:13 2016 +0200
Committer: Erik Jansman <ejansman@apache.org>
Committed: Tue Aug 23 09:40:13 2016 +0200

----------------------------------------------------------------------
 .../private/src/event_admin_activator.c         |  1 +
 .../event_admin/private/src/event_admin_impl.c  |  9 +++--
 .../private/src/event_handler_impl.c            |  1 +
 .../private/src/event_publisher_impl.c          | 35 +++++++++-----------
 4 files changed, 22 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/3b19906e/event_admin/event_admin/private/src/event_admin_activator.c
----------------------------------------------------------------------
diff --git a/event_admin/event_admin/private/src/event_admin_activator.c b/event_admin/event_admin/private/src/event_admin_activator.c
index f951968..82a3102 100644
--- a/event_admin/event_admin/private/src/event_admin_activator.c
+++ b/event_admin/event_admin/private/src/event_admin_activator.c
@@ -114,6 +114,7 @@ celix_status_t bundleActivator_stop(void * userData, bundle_context_pt
context)
     serviceRegistration_unregister(data->registration);
 	serviceTracker_close(data->tracker);
 	eventAdmin_stop(&data->event_admin_service->eventAdmin);
+	printf("event admin stopped\n");
 	return status;
 }
 

http://git-wip-us.apache.org/repos/asf/celix/blob/3b19906e/event_admin/event_admin/private/src/event_admin_impl.c
----------------------------------------------------------------------
diff --git a/event_admin/event_admin/private/src/event_admin_impl.c b/event_admin/event_admin/private/src/event_admin_impl.c
index bc89496..6b91f94 100644
--- a/event_admin/event_admin/private/src/event_admin_impl.c
+++ b/event_admin/event_admin/private/src/event_admin_impl.c
@@ -70,9 +70,12 @@ celix_status_t eventAdmin_stop(event_admin_pt *event_admin)
 
 celix_status_t eventAdmin_destroy(event_admin_pt *event_admin) {
 	celix_status_t status = CELIX_SUCCESS;
+    status = celixThread_join((*event_admin)->eventListProcessor, NULL);
+
     arrayList_destroy((*event_admin)->event_handlers);
 	free(*event_admin);
-	return status;
+
+    return status;
 }
 
 celix_status_t eventAdmin_getEventHandlersByChannel(bundle_context_pt context, const char
* serviceName, array_list_pt *eventHandlers) {
@@ -269,9 +272,5 @@ celix_status_t eventAdmin_removedService(void * handle, service_reference_pt
ref
     channel_t channel = hashMap_get(event_admin->channels, topic);
     hashMap_remove(channel->eventHandlers, &service);
     status = celixThreadMutex_unlock(event_admin->topicLock);
-	//hashMap_clear(event_admin->)
-	/*event_admin_pt event_admin = (event_admin_pt) handle;
-	logHelper_log(*event_admin->loghelper, OSGI_LOGSERVICE_ERROR, "Event admin Removed %p",
service);
-	printf("Event admin Removed %p", service);*/
 	return status;
 }

http://git-wip-us.apache.org/repos/asf/celix/blob/3b19906e/event_admin/event_handler/private/src/event_handler_impl.c
----------------------------------------------------------------------
diff --git a/event_admin/event_handler/private/src/event_handler_impl.c b/event_admin/event_handler/private/src/event_handler_impl.c
index 76f2367..29b61df 100644
--- a/event_admin/event_handler/private/src/event_handler_impl.c
+++ b/event_admin/event_handler/private/src/event_handler_impl.c
@@ -57,6 +57,7 @@ celix_status_t eventHandlerDestroy(event_handler_pt *event_handler)
     logHelper_stop((*event_handler)->loghelper);
     logHelper_destroy(&(*event_handler)->loghelper);
     free(*event_handler);
+    printf("event handler clean\n");
     return status;
 }
 

http://git-wip-us.apache.org/repos/asf/celix/blob/3b19906e/event_admin/event_publisher/private/src/event_publisher_impl.c
----------------------------------------------------------------------
diff --git a/event_admin/event_publisher/private/src/event_publisher_impl.c b/event_admin/event_publisher/private/src/event_publisher_impl.c
index 356a0ea..53c5f7a 100644
--- a/event_admin/event_publisher/private/src/event_publisher_impl.c
+++ b/event_admin/event_publisher/private/src/event_publisher_impl.c
@@ -76,18 +76,19 @@ celix_status_t eventPublisherDestroy(event_publisher_pt *event_publisher)
 void *produceEvents(void *handle) {
     event_publisher_pt *event_publisher = handle;
     while ((*event_publisher)->running ) {
-
-        if((*event_publisher)->eventAdminAdded && celixThreadMutex_tryLock((*event_publisher)->eventAdminAvailility)
== 0) {
-            event_admin_service_pt *event_admin_service = &(*event_publisher)->event_admin_service;
-            event_admin_pt event_admin = (*event_admin_service)->eventAdmin;
-            if (event_admin_service != NULL) {
-                event_pt event;
-                properties_pt props = properties_create();
-                properties_set(props, "Error ", "No Error, Just testing ");
-
-                (*event_admin_service)->createEvent(event_admin, "log/error/eventpublishers/event",
props, &event);
-                (*event_admin_service)->postEvent(event_admin, event);
-                (*event_admin_service)->sendEvent(event_admin, event);
+        if (celixThreadMutex_tryLock((*event_publisher)->eventAdminAvailility) == 0) {
+            if ((*event_publisher)->eventAdminAdded) {
+                event_admin_service_pt *event_admin_service = &(*event_publisher)->event_admin_service;
+                event_admin_pt event_admin = (*event_admin_service)->eventAdmin;
+                if (event_admin_service != NULL) {
+                    event_pt event;
+                    properties_pt props = properties_create();
+                    properties_set(props, "Error ", "No Error, Just testing ");
+
+                    (*event_admin_service)->createEvent(event_admin, "log/error/eventpublishers/event",
props, &event);
+                    (*event_admin_service)->postEvent(event_admin, event);
+                    (*event_admin_service)->sendEvent(event_admin, event);
+                }
             }
             celixThreadMutex_unlock((*event_publisher)->eventAdminAvailility);
         }
@@ -108,34 +109,30 @@ celix_status_t eventPublisherAddingService(void * handle, service_reference_pt
r
 celix_status_t eventPublisherAddedService(void * handle, service_reference_pt ref, void *
service) {
     celix_status_t status = CELIX_SUCCESS;
     event_publisher_pt data = (event_publisher_pt) handle;
-	logHelper_log(data->loghelper, OSGI_LOGSERVICE_DEBUG, "[PUB] Event admin added.");
     do {
         status = celixThreadMutex_tryLock(data->eventAdminAvailility);
     } while (status != 0);
     data->event_admin_service = (event_admin_service_pt) service;
     data->eventAdminAdded = true;
     celixThreadMutex_unlock(data->eventAdminAvailility);
-
 	return CELIX_SUCCESS;
 }
 
 celix_status_t eventPublisherModifiedService(void * handle, service_reference_pt ref, void
* service) {
-	event_publisher_pt data = (event_publisher_pt) handle;
-	logHelper_log(data->loghelper, OSGI_LOGSERVICE_DEBUG, "[PUB] Event admin modified.");
 	return CELIX_SUCCESS;
 }
 
 celix_status_t eventPublisherRemovedService(void * handle, service_reference_pt ref, void
* service) {
     celix_status_t status = CELIX_SUCCESS;
 	event_publisher_pt data = (event_publisher_pt) handle;
-	logHelper_log(data->loghelper, OSGI_LOGSERVICE_DEBUG, "[PUB] Event admin removed.");
     do {
         status = celixThreadMutex_tryLock(data->eventAdminAvailility);
     } while (status != 0);
-    data->event_admin_service = NULL;
+
     data->eventAdminAdded = false;
     celixThreadMutex_unlock(data->eventAdminAvailility);
-	return CELIX_SUCCESS;
+
+    return CELIX_SUCCESS;
 }
 
 


Mime
View raw message