You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@celix.apache.org by ej...@apache.org on 2016/08/23 08:11:56 UTC
[1/2] celix git commit: [CELIX-256] Fixed deadlock issue in the event
publisher when restarting the event admin
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 <ej...@apache.org>
Authored: Tue Aug 23 09:40:13 2016 +0200
Committer: Erik Jansman <ej...@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;
}
[2/2] celix git commit: [CELIX-256] refactored code
Posted by ej...@apache.org.
[CELIX-256] refactored code
Project: http://git-wip-us.apache.org/repos/asf/celix/repo
Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/1db2379c
Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/1db2379c
Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/1db2379c
Branch: refs/heads/feature/event_admin
Commit: 1db2379c1f52b10362dffc000d9ee18cb4915ca4
Parents: 3b19906
Author: Erik Jansman <ej...@apache.org>
Authored: Tue Aug 23 09:52:21 2016 +0200
Committer: Erik Jansman <ej...@apache.org>
Committed: Tue Aug 23 09:52:21 2016 +0200
----------------------------------------------------------------------
event_admin/event_admin/CMakeLists.txt | 2 +-
event_admin/event_admin/private/include/event_admin_impl.h | 5 ++---
event_admin/event_admin/private/src/event_admin_impl.c | 7 -------
event_admin/event_admin/public/include/event_admin.h | 2 +-
event_admin/event_admin/public/include/event_handler.h | 3 ++-
.../event_handler/private/src/event_handler_activator.c | 2 +-
event_admin/event_handler/private/src/event_handler_impl.c | 1 -
.../event_publisher/private/src/event_publisher_impl.c | 2 +-
8 files changed, 8 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/celix/blob/1db2379c/event_admin/event_admin/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/event_admin/event_admin/CMakeLists.txt b/event_admin/event_admin/CMakeLists.txt
index 4fe7ccd..b915c76 100644
--- a/event_admin/event_admin/CMakeLists.txt
+++ b/event_admin/event_admin/CMakeLists.txt
@@ -23,7 +23,7 @@ include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
include_directories("${PROJECT_SOURCE_DIR}/log_service/public/include")
add_bundle(event_admin
- VERSION 0.0.0
+ VERSION 0.0.1
SOURCES
private/src/event_admin_activator.c
private/src/event_admin_impl.c
http://git-wip-us.apache.org/repos/asf/celix/blob/1db2379c/event_admin/event_admin/private/include/event_admin_impl.h
----------------------------------------------------------------------
diff --git a/event_admin/event_admin/private/include/event_admin_impl.h b/event_admin/event_admin/private/include/event_admin_impl.h
index 65a5919..dbb969d 100644
--- a/event_admin/event_admin/private/include/event_admin_impl.h
+++ b/event_admin/event_admin/private/include/event_admin_impl.h
@@ -47,7 +47,6 @@ struct event_admin {
hash_map_pt channels;
array_list_pt event_handlers;
bundle_context_pt context;
- log_helper_pt *loghelper;
linked_list_pt eventList;
celix_thread_t eventListProcessor;
celix_thread_mutex_t *eventListLock;
@@ -56,8 +55,8 @@ struct event_admin {
};
typedef struct channel *channel_t;
struct channel {
- char *topic;
- hash_map_pt eventHandlers;///array list containing all listeners subscribed to the channel
+ char *topic;
+ hash_map_pt eventHandlers;///array list containing all listeners subscribed to the channel
celix_thread_mutex_t *channelLock;
};
http://git-wip-us.apache.org/repos/asf/celix/blob/1db2379c/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 6b91f94..37ca79d 100644
--- a/event_admin/event_admin/private/src/event_admin_impl.c
+++ b/event_admin/event_admin/private/src/event_admin_impl.c
@@ -78,12 +78,6 @@ celix_status_t eventAdmin_destroy(event_admin_pt *event_admin) {
return status;
}
-celix_status_t eventAdmin_getEventHandlersByChannel(bundle_context_pt context, const char * serviceName, array_list_pt *eventHandlers) {
- celix_status_t status = CELIX_SUCCESS;
- //celix_status_t status = bundleContext_getServiceReferences(context, serviceName, NULL, eventHandlers);
- return status;
-}
-
celix_status_t eventAdmin_postEvent(event_admin_pt event_admin, event_pt event) {
bool added = false;
while (event_admin->eventAdminRunning && added == false) {
@@ -92,7 +86,6 @@ celix_status_t eventAdmin_postEvent(event_admin_pt event_admin, event_pt event)
celixThreadMutex_unlock(event_admin->eventListLock);
added = true;
}
-
}
return CELIX_SUCCESS;
}
http://git-wip-us.apache.org/repos/asf/celix/blob/1db2379c/event_admin/event_admin/public/include/event_admin.h
----------------------------------------------------------------------
diff --git a/event_admin/event_admin/public/include/event_admin.h b/event_admin/event_admin/public/include/event_admin.h
index 4955b54..2cd49cc 100644
--- a/event_admin/event_admin/public/include/event_admin.h
+++ b/event_admin/event_admin/public/include/event_admin.h
@@ -30,7 +30,7 @@
#include "listener_hook_service.h"
-#define EVENT_ADMIN_NAME "event_admin"
+static const char *const EVENT_ADMIN_NAME = "org.osgi.service.event.EventAdmin";
typedef struct event_admin *event_admin_pt;
typedef struct event_admin_service *event_admin_service_pt;
http://git-wip-us.apache.org/repos/asf/celix/blob/1db2379c/event_admin/event_admin/public/include/event_handler.h
----------------------------------------------------------------------
diff --git a/event_admin/event_admin/public/include/event_handler.h b/event_admin/event_admin/public/include/event_handler.h
index 5f76c6d..0325790 100644
--- a/event_admin/event_admin/public/include/event_handler.h
+++ b/event_admin/event_admin/public/include/event_handler.h
@@ -28,7 +28,8 @@
#define EVENT_HANDLER_H_
#include "event_admin.h"
#include "properties.h"
-static const char * const EVENT_HANDLER_SERVICE = "service.event.handler";
+
+static const char *const EVENT_HANDLER_SERVICE = "org.osgi.service.event.EventHandler";
typedef struct event_handler_service *event_handler_service_pt;
typedef struct event_handler *event_handler_pt; //ADT
http://git-wip-us.apache.org/repos/asf/celix/blob/1db2379c/event_admin/event_handler/private/src/event_handler_activator.c
----------------------------------------------------------------------
diff --git a/event_admin/event_handler/private/src/event_handler_activator.c b/event_admin/event_handler/private/src/event_handler_activator.c
index 9654e95..c4b20b9 100644
--- a/event_admin/event_handler/private/src/event_handler_activator.c
+++ b/event_admin/event_handler/private/src/event_handler_activator.c
@@ -69,7 +69,7 @@ celix_status_t bundleActivator_start(void * userData, bundle_context_pt context)
properties_pt properties = NULL;
properties = properties_create();
properties_set(properties, (char *) EVENT_HANDLER_SERVICE, (const char *) EVENT_HANDLER_NAME);
- properties_set(properties, (char *) EVENT_TOPIC, (const char *) "log/error/eventpublishers/event");
+ properties_set(properties, (char *) EVENT_TOPIC, (const char *) "log/error");
event_handler_service_pt event_handler_service = activator->event_handler_service;
bundleContext_registerService(context, (char *) EVENT_HANDLER_SERVICE, event_handler_service, properties,
http://git-wip-us.apache.org/repos/asf/celix/blob/1db2379c/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 29b61df..76f2367 100644
--- a/event_admin/event_handler/private/src/event_handler_impl.c
+++ b/event_admin/event_handler/private/src/event_handler_impl.c
@@ -57,7 +57,6 @@ 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/1db2379c/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 53c5f7a..66b81d4 100644
--- a/event_admin/event_publisher/private/src/event_publisher_impl.c
+++ b/event_admin/event_publisher/private/src/event_publisher_impl.c
@@ -85,7 +85,7 @@ void *produceEvents(void *handle) {
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)->createEvent(event_admin, "log/error", props, &event);
(*event_admin_service)->postEvent(event_admin, event);
(*event_admin_service)->sendEvent(event_admin, event);
}