celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bpe...@apache.org
Subject [15/19] celix git commit: CELIX-259: added dispatcherThread shutdown
Date Mon, 28 Sep 2015 10:03:00 GMT
CELIX-259: added dispatcherThread shutdown


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

Branch: refs/heads/feature/CELIX-247_android_support
Commit: 268ab022e08adaa6011785a9cac6b36c958f670a
Parents: 7e3b33f
Author: Bjoern Petri <bpetri@apache.org>
Authored: Fri Sep 25 19:48:27 2015 +0200
Committer: Bjoern Petri <bpetri@apache.org>
Committed: Fri Sep 25 19:48:27 2015 +0200

----------------------------------------------------------------------
 framework/private/src/framework.c | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/268ab022/framework/private/src/framework.c
----------------------------------------------------------------------
diff --git a/framework/private/src/framework.c b/framework/private/src/framework.c
index e0391e7..529a712 100644
--- a/framework/private/src/framework.c
+++ b/framework/private/src/framework.c
@@ -2066,10 +2066,23 @@ static void *framework_shutdown(void *framework) {
 		bundle_close(bundle);
 	}
 	hashMapIterator_destroy(iter);
-#ifndef ANDROID
-    pthread_cancel(fw->dispatcherThread.thread);
-#endif
-    celixThread_join(fw->dispatcherThread, NULL);
+
+	if (celixThreadMutex_lock(&fw->dispatcherLock) != CELIX_SUCCESS) {
+		fw_log(fw->logger, OSGI_FRAMEWORK_LOG_ERROR, "Error locking the dispatcherThread.");
+	}
+	else {
+		fw->shutdown = true;
+
+		if (celixThreadCondition_broadcast(&fw->dispatcher)) {
+			fw_log(fw->logger, OSGI_FRAMEWORK_LOG_ERROR, "Error broadcasting .");
+		}
+
+		if (celixThreadMutex_unlock(&fw->dispatcherLock)) {
+			fw_log(fw->logger, OSGI_FRAMEWORK_LOG_ERROR, "Error unlocking the dispatcherThread.");
+		}
+
+		celixThread_join(fw->dispatcherThread, NULL);
+	}
 
 	err = celixThreadMutex_lock(&fw->mutex);
 	if (err != 0) {
@@ -2077,7 +2090,6 @@ static void *framework_shutdown(void *framework) {
 		celixThread_exit(NULL);
 		return NULL;
 	}
-	fw->shutdown = true;
 	err = celixThreadCondition_broadcast(&fw->shutdownGate);
 	if (err != 0) {
 		fw_log(fw->logger, OSGI_FRAMEWORK_LOG_ERROR,  "Error waking the shutdown gate, cannot
exit clean.");


Mime
View raw message