incubator-celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From abroekh...@apache.org
Subject svn commit: r1607050 - in /incubator/celix/trunk: examples/ examples/osgi-in-action/chapter01-greeting-example/client/ examples/osgi-in-action/chapter01-greeting-example/greeting/ examples/osgi-in-action/chapter04-correct-listener/ examples/osgi-in-act...
Date Tue, 01 Jul 2014 11:39:57 GMT
Author: abroekhuis
Date: Tue Jul  1 11:39:57 2014
New Revision: 1607050

URL: http://svn.apache.org/r1607050
Log:
CELIX-119: Fixed memory leaks and crashes due to incorrect reference removal.

Modified:
    incubator/celix/trunk/examples/CMakeLists.txt
    incubator/celix/trunk/examples/deploy.cmake
    incubator/celix/trunk/examples/osgi-in-action/chapter01-greeting-example/client/CMakeLists.txt
    incubator/celix/trunk/examples/osgi-in-action/chapter01-greeting-example/greeting/CMakeLists.txt
    incubator/celix/trunk/examples/osgi-in-action/chapter04-correct-listener/CMakeLists.txt
    incubator/celix/trunk/examples/osgi-in-action/chapter04-correct-listener/private/src/listener_example.c
    incubator/celix/trunk/examples/osgi-in-action/chapter04-correct-lookup/CMakeLists.txt
    incubator/celix/trunk/examples/osgi-in-action/chapter04-correct-lookup/private/src/activator.c
    incubator/celix/trunk/framework/private/mock/manifest_mock.c
    incubator/celix/trunk/framework/private/mock/wire_mock.c
    incubator/celix/trunk/framework/private/src/bundle_archive.c
    incubator/celix/trunk/framework/private/src/framework.c
    incubator/celix/trunk/framework/private/src/module.c
    incubator/celix/trunk/framework/private/src/service_registration.c
    incubator/celix/trunk/framework/private/src/service_registry.c
    incubator/celix/trunk/framework/public/include/manifest.h
    incubator/celix/trunk/remote_services/remote_service_admin_http/private/src/remote_service_admin_impl.c
    incubator/celix/trunk/shell/private/src/shell.c
    incubator/celix/trunk/shell_tui/private/src/shell_tui.c

Modified: incubator/celix/trunk/examples/CMakeLists.txt
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/examples/CMakeLists.txt?rev=1607050&r1=1607049&r2=1607050&view=diff
==============================================================================
--- incubator/celix/trunk/examples/CMakeLists.txt (original)
+++ incubator/celix/trunk/examples/CMakeLists.txt Tue Jul  1 11:39:57 2014
@@ -23,9 +23,9 @@ if (EXAMPLES)
     #add_subdirectory(whiteboard)
     #add_subdirectory(echo_service)
     
-    #add_subdirectory(osgi-in-action/chapter04-correct-lookup)
-    #add_subdirectory(osgi-in-action/chapter04-correct-listener)
-    #add_subdirectory(osgi-in-action/chapter01-greeting-example)
+    add_subdirectory(osgi-in-action/chapter04-correct-lookup)
+    add_subdirectory(osgi-in-action/chapter04-correct-listener)
+    add_subdirectory(osgi-in-action/chapter01-greeting-example)
     #add_subdirectory(osgi-in-action/chapter04-paint-example)
     
     #add_subdirectory(embedding)

Modified: incubator/celix/trunk/examples/deploy.cmake
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/examples/deploy.cmake?rev=1607050&r1=1607049&r2=1607050&view=diff
==============================================================================
--- incubator/celix/trunk/examples/deploy.cmake (original)
+++ incubator/celix/trunk/examples/deploy.cmake Tue Jul  1 11:39:57 2014
@@ -16,8 +16,8 @@
 # under the License.
 is_enabled(EXAMPLES)
 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(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 org.apache.incubator.celix.helloworld hello_world_test
log_service)
 	#deploy("wb" BUNDLES tracker publisherA publisherB shell shell_tui log_service log_writer)

Modified: incubator/celix/trunk/examples/osgi-in-action/chapter01-greeting-example/client/CMakeLists.txt
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/examples/osgi-in-action/chapter01-greeting-example/client/CMakeLists.txt?rev=1607050&r1=1607049&r2=1607050&view=diff
==============================================================================
--- incubator/celix/trunk/examples/osgi-in-action/chapter01-greeting-example/client/CMakeLists.txt
(original)
+++ incubator/celix/trunk/examples/osgi-in-action/chapter01-greeting-example/client/CMakeLists.txt
Tue Jul  1 11:39:57 2014
@@ -15,6 +15,9 @@
 # specific language governing permissions and limitations
 # under the License.
 
+SET(BUNDLE_SYMBOLICNAME "apache_celix_examples_chapter01_greeting_example_client")
+SET(BUNDLE_VERSION "0.0.1")
+
 bundle(chapter01-greeting-example-client SOURCES private/src/client)
 include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
 include_directories("../greeting/public/include")

Modified: incubator/celix/trunk/examples/osgi-in-action/chapter01-greeting-example/greeting/CMakeLists.txt
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/examples/osgi-in-action/chapter01-greeting-example/greeting/CMakeLists.txt?rev=1607050&r1=1607049&r2=1607050&view=diff
==============================================================================
--- incubator/celix/trunk/examples/osgi-in-action/chapter01-greeting-example/greeting/CMakeLists.txt
(original)
+++ incubator/celix/trunk/examples/osgi-in-action/chapter01-greeting-example/greeting/CMakeLists.txt
Tue Jul  1 11:39:57 2014
@@ -15,6 +15,9 @@
 # specific language governing permissions and limitations
 # under the License.
 
+SET(BUNDLE_SYMBOLICNAME "apache_celix_examples_chapter01_greeting_example")
+SET(BUNDLE_VERSION "0.0.1")
+
 bundle(chapter01-greeting-example SOURCES
     private/src/activator
     private/src/greeting_impl

Modified: incubator/celix/trunk/examples/osgi-in-action/chapter04-correct-listener/CMakeLists.txt
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/examples/osgi-in-action/chapter04-correct-listener/CMakeLists.txt?rev=1607050&r1=1607049&r2=1607050&view=diff
==============================================================================
--- incubator/celix/trunk/examples/osgi-in-action/chapter04-correct-listener/CMakeLists.txt
(original)
+++ incubator/celix/trunk/examples/osgi-in-action/chapter04-correct-listener/CMakeLists.txt
Tue Jul  1 11:39:57 2014
@@ -15,7 +15,9 @@
 # specific language governing permissions and limitations
 # under the License.
 
+SET(BUNDLE_SYMBOLICNAME "apache_celix_examples_chapter04_correct_listener")
+SET(BUNDLE_VERSION "0.0.1")
 bundle(chapter04-correct-listener SOURCES private/src/listener_example)
 include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
 include_directories("${PROJECT_SOURCE_DIR}/log_service/public/include")
-target_link_libraries(chapter04-correct-listener celix_framework)
+target_link_libraries(chapter04-correct-listener celix_framework ${APRUTIL_LIBRARY})

Modified: incubator/celix/trunk/examples/osgi-in-action/chapter04-correct-listener/private/src/listener_example.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/examples/osgi-in-action/chapter04-correct-listener/private/src/listener_example.c?rev=1607050&r1=1607049&r2=1607050&view=diff
==============================================================================
--- incubator/celix/trunk/examples/osgi-in-action/chapter04-correct-listener/private/src/listener_example.c
(original)
+++ incubator/celix/trunk/examples/osgi-in-action/chapter04-correct-listener/private/src/listener_example.c
Tue Jul  1 11:39:57 2014
@@ -26,6 +26,7 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <apr_general.h>
+#include <apr_thread_proc.h>
 
 #include "bundle_activator.h"
 #include "log_service.h"
@@ -100,7 +101,6 @@ celix_status_t bundleActivator_start(voi
 
 		listener->handle = activator;
 		listener->serviceChanged = (void *) listenerExample_serviceChanged;
-		listener->pool = pool;
 		status = bundleContext_addServiceListener(context, listener, filter);
 		if (status == CELIX_SUCCESS) {
 			activator->listener = listener;

Modified: incubator/celix/trunk/examples/osgi-in-action/chapter04-correct-lookup/CMakeLists.txt
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/examples/osgi-in-action/chapter04-correct-lookup/CMakeLists.txt?rev=1607050&r1=1607049&r2=1607050&view=diff
==============================================================================
--- incubator/celix/trunk/examples/osgi-in-action/chapter04-correct-lookup/CMakeLists.txt
(original)
+++ incubator/celix/trunk/examples/osgi-in-action/chapter04-correct-lookup/CMakeLists.txt
Tue Jul  1 11:39:57 2014
@@ -15,6 +15,9 @@
 # specific language governing permissions and limitations
 # under the License.
 
+SET(BUNDLE_SYMBOLICNAME "apache_celix_examples_chapter04_correct_lookup")
+SET(BUNDLE_VERSION "0.0.1")
+
 bundle(chapter04-correct-lookup SOURCES private/src/activator)
 include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
 include_directories("${PROJECT_SOURCE_DIR}/log_service/public/include")

Modified: incubator/celix/trunk/examples/osgi-in-action/chapter04-correct-lookup/private/src/activator.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/examples/osgi-in-action/chapter04-correct-lookup/private/src/activator.c?rev=1607050&r1=1607049&r2=1607050&view=diff
==============================================================================
--- incubator/celix/trunk/examples/osgi-in-action/chapter04-correct-lookup/private/src/activator.c
(original)
+++ incubator/celix/trunk/examples/osgi-in-action/chapter04-correct-lookup/private/src/activator.c
Tue Jul  1 11:39:57 2014
@@ -26,6 +26,8 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <apr_general.h>
+#include <apr_thread_proc.h>
+#include <apr_portable.h>
 
 #include "bundle_activator.h"
 #include "bundle_context.h"

Modified: incubator/celix/trunk/framework/private/mock/manifest_mock.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/mock/manifest_mock.c?rev=1607050&r1=1607049&r2=1607050&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/mock/manifest_mock.c (original)
+++ incubator/celix/trunk/framework/private/mock/manifest_mock.c Tue Jul  1 11:39:57 2014
@@ -40,6 +40,11 @@ celix_status_t manifest_createFromFile(c
 	return mock_c()->returnValue().value.intValue;
 }
 
+celix_status_t manifest_destroy(manifest_pt manifest) {
+    mock_c()->actualCall("manifest_destroy");
+    return mock_c()->returnValue().value.intValue;
+}
+
 void manifest_clear(manifest_pt manifest) {
 	mock_c()->actualCall("manifest_clear");
 }

Modified: incubator/celix/trunk/framework/private/mock/wire_mock.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/mock/wire_mock.c?rev=1607050&r1=1607049&r2=1607050&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/mock/wire_mock.c (original)
+++ incubator/celix/trunk/framework/private/mock/wire_mock.c Tue Jul  1 11:39:57 2014
@@ -33,6 +33,11 @@ celix_status_t wire_create(module_pt imp
 	return mock_c()->returnValue().value.intValue;
 }
 
+celix_status_t wire_destroy(wire_pt wire) {
+    mock_c()->actualCall("wire_destroy");
+    return mock_c()->returnValue().value.intValue;
+}
+
 celix_status_t wire_getCapability(wire_pt wire, capability_pt *capability) {
 	mock_c()->actualCall("requirement_create");
 	return mock_c()->returnValue().value.intValue;

Modified: incubator/celix/trunk/framework/private/src/bundle_archive.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/bundle_archive.c?rev=1607050&r1=1607049&r2=1607050&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/bundle_archive.c (original)
+++ incubator/celix/trunk/framework/private/src/bundle_archive.c Tue Jul  1 11:39:57 2014
@@ -707,7 +707,7 @@ static celix_status_t bundleArchive_dele
                 if (dp->d_type == DT_DIR) {
                     status = bundleArchive_deleteTree(archive, subdir);
                 } else {
-                    if (rmdir(subdir) != 0) {
+                    if (remove(subdir) != 0) {
                         status = CELIX_FILE_IO_EXCEPTION;
                         break;
                     }

Modified: incubator/celix/trunk/framework/private/src/framework.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/framework.c?rev=1607050&r1=1607049&r2=1607050&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/framework.c (original)
+++ incubator/celix/trunk/framework/private/src/framework.c Tue Jul  1 11:39:57 2014
@@ -1567,7 +1567,7 @@ void fw_serviceChanged(framework_pt fram
 
 				element->listener->serviceChanged(element->listener, event);
 
-				serviceReference_destroy(event->reference);
+//				serviceReference_destroy(event->reference);
 				free(event);
 				//TODO cleanup service reference
 

Modified: incubator/celix/trunk/framework/private/src/module.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/module.c?rev=1607050&r1=1607049&r2=1607050&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/module.c (original)
+++ incubator/celix/trunk/framework/private/src/module.c Tue Jul  1 11:39:57 2014
@@ -116,14 +116,16 @@ void module_destroy(module_pt module) {
 	linkedList_destroy(module->requirements);
 	version_destroy(module->version);
 
-	linked_list_iterator_pt iter = linkedListIterator_create(module->wires, 0);
-	while (linkedListIterator_hasNext(iter)) {
-	    wire_pt next = linkedListIterator_next(iter);
-	    linkedListIterator_remove(iter);
-	    wire_destroy(next);
+	if (module->wires != NULL) {
+        linked_list_iterator_pt iter = linkedListIterator_create(module->wires, 0);
+        while (linkedListIterator_hasNext(iter)) {
+            wire_pt next = linkedListIterator_next(iter);
+            linkedListIterator_remove(iter);
+            wire_destroy(next);
+        }
+        linkedListIterator_destroy(iter);
+        linkedList_destroy(module->wires);
 	}
-	linkedListIterator_destroy(iter);
-	linkedList_destroy(module->wires);
 
 	module->headerMap = NULL;
 

Modified: incubator/celix/trunk/framework/private/src/service_registration.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/service_registration.c?rev=1607050&r1=1607049&r2=1607050&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/service_registration.c (original)
+++ incubator/celix/trunk/framework/private/src/service_registration.c Tue Jul  1 11:39:57
2014
@@ -95,6 +95,7 @@ celix_status_t serviceRegistration_destr
 
 	celixThreadMutex_destroy(&registration->mutex);
 
+	registration = NULL;
 	free(registration);
 
 	return CELIX_SUCCESS;

Modified: incubator/celix/trunk/framework/private/src/service_registry.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/service_registry.c?rev=1607050&r1=1607049&r2=1607050&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/service_registry.c (original)
+++ incubator/celix/trunk/framework/private/src/service_registry.c Tue Jul  1 11:39:57 2014
@@ -444,6 +444,7 @@ celix_status_t serviceRegistry_ungetServ
 	if ((serviceRegistration_isValid(registration)) || (usage->count <= 0)) {
 		usage->service = NULL;
 		serviceRegistry_flushUsageCount(registry, bundle, reference);
+		serviceReference_destroy(reference);
 	}
 
 	celixThreadMutex_unlock(&registry->mutex);
@@ -476,7 +477,6 @@ void serviceRegistry_ungetServices(servi
 		while (ungetResult) {
 			serviceRegistry_ungetService(registry, bundle, reference, &ungetResult);
 		}
-		serviceReference_destroy(reference);
 	}
 
 	arrayList_destroy(fusages);

Modified: incubator/celix/trunk/framework/public/include/manifest.h
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/public/include/manifest.h?rev=1607050&r1=1607049&r2=1607050&view=diff
==============================================================================
--- incubator/celix/trunk/framework/public/include/manifest.h (original)
+++ incubator/celix/trunk/framework/public/include/manifest.h Tue Jul  1 11:39:57 2014
@@ -40,6 +40,7 @@ typedef struct manifest * manifest_pt;
 
 FRAMEWORK_EXPORT celix_status_t manifest_create(manifest_pt *manifest);
 FRAMEWORK_EXPORT celix_status_t manifest_createFromFile(char *filename, manifest_pt *manifest);
+FRAMEWORK_EXPORT celix_status_t manifest_destroy(manifest_pt manifest);
 
 FRAMEWORK_EXPORT void manifest_clear(manifest_pt manifest);
 FRAMEWORK_EXPORT properties_pt manifest_getMainAttributes(manifest_pt manifest);

Modified: incubator/celix/trunk/remote_services/remote_service_admin_http/private/src/remote_service_admin_impl.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/remote_services/remote_service_admin_http/private/src/remote_service_admin_impl.c?rev=1607050&r1=1607049&r2=1607050&view=diff
==============================================================================
--- incubator/celix/trunk/remote_services/remote_service_admin_http/private/src/remote_service_admin_impl.c
(original)
+++ incubator/celix/trunk/remote_services/remote_service_admin_http/private/src/remote_service_admin_impl.c
Tue Jul  1 11:39:57 2014
@@ -405,6 +405,9 @@ celix_status_t remoteServiceAdmin_create
 			(*description)->frameworkUUID = uuid;
 			(*description)->serviceId = apr_atoi64(properties_get(serviceProperties, (char *) OSGI_FRAMEWORK_SERVICE_ID));
 			(*description)->id = apr_pstrdup(childPool, "TODO"); // does not work, txt record to
big ?? --> apr_pstrcat(childPool, uuid, "-", (*description)->serviceId, NULL);
+//			char *id = apr_pstrcat(childPool, uuid, "-", properties_get(serviceProperties, (char
*) OSGI_FRAMEWORK_SERVICE_ID), NULL);
+//			printf("ID %s\n", id);
+//            (*description)->id = id;
 			(*description)->service = interface;
 		}
 	}

Modified: incubator/celix/trunk/shell/private/src/shell.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/shell/private/src/shell.c?rev=1607050&r1=1607049&r2=1607050&view=diff
==============================================================================
--- incubator/celix/trunk/shell/private/src/shell.c (original)
+++ incubator/celix/trunk/shell/private/src/shell.c Tue Jul  1 11:39:57 2014
@@ -170,7 +170,9 @@ void shell_addCommand(shell_pt shell, se
 void shell_removeCommand(shell_pt shell, service_reference_pt reference) {
 	command_service_pt command = (command_service_pt) hashMap_remove(shell->commandReferenceMap,
reference);
 	if (command != NULL) {
+	    bool result = false;
 		hashMap_remove(shell->commandNameMap, command->getName(command->command));
+		bundleContext_ungetService(shell->bundleContext, reference, &result);
 	}
 }
 
@@ -178,6 +180,8 @@ void shell_serviceChanged(service_listen
 	shell_pt shell = (shell_pt) listener->handle;
 	if (event->type == OSGI_FRAMEWORK_SERVICE_EVENT_REGISTERED) {
 		shell_addCommand(shell, event->reference);
+	} else if (event->type == OSGI_FRAMEWORK_SERVICE_EVENT_UNREGISTERING) {
+	    shell_removeCommand(shell, event->reference);
 	}
 }
 

Modified: incubator/celix/trunk/shell_tui/private/src/shell_tui.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/shell_tui/private/src/shell_tui.c?rev=1607050&r1=1607049&r2=1607050&view=diff
==============================================================================
--- incubator/celix/trunk/shell_tui/private/src/shell_tui.c (original)
+++ incubator/celix/trunk/shell_tui/private/src/shell_tui.c Tue Jul  1 11:39:57 2014
@@ -101,7 +101,6 @@ void shellTui_serviceChanged(service_lis
 		shellTui_initializeService(act);
 	} else if ((event->type == OSGI_FRAMEWORK_SERVICE_EVENT_UNREGISTERING) && (act->reference
== event->reference)) {
 		bundleContext_ungetService(act->context, act->reference, &result);
-        serviceReference_destroy(act->reference);
 		act->reference = NULL;
 		act->shell = NULL;
 



Mime
View raw message