celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bpe...@apache.org
Subject svn commit: r1643876 - in /celix/trunk: log_service/private/include/ log_service/private/src/ log_writer/log_writer/private/src/ shell/private/src/
Date Mon, 08 Dec 2014 18:17:38 GMT
Author: bpetri
Date: Mon Dec  8 18:17:38 2014
New Revision: 1643876

URL: http://svn.apache.org/r1643876
Log:
CELIX-119: fixed minor memory-leaks in log_service and log_writer

Modified:
    celix/trunk/log_service/private/include/log.h
    celix/trunk/log_service/private/include/log_factory.h
    celix/trunk/log_service/private/src/log.c
    celix/trunk/log_service/private/src/log_service_activator.c
    celix/trunk/log_writer/log_writer/private/src/log_writer.c
    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=1643876&r1=1643875&r2=1643876&view=diff
==============================================================================
--- celix/trunk/log_service/private/include/log.h (original)
+++ celix/trunk/log_service/private/include/log.h Mon Dec  8 18:17:38 2014
@@ -34,6 +34,7 @@
 typedef struct log * log_pt;
 
 celix_status_t log_create(log_pt *logger);
+celix_status_t log_destroy(log_pt logger);
 celix_status_t log_addEntry(log_pt log, log_entry_pt entry);
 celix_status_t log_getEntries(log_pt log, linked_list_pt *list);
 

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=1643876&r1=1643875&r2=1643876&view=diff
==============================================================================
--- celix/trunk/log_service/private/include/log_factory.h (original)
+++ celix/trunk/log_service/private/include/log_factory.h Mon Dec  8 18:17:38 2014
@@ -32,6 +32,7 @@
 typedef struct log_service_factory * log_service_factory_pt;
 
 celix_status_t logFactory_create(log_pt log, service_factory_pt *factory);
+celix_status_t logFactory_destroy(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/src/log.c
URL: http://svn.apache.org/viewvc/celix/trunk/log_service/private/src/log.c?rev=1643876&r1=1643875&r2=1643876&view=diff
==============================================================================
--- celix/trunk/log_service/private/src/log.c (original)
+++ celix/trunk/log_service/private/src/log.c Mon Dec  8 18:17:38 2014
@@ -85,23 +85,26 @@ celix_status_t log_create(log_pt *logger
 	return status;
 }
 
-celix_status_t log_destroy(void *logp) {
+celix_status_t log_destroy(log_pt logger) {
 	celix_status_t status = CELIX_SUCCESS;
-	log_pt log = logp;
 
-	celixThreadMutex_destroy(&log->listenerLock);
-	celixThreadMutex_destroy(&log->deliverLock);
+	celixThreadMutex_destroy(&logger->listenerLock);
+	celixThreadMutex_destroy(&logger->deliverLock);
 
-	arrayList_destroy(log->listenerEntries);
-	arrayList_destroy(log->listeners);
-	linked_list_iterator_pt iter = linkedListIterator_create(log->entries, 0);
+	arrayList_destroy(logger->listenerEntries);
+	arrayList_destroy(logger->listeners);
+	linked_list_iterator_pt iter = linkedListIterator_create(logger->entries, 0);
 	while (linkedListIterator_hasNext(iter)) {
 	    log_entry_pt entry = linkedListIterator_next(iter);
 	    logEntry_destroy(&entry);
 	}
-	linkedList_destroy(log->entries);
+	linkedListIterator_destroy(iter);
 
-	celixThreadMutex_destroy(&log->lock);
+	linkedList_destroy(logger->entries);
+
+	celixThreadMutex_destroy(&logger->lock);
+
+	free(logger);
 
 	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=1643876&r1=1643875&r2=1643876&view=diff
==============================================================================
--- celix/trunk/log_service/private/src/log_service_activator.c (original)
+++ celix/trunk/log_service/private/src/log_service_activator.c Mon Dec  8 18:17:38 2014
@@ -119,12 +119,15 @@ celix_status_t bundleActivator_stop(void
     logReaderService_destroy(&activator->reader);
 	free(activator->reader_service);
 
-	// logFactory_destroy(activator->factory);
+	logFactory_destroy(&activator->factory);
 
 	bundleContext_removeBundleListener(context, activator->bundleListener);
 	bundleContext_removeFrameworkListener(context, activator->frameworkListener);
 
-	// log_destroy(activator->logger);
+	free(activator->bundleListener);
+	free(activator->frameworkListener);
+
+	log_destroy(activator->logger);
 
     return CELIX_SUCCESS;
 }

Modified: celix/trunk/log_writer/log_writer/private/src/log_writer.c
URL: http://svn.apache.org/viewvc/celix/trunk/log_writer/log_writer/private/src/log_writer.c?rev=1643876&r1=1643875&r2=1643876&view=diff
==============================================================================
--- celix/trunk/log_writer/log_writer/private/src/log_writer.c (original)
+++ celix/trunk/log_writer/log_writer/private/src/log_writer.c Mon Dec  8 18:17:38 2014
@@ -78,7 +78,16 @@ celix_status_t logWriter_start(log_write
 }
 
 celix_status_t logWriter_stop(log_writer_pt writer) {
-	return serviceTracker_close(writer->tracker);
+	celix_status_t status = CELIX_SUCCESS;
+
+	if (serviceTracker_close(writer->tracker) != CELIX_SUCCESS) {
+		status = CELIX_BUNDLE_EXCEPTION;
+	}
+	if (serviceTracker_destroy(writer->tracker) != CELIX_SUCCESS) {
+		status = CELIX_BUNDLE_EXCEPTION;
+	}
+
+	return status;
 }
 
 celix_status_t logWriter_addingServ(void * handle, service_reference_pt ref, void **service)
{

Modified: celix/trunk/shell/private/src/log_command.c
URL: http://svn.apache.org/viewvc/celix/trunk/shell/private/src/log_command.c?rev=1643876&r1=1643875&r2=1643876&view=diff
==============================================================================
--- celix/trunk/shell/private/src/log_command.c (original)
+++ celix/trunk/shell/private/src/log_command.c Mon Dec  8 18:17:38 2014
@@ -90,9 +90,9 @@ void logCommand_execute(command_pt comma
 			}
 		}
 		linkedListIterator_destroy(iter);
+		linkedList_destroy(list);
 		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