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 2015/02/03 09:21:00 UTC
svn commit: r1656644 - in /celix/trunk: examples/deploy.cmake
log_service/private/src/log.c
Author: abroekhuis
Date: Tue Feb 3 08:21:00 2015
New Revision: 1656644
URL: http://svn.apache.org/r1656644
Log:
CELIX-213: Changed entry handling and locking to prevent segfaults.
Modified:
celix/trunk/examples/deploy.cmake
celix/trunk/log_service/private/src/log.c
Modified: celix/trunk/examples/deploy.cmake
URL: http://svn.apache.org/viewvc/celix/trunk/examples/deploy.cmake?rev=1656644&r1=1656643&r2=1656644&view=diff
==============================================================================
--- celix/trunk/examples/deploy.cmake (original)
+++ celix/trunk/examples/deploy.cmake Tue Feb 3 08:21:00 2015
@@ -19,7 +19,7 @@ if (EXAMPLES)
deploy(chapter01-greeting-example BUNDLES shell shell_tui log_service chapter01-greeting-example-client chapter01-greeting-example)
deploy(chapter04-correct-listener BUNDLES shell shell_tui log_service chapter04-correct-listener)
- deploy("hello_world" BUNDLES shell shell_tui apache_celix_examples_hello_world hello_world_test log_service)
+ deploy("hello_world" BUNDLES shell shell_tui apache_celix_examples_hello_world hello_world_test log_service log_writer)
deploy("wb" BUNDLES tracker publisherA publisherB shell shell_tui log_service log_writer)
deploy("wb_dp" BUNDLES tracker_depman publisherA publisherB shell shell_tui log_service log_writer)
deploy("echo" BUNDLES echo_server echo_client shell shell_tui)
Modified: celix/trunk/log_service/private/src/log.c
URL: http://svn.apache.org/viewvc/celix/trunk/log_service/private/src/log.c?rev=1656644&r1=1656643&r2=1656644&view=diff
==============================================================================
--- celix/trunk/log_service/private/src/log.c (original)
+++ celix/trunk/log_service/private/src/log.c Tue Feb 3 08:21:00 2015
@@ -134,21 +134,30 @@ celix_status_t log_addEntry(log_pt log,
if (log->store_debug || entry->level != OSGI_LOGSERVICE_DEBUG) {
linkedList_addElement(log->entries, entry);
}
+ }
+
+ celixThreadMutex_lock(&log->deliverLock);
+ arrayList_add(log->listenerEntries, entry);
+ celixThreadMutex_unlock(&log->deliverLock);
+ celixThreadCondition_signal(&log->entriesToDeliver);
+
+ if (log->max_size != 0) {
if (log->max_size != -1) {
if (linkedList_size(log->entries) > log->max_size) {
- log_entry_pt entry = linkedList_removeFirst(log->entries);
- if (entry) {
- logEntry_destroy(&entry);
+ log_entry_pt rentry = linkedList_removeFirst(log->entries);
+ if (rentry) {
+ celixThreadMutex_lock(&log->deliverLock);
+ arrayList_removeElement(log->listenerEntries, rentry);
+ logEntry_destroy(&rentry);
+ celixThreadMutex_unlock(&log->deliverLock);
}
}
}
}
- arrayList_add(log->listenerEntries, entry);
- celixThreadCondition_signal(&log->entriesToDeliver);
-
celixThreadMutex_unlock(&log->lock);
+
return CELIX_SUCCESS;
}
@@ -333,9 +342,9 @@ static void * log_listenerThread(void *d
arrayListIterator_destroy(it);
// destroy not-stored entries
- if (!(logger->store_debug || entry->level != OSGI_LOGSERVICE_DEBUG)) {
- logEntry_destroy(&entry);
- }
+ if (!(logger->store_debug || entry->level != OSGI_LOGSERVICE_DEBUG)) {
+ logEntry_destroy(&entry);
+ }
status = celixThreadMutex_unlock(&logger->listenerLock);
if (status != CELIX_SUCCESS) {