celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ejans...@apache.org
Subject celix git commit: stability updates. Few service references left. need to figure it out.
Date Mon, 22 Aug 2016 11:14:16 GMT
Repository: celix
Updated Branches:
  refs/heads/feature/event_admin a59205735 -> fe8faa5ad


stability updates. Few service references left. need to figure it out.


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

Branch: refs/heads/feature/event_admin
Commit: fe8faa5ad5af3a29c925d67bc2b3ae190f2fc7e4
Parents: a592057
Author: Erik Jansman <ejansman@apache.org>
Authored: Mon Aug 22 13:13:13 2016 +0200
Committer: Erik Jansman <ejansman@apache.org>
Committed: Mon Aug 22 13:13:13 2016 +0200

----------------------------------------------------------------------
 event_admin/CMakeLists.txt                      |  3 +--
 .../event_admin/private/src/event_admin_impl.c  | 25 ++++++++++++++++----
 .../private/src/event_publisher_impl.c          | 14 +++++++----
 3 files changed, 32 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/fe8faa5a/event_admin/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/event_admin/CMakeLists.txt b/event_admin/CMakeLists.txt
index 44d7169..60e1b0f 100644
--- a/event_admin/CMakeLists.txt
+++ b/event_admin/CMakeLists.txt
@@ -34,6 +34,5 @@ if(EVENT_ADMIN)
 	add_deploy(event_publisher_consumer
 			NAME "event_publisher_consumer"
 			GROUP "event_publisher"
-			BUNDLES event_admin event_publisher event_handler shell_tui shell log_writer log_service
)
-            #BUNDLES event_publisher shell_tui shell log_writer log_service )
+			BUNDLES event_publisher event_handler event_admin shell_tui shell log_writer log_service)
 endif(EVENT_ADMIN)

http://git-wip-us.apache.org/repos/asf/celix/blob/fe8faa5a/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 ab50d86..bc89496 100644
--- a/event_admin/event_admin/private/src/event_admin_impl.c
+++ b/event_admin/event_admin/private/src/event_admin_impl.c
@@ -44,6 +44,7 @@ celix_status_t eventAdmin_create(bundle_context_pt context, event_admin_pt
*even
         (*event_admin)->context =context;
         (*event_admin)->eventListLock = calloc(1, sizeof(celix_thread_mutex_t));
         (*event_admin)->eventListProcessor = celix_thread_default;
+        (*event_admin)->topicLock = calloc(1, sizeof(celix_thread_mutex_t));
         (*event_admin)->eventAdminRunning = false;
         linkedList_create(&(*event_admin)->eventList);//
 
@@ -56,6 +57,7 @@ celix_status_t eventAdmin_start(event_admin_pt *event_admin) {
     celix_status_t status = CELIX_SUCCESS;
     status = celixThread_create(&(*event_admin)->eventListProcessor, NULL, eventProcessor,
&(*event_admin));
     celixThreadMutex_create((*event_admin)->eventListLock, NULL);
+    celixThreadMutex_create((*event_admin)->topicLock, NULL);
     (*event_admin)->eventAdminRunning = true;
     return status;
 }
@@ -148,7 +150,6 @@ celix_status_t processEvent(event_admin_pt event_admin, event_pt event)
{
 
     array_list_pt event_handlers;
     arrayList_create(&event_handlers);
-    //eventAdmin_lockHandlersList(event_admin, topic);
     status = eventAdmin_findHandlersByTopic(event_admin, topic, event_handlers);
     if (status == CELIX_SUCCESS) {
         array_list_iterator_pt handlers_iterator = arrayListIterator_create(event_handlers);
@@ -158,11 +159,15 @@ celix_status_t processEvent(event_admin_pt event_admin, event_pt event)
{
             event_handler_service->handle_event(&event_handler_service->event_handler,
event);
         }
     }
-    //eventAdmin_releaseHandersList(event_admin, topic);
     return status;
 }
 celix_status_t eventAdmin_sendEvent(event_admin_pt event_admin, event_pt event) {
-    return processEvent(event_admin, event);
+    celix_status_t status = CELIX_SUCCESS;
+    status = processEvent(event_admin, event);
+    const char *topic;
+    eventAdmin_getTopic(&event, &topic);
+    status = eventAdmin_unlockTopic(event_admin, topic);
+    return status;
 }
 
 celix_status_t eventAdmin_findHandlersByTopic(event_admin_pt event_admin, const char *topic,
@@ -201,6 +206,9 @@ celix_status_t eventAdmin_unlockTopic(event_admin_pt event_admin, const
char *to
 celix_status_t eventAdmin_createEventChannels(event_admin_pt *event_admin, const char *topic,
 											  event_handler_service_pt event_handler_service) {
 	celix_status_t status = CELIX_SUCCESS;
+    do {
+        status = celixThreadMutex_tryLock((*event_admin)->topicLock);
+    } while (status != 0);
     channel_t channel = hashMap_get((*event_admin)->channels, topic);
 	if (channel == NULL) {
 		//create channel
@@ -219,6 +227,7 @@ celix_status_t eventAdmin_createEventChannels(event_admin_pt *event_admin,
const
     if (channel) {
         hashMap_put(channel->eventHandlers, &event_handler_service, event_handler_service);
     }
+    status = celixThreadMutex_unlock((*event_admin)->topicLock);
 
 	return status;
 
@@ -251,7 +260,15 @@ celix_status_t eventAdmin_modifiedService(void * handle, service_reference_pt
re
 
 celix_status_t eventAdmin_removedService(void * handle, service_reference_pt ref, void *
service) {
 	celix_status_t status = CELIX_SUCCESS;
-	//event_admin_pt  event_admin = handle;
+    event_admin_pt event_admin = handle;
+    do {
+        status = celixThreadMutex_tryLock(event_admin->topicLock);
+    } while (status != 0);
+    const char *topic = NULL;
+    serviceReference_getProperty(ref, (const char *) EVENT_TOPIC, &topic);
+    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);

http://git-wip-us.apache.org/repos/asf/celix/blob/fe8faa5a/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 c21aaf1..356a0ea 100644
--- a/event_admin/event_publisher/private/src/event_publisher_impl.c
+++ b/event_admin/event_publisher/private/src/event_publisher_impl.c
@@ -87,7 +87,7 @@ void *produceEvents(void *handle) {
 
                 (*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);
+                (*event_admin_service)->sendEvent(event_admin, event);
             }
             celixThreadMutex_unlock((*event_publisher)->eventAdminAvailility);
         }
@@ -106,13 +106,16 @@ 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.");
-    printf(" added event admin\n");
-    celixThreadMutex_lock(data->eventAdminAvailility);
+    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;
 }
 
@@ -123,9 +126,12 @@ celix_status_t eventPublisherModifiedService(void * handle, service_reference_pt
 }
 
 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.");
-    celixThreadMutex_lock(data->eventAdminAvailility);
+    do {
+        status = celixThreadMutex_tryLock(data->eventAdminAvailility);
+    } while (status != 0);
     data->event_admin_service = NULL;
     data->eventAdminAdded = false;
     celixThreadMutex_unlock(data->eventAdminAvailility);


Mime
View raw message