celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bpe...@apache.org
Subject svn commit: r1643720 - in /celix/trunk: log_service/private/include/ log_service/private/src/ log_service/public/include/ shell/private/src/
Date Sun, 07 Dec 2014 21:32:19 GMT
Author: bpetri
Date: Sun Dec  7 21:32:18 2014
New Revision: 1643720

URL: http://svn.apache.org/r1643720
Log:
CELIX-119: remove apr from log_service

Modified:
    celix/trunk/log_service/private/include/log.h
    celix/trunk/log_service/private/include/log_factory.h
    celix/trunk/log_service/private/include/log_reader_service_impl.h
    celix/trunk/log_service/private/include/log_service_impl.h
    celix/trunk/log_service/private/src/log.c
    celix/trunk/log_service/private/src/log_entry.c
    celix/trunk/log_service/private/src/log_factory.c
    celix/trunk/log_service/private/src/log_reader_service_impl.c
    celix/trunk/log_service/private/src/log_service_activator.c
    celix/trunk/log_service/private/src/log_service_impl.c
    celix/trunk/log_service/public/include/log_entry.h
    celix/trunk/log_service/public/include/log_reader_service.h
    celix/trunk/shell/private/src/log_command.c

Modified: celix/trunk/log_service/private/include/log.h
URL: http://svn.apache.org/viewvc/celix/trunk/log_service/private/include/log.h?rev=1643720&r1=1643719&r2=1643720&view=diff
==============================================================================
--- celix/trunk/log_service/private/include/log.h (original)
+++ celix/trunk/log_service/private/include/log.h Sun Dec  7 21:32:18 2014
@@ -27,17 +27,15 @@
 #ifndef LOG_H_
 #define LOG_H_
 
-#include <apr_general.h>
-
 #include "linked_list.h"
 #include "log_entry.h"
 #include "log_listener.h"
 
 typedef struct log * log_pt;
 
-celix_status_t log_create(apr_pool_t *pool, log_pt *logger);
+celix_status_t log_create(log_pt *logger);
 celix_status_t log_addEntry(log_pt log, log_entry_pt entry);
-celix_status_t log_getEntries(log_pt log, apr_pool_t *memory_pool, linked_list_pt *list);
+celix_status_t log_getEntries(log_pt log, linked_list_pt *list);
 
 celix_status_t log_bundleChanged(void *listener, bundle_event_pt event);
 celix_status_t log_frameworkEvent(void *listener, framework_event_pt event);

Modified: celix/trunk/log_service/private/include/log_factory.h
URL: http://svn.apache.org/viewvc/celix/trunk/log_service/private/include/log_factory.h?rev=1643720&r1=1643719&r2=1643720&view=diff
==============================================================================
--- celix/trunk/log_service/private/include/log_factory.h (original)
+++ celix/trunk/log_service/private/include/log_factory.h Sun Dec  7 21:32:18 2014
@@ -31,7 +31,7 @@
 
 typedef struct log_service_factory * log_service_factory_pt;
 
-celix_status_t logFactory_create(apr_pool_t *pool, log_pt log, service_factory_pt *factory);
+celix_status_t logFactory_create(log_pt log, service_factory_pt *factory);
 celix_status_t logFactory_getService(void *factory, bundle_pt bundle, service_registration_pt
registration, void **service);
 celix_status_t logFactory_ungetService(void *factory, bundle_pt bundle, service_registration_pt
registration);
 

Modified: celix/trunk/log_service/private/include/log_reader_service_impl.h
URL: http://svn.apache.org/viewvc/celix/trunk/log_service/private/include/log_reader_service_impl.h?rev=1643720&r1=1643719&r2=1643720&view=diff
==============================================================================
--- celix/trunk/log_service/private/include/log_reader_service_impl.h (original)
+++ celix/trunk/log_service/private/include/log_reader_service_impl.h Sun Dec  7 21:32:18
2014
@@ -30,9 +30,10 @@
 #include "log_reader_service.h"
 #include "log.h"
 
-celix_status_t logReaderService_create(log_pt log, apr_pool_t *pool, log_reader_data_pt *reader);
+celix_status_t logReaderService_create(log_pt log, log_reader_data_pt *reader);
+celix_status_t logReaderService_destroy(log_reader_data_pt *reader);
 
-celix_status_t logReaderService_getLog(log_reader_data_pt reader, apr_pool_t *memory_pool,
linked_list_pt *list);
+celix_status_t logReaderService_getLog(log_reader_data_pt reader, linked_list_pt *list);
 
 celix_status_t logReaderService_addLogListener(log_reader_data_pt reader, log_listener_pt
listener);
 celix_status_t logReaderService_removeLogListener(log_reader_data_pt reader, log_listener_pt
listener);

Modified: celix/trunk/log_service/private/include/log_service_impl.h
URL: http://svn.apache.org/viewvc/celix/trunk/log_service/private/include/log_service_impl.h?rev=1643720&r1=1643719&r2=1643720&view=diff
==============================================================================
--- celix/trunk/log_service/private/include/log_service_impl.h (original)
+++ celix/trunk/log_service/private/include/log_service_impl.h Sun Dec  7 21:32:18 2014
@@ -30,7 +30,8 @@
 #include "log_service.h"
 #include "log.h"
 
-celix_status_t logService_create(log_pt log, bundle_pt bundle, apr_pool_t *pool, log_service_data_pt
*logger);
+celix_status_t logService_create(log_pt log, bundle_pt bundle, log_service_data_pt *logger);
+celix_status_t logService_destroy(log_service_data_pt *logger);
 celix_status_t logService_log(log_service_data_pt logger, log_level_t level, char * message);
 celix_status_t logService_logSr(log_service_data_pt logger, service_reference_pt reference,
log_level_t level, char * message);
 

Modified: celix/trunk/log_service/private/src/log.c
URL: http://svn.apache.org/viewvc/celix/trunk/log_service/private/src/log.c?rev=1643720&r1=1643719&r2=1643720&view=diff
==============================================================================
--- celix/trunk/log_service/private/src/log.c (original)
+++ celix/trunk/log_service/private/src/log.c Sun Dec  7 21:32:18 2014
@@ -24,83 +24,74 @@
  *  \copyright	Apache License, Version 2.0
  */
 #include <stdlib.h>
-#include <apr_thread_cond.h>
-#include <apr_thread_mutex.h>
-#include <apr_thread_proc.h>
 
 #include "log.h"
 #include "linked_list_iterator.h"
 #include "array_list.h"
 
 struct log {
-    linked_list_pt entries;
-    apr_thread_mutex_t *lock;
+	linked_list_pt entries;
+	celix_thread_mutex_t lock;
 
-    array_list_pt listeners;
-    array_list_pt listenerEntries;
+	array_list_pt listeners;
+	array_list_pt listenerEntries;
 
-    apr_thread_t *listenerThread;
-    bool running;
+	celix_thread_t listenerThread;
+	bool running;
 
-    apr_thread_cond_t *entriesToDeliver;
-    apr_thread_mutex_t *deliverLock;
-    apr_thread_mutex_t *listenerLock;
-
-    apr_pool_t *pool;
+	celix_thread_cond_t entriesToDeliver;
+	celix_thread_mutex_t deliverLock;
+	celix_thread_mutex_t listenerLock;
 };
 
 static celix_status_t log_startListenerThread(log_pt logger);
 static celix_status_t log_stopListenerThread(log_pt logger);
 
-void * APR_THREAD_FUNC log_listenerThread(apr_thread_t *thread, void *data);
-apr_status_t log_destroy(void *logp);
 
-celix_status_t log_create(apr_pool_t *pool, log_pt *logger) {
-    celix_status_t status = CELIX_SUCCESS;
+static void *log_listenerThread(void *data);
+
+celix_status_t log_create(log_pt *logger) {
+	celix_status_t status = CELIX_ENOMEM;
+
+	*logger = calloc(1, sizeof(**logger));
+
+	if (*logger != NULL) {
+		linkedList_create(&(*logger)->entries);
 
-    *logger = apr_palloc(pool, sizeof(**logger));
-    if (*logger == NULL) {
-        status = CELIX_ENOMEM;
-    } else {
-        apr_status_t apr_status;
-
-        apr_pool_pre_cleanup_register(pool, *logger, log_destroy);
-        linkedList_create(&(*logger)->entries);
-        apr_thread_mutex_create(&(*logger)->lock, APR_THREAD_MUTEX_UNNESTED, pool);
+		status = celixThreadMutex_create(&(*logger)->lock, NULL);
+
+		(*logger)->listeners = NULL;
+		(*logger)->listenerEntries = NULL;
+		(*logger)->listenerThread = -1;
+		(*logger)->running = false;
 
-        (*logger)->pool = pool;
-        (*logger)->listeners = NULL;
 		arrayList_create(&(*logger)->listeners);
-        (*logger)->listenerEntries = NULL;
-        arrayList_create(&(*logger)->listenerEntries);
-        (*logger)->listenerThread = NULL;
-        (*logger)->running = false;
-        apr_status = apr_thread_cond_create(&(*logger)->entriesToDeliver, pool);
-        if (apr_status != APR_SUCCESS) {
-            status = CELIX_INVALID_SYNTAX;
-        } else {
-            apr_status = apr_thread_mutex_create(&(*logger)->deliverLock, 0, pool);
-            if (apr_status != APR_SUCCESS) {
-                status = CELIX_INVALID_SYNTAX;
-            } else {
-                apr_status = apr_thread_mutex_create(&(*logger)->listenerLock, 0,
pool);
-                if (apr_status != APR_SUCCESS) {
-                    status = CELIX_INVALID_SYNTAX;
-                } else {
-                    // done
-                }
-            }
-        }
-    }
+		arrayList_create(&(*logger)->listenerEntries);
+
+		if (celixThreadCondition_init(&(*logger)->entriesToDeliver, NULL) != CELIX_SUCCESS)
{
+			status = CELIX_INVALID_SYNTAX;
+		}
+		else if (celixThreadMutex_create(&(*logger)->deliverLock, NULL) != CELIX_SUCCESS)
{
+			status = CELIX_INVALID_SYNTAX;
+		}
+		else if (celixThreadMutex_create(&(*logger)->listenerLock, NULL) != CELIX_SUCCESS)
{
+			status = CELIX_INVALID_SYNTAX;
+		}
+		else {
+			status = CELIX_SUCCESS;
+		}
+	}
 
-    return status;
+	return status;
 }
 
-apr_status_t log_destroy(void *logp) {
+celix_status_t log_destroy(void *logp) {
+	celix_status_t status = CELIX_SUCCESS;
 	log_pt log = logp;
-	apr_thread_mutex_destroy(log->listenerLock);
-	apr_thread_mutex_destroy(log->deliverLock);
-	apr_thread_cond_destroy(log->entriesToDeliver);
+
+	celixThreadMutex_destroy(&log->listenerLock);
+	celixThreadMutex_destroy(&log->deliverLock);
+
 	arrayList_destroy(log->listenerEntries);
 	arrayList_destroy(log->listeners);
 	linked_list_iterator_pt iter = linkedListIterator_create(log->entries, 0);
@@ -109,47 +100,44 @@ apr_status_t log_destroy(void *logp) {
 	    logEntry_destroy(&entry);
 	}
 	linkedList_destroy(log->entries);
-	apr_thread_mutex_destroy(log->lock);
 
-	return APR_SUCCESS;
+	celixThreadMutex_destroy(&log->lock);
+
+	return status;
 }
 
 celix_status_t log_addEntry(log_pt log, log_entry_pt entry) {
-    apr_thread_mutex_lock(log->lock);
-    linkedList_addElement(log->entries, entry);
+	celixThreadMutex_lock(&log->lock);
+	linkedList_addElement(log->entries, entry);
+
+	arrayList_add(log->listenerEntries, entry);
+	celixThreadCondition_signal(&log->entriesToDeliver);
+
+	celixThreadMutex_unlock(&log->lock);
+	return CELIX_SUCCESS;
+}
 
-    // notify any listeners
-    if (log->listenerThread != NULL)
-    {
-        arrayList_add(log->listenerEntries, entry);
-        apr_thread_cond_signal(log->entriesToDeliver);
-    }
-
-    apr_thread_mutex_unlock(log->lock);
-    return CELIX_SUCCESS;
-}
-
-celix_status_t log_getEntries(log_pt log, apr_pool_t *memory_pool, linked_list_pt *list)
{
-    linked_list_pt entries = NULL;
-    if (linkedList_create(&entries) == CELIX_SUCCESS) {
-        linked_list_iterator_pt iter = NULL;
-
-        apr_thread_mutex_lock(log->lock);
-
-        iter = linkedListIterator_create(log->entries, 0);
-        while (linkedListIterator_hasNext(iter)) {
-            linkedList_addElement(entries, linkedListIterator_next(iter));
-        }
+celix_status_t log_getEntries(log_pt log, linked_list_pt *list) {
+	linked_list_pt entries = NULL;
+	if (linkedList_create(&entries) == CELIX_SUCCESS) {
+		linked_list_iterator_pt iter = NULL;
+
+		celixThreadMutex_lock(&log->lock);
+
+		iter = linkedListIterator_create(log->entries, 0);
+		while (linkedListIterator_hasNext(iter)) {
+			linkedList_addElement(entries, linkedListIterator_next(iter));
+		}
 		linkedListIterator_destroy(iter);
 
-        *list = entries;
+		*list = entries;
 
-        apr_thread_mutex_unlock(log->lock);
+		celixThreadMutex_unlock(&log->lock);
 
-        return CELIX_SUCCESS;
-    } else {
-        return CELIX_ENOMEM;
-    }
+		return CELIX_SUCCESS;
+	} else {
+		return CELIX_ENOMEM;
+	}
 }
 
 celix_status_t log_bundleChanged(void *listener, bundle_event_pt event) {
@@ -203,154 +191,129 @@ celix_status_t log_frameworkEvent(void *
 }
 
 celix_status_t log_addLogListener(log_pt logger, log_listener_pt listener) {
-    celix_status_t status = CELIX_SUCCESS;
-    apr_status_t apr_status;
+	celix_status_t status = CELIX_SUCCESS;
+
+	celixThreadMutex_lock(&logger->listenerLock);
 
-    apr_status = apr_thread_mutex_lock(logger->listenerLock);
-    if (apr_status != APR_SUCCESS) {
-        status = CELIX_INVALID_SYNTAX;
-    } else {
-        arrayList_add(logger->listeners, listener);
-
-        if (logger->listenerThread == NULL) {
-            log_startListenerThread(logger);
-        }
-
-        apr_status = apr_thread_mutex_unlock(logger->listenerLock);
-        if (apr_status != APR_SUCCESS) {
-            status = CELIX_INVALID_SYNTAX;
-        }
-    }
+	arrayList_add(logger->listeners, listener);
+	log_startListenerThread(logger);
 
-    return status;
+	celixThreadMutex_unlock(&logger->listenerLock);
+
+	return status;
 }
 
 celix_status_t log_removeLogListener(log_pt logger, log_listener_pt listener) {
-    celix_status_t status = CELIX_SUCCESS;
-    celix_status_t threadStatus = CELIX_SUCCESS;
-	bool last=false;
-
-    status = CELIX_DO_IF(status, apr_thread_mutex_lock(logger->deliverLock));
-    status = CELIX_DO_IF(status, apr_thread_mutex_lock(logger->listenerLock));
-    if (status == CELIX_SUCCESS) {
-        arrayList_removeElement(logger->listeners, listener);
-        if (arrayList_size(logger->listeners) == 0) {
-            status = log_stopListenerThread(logger);
-			last=true;
-        }
-
-        status = CELIX_DO_IF(status, apr_thread_mutex_unlock(logger->listenerLock));
-        status = CELIX_DO_IF(status, apr_thread_mutex_unlock(logger->deliverLock));
-
-		if(last){
-        status = CELIX_DO_IF(status, apr_thread_join(&threadStatus, logger->listenerThread));
-		}
-
-        if (status == CELIX_SUCCESS) {
-            logger->listenerThread = NULL;
-        }
-        status = threadStatus;
-    }
-
-    if (status != CELIX_SUCCESS) {
-        status = CELIX_SERVICE_EXCEPTION;
-    }
+	celix_status_t status = CELIX_SUCCESS;
+	bool last = false;
+
+	celixThreadMutex_lock(&logger->deliverLock);
+	celixThreadMutex_lock(&logger->listenerLock);
 
-    return status;
+	if (status == CELIX_SUCCESS) {
+		arrayList_removeElement(logger->listeners, listener);
+		if (arrayList_size(logger->listeners) == 0) {
+			status = log_stopListenerThread(logger);
+			last = true;
+		}
+
+		celixThreadMutex_unlock(&logger->listenerLock);
+		celixThreadMutex_unlock(&logger->deliverLock);
+
+		if (last) {
+			celixThread_join(logger->listenerThread, NULL);
+		}
+
+		if (status == CELIX_SUCCESS) {
+			logger->listenerThread = -1;
+		}
+	}
+
+	if (status != CELIX_SUCCESS) {
+		status = CELIX_SERVICE_EXCEPTION;
+	}
+
+	return status;
 }
 
 celix_status_t log_removeAllLogListener(log_pt logger) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    apr_status_t apr_status;
+	celix_status_t status = CELIX_SUCCESS;
 
-    apr_status = apr_thread_mutex_lock(logger->listenerLock);
-    if (apr_status != APR_SUCCESS) {
-        status = CELIX_INVALID_SYNTAX;
-    } else {
-        arrayList_clear(logger->listeners);
+	celixThreadMutex_lock(&logger->listenerLock);
 
+	arrayList_clear(logger->listeners);
 
-        apr_status = apr_thread_mutex_unlock(logger->listenerLock);
-        if (apr_status != APR_SUCCESS) {
-            status = CELIX_INVALID_SYNTAX;
-        }
-    }
+	celixThreadMutex_unlock(&logger->listenerLock);
 
-    return status;
+	return status;
 }
 
 static celix_status_t log_startListenerThread(log_pt logger) {
-    celix_status_t status = CELIX_SUCCESS;
-    apr_status_t apr_status;
+	celix_status_t status = CELIX_SUCCESS;
+
+	logger->running = true;
 
-    logger->running = true;
-    apr_status = apr_thread_create(&logger->listenerThread, NULL, log_listenerThread,
logger, logger->pool);
-    if (apr_status != APR_SUCCESS) {
-        status = CELIX_INVALID_SYNTAX;
-    }
+	status = celixThread_create(&logger->listenerThread, NULL, &log_listenerThread,
logger);
 
-    return status;
+	return status;
 }
 
 static celix_status_t log_stopListenerThread(log_pt logger) {
-    celix_status_t status = CELIX_SUCCESS;
+	celix_status_t status = CELIX_SUCCESS;
+
+	logger->running = false;
+
+	status = celixThreadCondition_signal(&logger->entriesToDeliver);
 
-    logger->running = false;
-	if( apr_thread_cond_signal(logger->entriesToDeliver) != APR_SUCCESS){
-        status = CELIX_SERVICE_EXCEPTION;
-    }
-
-    return status;
-}
-
-void * APR_THREAD_FUNC log_listenerThread(apr_thread_t *thread, void *data) {
-    apr_status_t status = APR_SUCCESS;
-
-    log_pt logger = data;
-
-    while (logger->running) {
-        status = apr_thread_mutex_lock(logger->deliverLock);
-        if (status != APR_SUCCESS) {
-            logger->running = false;
-        } else {
-            if (!arrayList_isEmpty(logger->listenerEntries)) {
-                log_entry_pt entry = (log_entry_pt) arrayList_remove(logger->listenerEntries,
0);
-
-                if (entry) {
-                    status = apr_thread_mutex_lock(logger->listenerLock);
-                    if (status != APR_SUCCESS) {
-                        logger->running = false;
-                        break;
-                    } else {
-                        array_list_iterator_pt it = arrayListIterator_create(logger->listeners);
-                        while (arrayListIterator_hasNext(it)) {
-                            log_listener_pt listener = arrayListIterator_next(it);
-                            listener->logged(listener, entry);
-                        }
-                        arrayListIterator_destroy(it);
-
-                        status = apr_thread_mutex_unlock(logger->listenerLock);
-                        if (status != APR_SUCCESS) {
-                            logger->running = false;
-                            break;
-                        }
-                    }
-                }
-            }
-
-            if (arrayList_isEmpty(logger->listenerEntries) && logger->running)
{
-                apr_thread_cond_wait(logger->entriesToDeliver, logger->deliverLock);
-            }
-
-            status = apr_thread_mutex_unlock(logger->deliverLock);
-            if (status != APR_SUCCESS) {
-                logger->running = false;
-                break;
-            }
-        }
-    }
+	return status;
+}
+
+static void * log_listenerThread(void *data) {
+	celix_status_t status = CELIX_SUCCESS;
 
-    apr_thread_exit(thread, status);
-    return NULL;
+	log_pt logger = data;
+
+	while (logger->running) {
+
+		status = celixThreadMutex_lock(&logger->deliverLock);
+
+		if ( status != CELIX_SUCCESS) {
+			logger->running = false;
+		}
+		else {
+			if (!arrayList_isEmpty(logger->listenerEntries)) {
+				log_entry_pt entry = (log_entry_pt) arrayList_remove(logger->listenerEntries, 0);
+
+				status = celixThreadMutex_lock(&logger->listenerLock);
+				if (status != CELIX_SUCCESS) {
+					logger->running = false;
+				} else {
+					array_list_iterator_pt it = arrayListIterator_create(logger->listeners);
+					while (arrayListIterator_hasNext(it)) {
+						log_listener_pt listener = arrayListIterator_next(it);
+						listener->logged(listener, entry);
+					}
+					arrayListIterator_destroy(it);
+
+					status = celixThreadMutex_unlock(&logger->listenerLock);
+					if (status != CELIX_SUCCESS) {
+						logger->running = false;
+						break;
+					}
+				}
+			}
+
+			if (arrayList_isEmpty(logger->listenerEntries) && logger->running) {
+				celixThreadCondition_wait(&logger->entriesToDeliver, &logger->deliverLock);
+			}
+
+			status = celixThreadMutex_unlock(&logger->deliverLock);
+
+			if (status != CELIX_SUCCESS) {
+				logger->running = false;
+			}
+		}
+
+	}
+	return NULL;
 }

Modified: celix/trunk/log_service/private/src/log_entry.c
URL: http://svn.apache.org/viewvc/celix/trunk/log_service/private/src/log_entry.c?rev=1643720&r1=1643719&r2=1643720&view=diff
==============================================================================
--- celix/trunk/log_service/private/src/log_entry.c (original)
+++ celix/trunk/log_service/private/src/log_entry.c Sun Dec  7 21:32:18 2014
@@ -27,6 +27,8 @@
 #include <stddef.h>
 #include <stdlib.h>
 
+#include "celix_errno.h"
+#include "log_service.h"
 #include "log_entry.h"
 
 celix_status_t logEntry_create(bundle_pt bundle, service_reference_pt reference,

Modified: celix/trunk/log_service/private/src/log_factory.c
URL: http://svn.apache.org/viewvc/celix/trunk/log_service/private/src/log_factory.c?rev=1643720&r1=1643719&r2=1643720&view=diff
==============================================================================
--- celix/trunk/log_service/private/src/log_factory.c (original)
+++ celix/trunk/log_service/private/src/log_factory.c Sun Dec  7 21:32:18 2014
@@ -25,28 +25,28 @@
  */
 
 #include <stddef.h>
+#include <stdlib.h>
+
 
 #include "service_factory.h"
 #include "log_factory.h"
 #include "log_service_impl.h"
 
 struct log_service_factory {
-    apr_pool_t *pool;
     log_pt log;
 };
 
-celix_status_t logFactory_create(apr_pool_t *pool, log_pt log, service_factory_pt *factory)
{
+celix_status_t logFactory_create(log_pt log, service_factory_pt *factory) {
     celix_status_t status = CELIX_SUCCESS;
 
-    *factory = apr_palloc(pool, sizeof(**factory));
+    *factory = calloc(1, sizeof(**factory));
     if (*factory == NULL) {
         status = CELIX_ENOMEM;
     } else {
-        log_service_factory_pt factoryData = apr_palloc(pool, sizeof(*factoryData));
+        log_service_factory_pt factoryData = calloc(1, sizeof(*factoryData));
         if (factoryData == NULL) {
             status = CELIX_ENOMEM;
         } else {
-            factoryData->pool = pool;
             factoryData->log = log;
 
             (*factory)->factory = factoryData;
@@ -58,14 +58,27 @@ celix_status_t logFactory_create(apr_poo
     return status;
 }
 
+celix_status_t logFactory_destroy(service_factory_pt *factory) {
+    celix_status_t status = CELIX_SUCCESS;
+
+
+    free((*factory)->factory);
+    free(*factory);
+
+    factory = NULL;
+
+    return status;
+}
+
+
 celix_status_t logFactory_getService(void *factory, bundle_pt bundle, service_registration_pt
registration, void **service) {
     log_service_factory_pt log_factory = ((service_factory_pt) factory)->factory;
     log_service_pt log_service = NULL;
     log_service_data_pt log_service_data = NULL;
 
-    logService_create(log_factory->log, bundle, log_factory->pool, &log_service_data);
+    logService_create(log_factory->log, bundle, &log_service_data);
 
-    log_service = apr_palloc(log_factory->pool, sizeof(*log_service));
+    log_service = calloc(1, sizeof(*log_service));
     log_service->logger = log_service_data;
     log_service->log = logService_log;
     log_service->logSr = logService_logSr;

Modified: celix/trunk/log_service/private/src/log_reader_service_impl.c
URL: http://svn.apache.org/viewvc/celix/trunk/log_service/private/src/log_reader_service_impl.c?rev=1643720&r1=1643719&r2=1643720&view=diff
==============================================================================
--- celix/trunk/log_service/private/src/log_reader_service_impl.c (original)
+++ celix/trunk/log_service/private/src/log_reader_service_impl.c Sun Dec  7 21:32:18 2014
@@ -24,6 +24,7 @@
  *  \copyright	Apache License, Version 2.0
  */
 
+#include <stdlib.h>
 #include <stddef.h>
 
 #include "log_reader_service_impl.h"
@@ -31,28 +32,37 @@
 
 struct log_reader_data {
     log_pt log;
-    apr_pool_t *pool;
 };
 
-celix_status_t logReaderService_create(log_pt log, apr_pool_t *pool, log_reader_data_pt *reader)
{
-    celix_status_t status = APR_SUCCESS;
+celix_status_t logReaderService_create(log_pt log, log_reader_data_pt *reader) {
+    celix_status_t status = CELIX_SUCCESS;
 
-    *reader = (log_reader_data_pt) apr_palloc(pool, sizeof(**reader));
+    *reader = (log_reader_data_pt) calloc(1, sizeof(**reader));
 
     if (reader == NULL) {
         status = CELIX_ENOMEM;
     } else {
         (*reader)->log = log;
-        (*reader)->pool = pool;
     }
 
     return status;
 }
 
-celix_status_t logReaderService_getLog(log_reader_data_pt reader, apr_pool_t *memory_pool,
linked_list_pt *list) {
+celix_status_t logReaderService_destroy(log_reader_data_pt *reader) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    free(*reader);
+    reader = NULL;
+
+    return status;
+}
+
+
+
+celix_status_t logReaderService_getLog(log_reader_data_pt reader, linked_list_pt *list) {
     celix_status_t status = CELIX_SUCCESS;
 
-    status = log_getEntries(reader->log, memory_pool, list);
+    status = log_getEntries(reader->log, list);
 
     return status;
 }

Modified: celix/trunk/log_service/private/src/log_service_activator.c
URL: http://svn.apache.org/viewvc/celix/trunk/log_service/private/src/log_service_activator.c?rev=1643720&r1=1643719&r2=1643720&view=diff
==============================================================================
--- celix/trunk/log_service/private/src/log_service_activator.c (original)
+++ celix/trunk/log_service/private/src/log_service_activator.c Sun Dec  7 21:32:18 2014
@@ -23,7 +23,7 @@
  *  \author    	<a href="mailto:celix-dev@incubator.apache.org">Apache Celix Project
Team</a>
  *  \copyright	Apache License, Version 2.0
  */
-#include <apr_general.h>
+
 #include <stdlib.h>
 
 #include "bundle_activator.h"
@@ -35,7 +35,6 @@
 #include "service_registration.h"
 
 struct logActivator {
-    apr_pool_t *pool;
     bundle_context_pt bundleContext;
     service_registration_pt logServiceFactoryReg;
     service_registration_pt logReaderServiceReg;
@@ -51,12 +50,9 @@ struct logActivator {
 
 celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
     celix_status_t status = CELIX_SUCCESS;
-    apr_pool_t *mp = NULL;
 	struct logActivator * activator = NULL;
 
-    apr_pool_create(&mp, NULL);
-    activator = (struct logActivator *) apr_palloc(mp, sizeof(struct logActivator));
-
+    activator = (struct logActivator *) calloc(1, sizeof(struct logActivator));
 
     if (activator == NULL) {
         status = CELIX_ENOMEM;
@@ -64,7 +60,6 @@ celix_status_t bundleActivator_create(bu
 		activator->bundleContext = context;
 		activator->logServiceFactoryReg = NULL;
 		activator->logReaderServiceReg = NULL;
-		activator->pool = mp;
 
 		activator->logger = NULL;
 		activator->factory = NULL;
@@ -81,26 +76,27 @@ celix_status_t bundleActivator_start(voi
     struct logActivator * activator = (struct logActivator *) userData;
     celix_status_t status = CELIX_SUCCESS;
 
-    log_create(activator->pool, &activator->logger);
+
+    log_create(&activator->logger);
 
     // Add logger as Bundle- and FrameworkEvent listener
-    activator->bundleListener = apr_palloc(activator->pool, sizeof(*activator->bundleListener));
+    activator->bundleListener = calloc(1, sizeof(*activator->bundleListener));
     activator->bundleListener->handle = activator->logger;
     activator->bundleListener->bundleChanged = log_bundleChanged;
     bundleContext_addBundleListener(context, activator->bundleListener);
 
-    activator->frameworkListener = apr_palloc(activator->pool, sizeof(*activator->frameworkListener));
+    activator->frameworkListener = calloc(1, sizeof(*activator->frameworkListener));
     activator->frameworkListener->handle = activator->logger;
     activator->frameworkListener->frameworkEvent = log_frameworkEvent;
     bundleContext_addFrameworkListener(context, activator->frameworkListener);
 
-    logFactory_create(activator->pool, activator->logger, &activator->factory);
+    logFactory_create(activator->logger, &activator->factory);
 
     bundleContext_registerServiceFactory(context, (char *) OSGI_LOGSERVICE_NAME, activator->factory,
NULL, &activator->logServiceFactoryReg);
 
-    logReaderService_create(activator->logger, activator->pool, &activator->reader);
+    logReaderService_create(activator->logger, &activator->reader);
 
-    activator->reader_service = apr_palloc(activator->pool, sizeof(*activator->reader_service));
+    activator->reader_service = calloc(1, sizeof(*activator->reader_service));
     activator->reader_service->reader = activator->reader;
     activator->reader_service->getLog = logReaderService_getLog;
     activator->reader_service->addLogListener = logReaderService_addLogListener;
@@ -120,8 +116,8 @@ celix_status_t bundleActivator_stop(void
 	serviceRegistration_unregister(activator->logServiceFactoryReg);
 	activator->logServiceFactoryReg = NULL;
 
-	// logReaderService_destroy(activator->reader);
-	// free(activator->reader_service);
+    logReaderService_destroy(&activator->reader);
+	free(activator->reader_service);
 
 	// logFactory_destroy(activator->factory);
 
@@ -134,5 +130,9 @@ celix_status_t bundleActivator_stop(void
 }
 
 celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) {
+	struct logActivator * activator = (struct logActivator *) userData;
+
+	free(activator);
+
     return CELIX_SUCCESS;
 }

Modified: celix/trunk/log_service/private/src/log_service_impl.c
URL: http://svn.apache.org/viewvc/celix/trunk/log_service/private/src/log_service_impl.c?rev=1643720&r1=1643719&r2=1643720&view=diff
==============================================================================
--- celix/trunk/log_service/private/src/log_service_impl.c (original)
+++ celix/trunk/log_service/private/src/log_service_impl.c Sun Dec  7 21:32:18 2014
@@ -32,22 +32,29 @@
 struct log_service_data {
     log_pt log;
     bundle_pt bundle;
-    apr_pool_t *pool;
 };
 
-celix_status_t logService_create(log_pt log, bundle_pt bundle, apr_pool_t *pool, log_service_data_pt
*logger) {
+celix_status_t logService_create(log_pt log, bundle_pt bundle, log_service_data_pt *logger)
{
     celix_status_t status = CELIX_SUCCESS;
-    *logger = apr_palloc(pool, sizeof(struct log_service_data));
+    *logger = calloc(1, sizeof(struct log_service_data));
     if (*logger == NULL) {
         status = CELIX_ENOMEM;
     } else {
         (*logger)->bundle = bundle;
         (*logger)->log = log;
-        (*logger)->pool = pool;
     }
 
     return status;
 }
+
+celix_status_t logService_destroy(log_service_data_pt *logger) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    free(*logger);
+    logger = NULL;
+
+    return status;
+}
 
 celix_status_t logService_log(log_service_data_pt logger, log_level_t level, char * message)
{
     return logService_logSr(logger, NULL, level, message);

Modified: celix/trunk/log_service/public/include/log_entry.h
URL: http://svn.apache.org/viewvc/celix/trunk/log_service/public/include/log_entry.h?rev=1643720&r1=1643719&r2=1643720&view=diff
==============================================================================
--- celix/trunk/log_service/public/include/log_entry.h (original)
+++ celix/trunk/log_service/public/include/log_entry.h Sun Dec  7 21:32:18 2014
@@ -27,8 +27,6 @@
 #ifndef LOG_ENTRY_H_
 #define LOG_ENTRY_H_
 
-#include <apr_general.h>
-
 #include "log_service.h"
 
 struct log_entry {

Modified: celix/trunk/log_service/public/include/log_reader_service.h
URL: http://svn.apache.org/viewvc/celix/trunk/log_service/public/include/log_reader_service.h?rev=1643720&r1=1643719&r2=1643720&view=diff
==============================================================================
--- celix/trunk/log_service/public/include/log_reader_service.h (original)
+++ celix/trunk/log_service/public/include/log_reader_service.h Sun Dec  7 21:32:18 2014
@@ -27,7 +27,7 @@
 #ifndef LOG_READER_SERVICE_H_
 #define LOG_READER_SERVICE_H_
 
-#include <apr_general.h>
+
 #include "celix_errno.h"
 #include "linked_list.h"
 #include "log_listener.h"
@@ -38,7 +38,7 @@ typedef struct log_reader_data * log_rea
 
 struct log_reader_service {
     log_reader_data_pt reader;
-    celix_status_t (*getLog)(log_reader_data_pt reader, apr_pool_t *memory_pool, linked_list_pt
*list);
+    celix_status_t (*getLog)(log_reader_data_pt reader, linked_list_pt *list);
     celix_status_t (*addLogListener)(log_reader_data_pt reader, log_listener_pt listener);
     celix_status_t (*removeLogListener)(log_reader_data_pt reader, log_listener_pt listener);
     celix_status_t (*removeAllLogListener)(log_reader_data_pt reader);

Modified: celix/trunk/shell/private/src/log_command.c
URL: http://svn.apache.org/viewvc/celix/trunk/shell/private/src/log_command.c?rev=1643720&r1=1643719&r2=1643720&view=diff
==============================================================================
--- celix/trunk/shell/private/src/log_command.c (original)
+++ celix/trunk/shell/private/src/log_command.c Sun Dec  7 21:32:18 2014
@@ -52,7 +52,6 @@ void logCommand_destroy(command_pt comma
 
 void logCommand_execute(command_pt command, char *line, void (*out)(char *), void (*err)(char
*)) {
     service_reference_pt readerService = NULL;
-    apr_pool_t *memory_pool = NULL;
 
     bundleContext_getServiceReference(command->bundleContext, (char *) OSGI_LOGSERVICE_READER_SERVICE_NAME,
&readerService);
     if (readerService != NULL) {
@@ -61,43 +60,39 @@ void logCommand_execute(command_pt comma
         linked_list_iterator_pt iter = NULL;
         log_reader_service_pt reader = NULL;
 
-        apr_pool_create(&memory_pool, NULL);
-        if (memory_pool) {
-            bundleContext_getService(command->bundleContext, readerService, (void **)
&reader);
-            reader->getLog(reader->reader, memory_pool, &list);
-            iter = linkedListIterator_create(list, 0);
-            while (linkedListIterator_hasNext(iter)) {
-                log_entry_pt entry = linkedListIterator_next(iter);
-                char time[20];
-                char *level = NULL;
-                module_pt module = NULL;
-                char *bundleSymbolicName = NULL;
-                char errorString[256];
-
-                celix_status_t status = bundle_getCurrentModule(entry->bundle, &module);
-                if (status == CELIX_SUCCESS) {
-                    status = module_getSymbolicName(module, &bundleSymbolicName);
-
-                    strftime(time, 20, "%Y-%m-%d %H:%M:%S", localtime(&entry->time));
-                    logCommand_levelAsString(command, entry->level, &level);
-
-                    if (entry->errorCode > 0) {
-                        celix_strerror(entry->errorCode, errorString, 256);
-                        sprintf(line, "%s - Bundle: %s - %s - %d %s\n", time, bundleSymbolicName,
entry->message, entry->errorCode, errorString);
-                        out(line);
-                    } else {
-                        sprintf(line, "%s - Bundle: %s - %s\n", time, bundleSymbolicName,
entry->message);
-                        out(line);
-                    }
-                }
-            }
-            linkedListIterator_destroy(iter);
-            bool result = true;
-            bundleContext_ungetService(command->bundleContext, readerService, &result);
-            apr_pool_destroy(memory_pool);
-        } else {
-            out("Log reader service: out of memory!\n");
-        }
+
+		bundleContext_getService(command->bundleContext, readerService, (void **) &reader);
+		reader->getLog(reader->reader, &list);
+		iter = linkedListIterator_create(list, 0);
+		while (linkedListIterator_hasNext(iter)) {
+			log_entry_pt entry = linkedListIterator_next(iter);
+			char time[20];
+			char *level = NULL;
+			module_pt module = NULL;
+			char *bundleSymbolicName = NULL;
+			char errorString[256];
+
+			celix_status_t status = bundle_getCurrentModule(entry->bundle, &module);
+			if (status == CELIX_SUCCESS) {
+				status = module_getSymbolicName(module, &bundleSymbolicName);
+
+				strftime(time, 20, "%Y-%m-%d %H:%M:%S", localtime(&entry->time));
+				logCommand_levelAsString(command, entry->level, &level);
+
+				if (entry->errorCode > 0) {
+					celix_strerror(entry->errorCode, errorString, 256);
+					sprintf(line, "%s - Bundle: %s - %s - %d %s\n", time, bundleSymbolicName, entry->message,
entry->errorCode, errorString);
+					out(line);
+				} else {
+					sprintf(line, "%s - Bundle: %s - %s\n", time, bundleSymbolicName, entry->message);
+					out(line);
+				}
+			}
+		}
+		linkedListIterator_destroy(iter);
+		bool result = true;
+		bundleContext_ungetService(command->bundleContext, readerService, &result);
+
         bundleContext_ungetServiceReference(command->bundleContext, readerService);
     } else {
         out("No log reader available\n");



Mime
View raw message