Author: bpetri
Date: Tue Oct 28 07:10:01 2014
New Revision: 1634802
URL: http://svn.apache.org/r1634802
Log:
CELIX-174: minor memory leak bugfixing causing segfault when shutdown after
installing bundles via shell
Modified:
celix/trunk/framework/private/src/framework.c
celix/trunk/shell/private/src/install_command.c
Modified: celix/trunk/framework/private/src/framework.c
URL:
http://svn.apache.org/viewvc/celix/trunk/framework/private/src/framework.c?rev=1634802&r1=1634801&r2=1634802&view=diff
==============================================================================
--- celix/trunk/framework/private/src/framework.c (original)
+++ celix/trunk/framework/private/src/framework.c Tue Oct 28 07:10:01 2014
@@ -229,9 +229,6 @@ celix_status_t framework_destroy(framewo
bundle_pt bundle = (bundle_pt) hashMapEntry_getValue(entry);
bundle_archive_pt archive = NULL;
- if (bundle_getArchive(bundle, &archive) == CELIX_SUCCESS) {
- bundleArchive_destroy(archive);
- }
bool systemBundle = false;
bundle_isSystemBundle(bundle, &systemBundle);
if (systemBundle) {
@@ -239,8 +236,10 @@ celix_status_t framework_destroy(framewo
bundle_getContext(framework->bundle, &context);
bundleContext_destroy(context);
}
+ if (bundle_getArchive(bundle, &archive) == CELIX_SUCCESS) {
+ bundleArchive_destroy(archive);
+ }
bundle_destroy(bundle);
- hashMapIterator_remove(iterator);
}
hashMapIterator_destroy(iterator);
}
@@ -270,9 +269,11 @@ celix_status_t framework_destroy(framewo
arrayList_destroy(framework->requests);
}
if(framework->installedBundleMap!=NULL){
- hashMap_destroy(framework->installedBundleMap, false, false);
+ hashMap_destroy(framework->installedBundleMap, true, false);
}
+ free(framework);
+
return status;
}
@@ -346,7 +347,7 @@ celix_status_t fw_init(framework_pt fram
status = CELIX_DO_IF(status, bundle_getArchive(framework->bundle,
&archive));
status = CELIX_DO_IF(status, bundleArchive_getLocation(archive,
&location));
if (status == CELIX_SUCCESS) {
- hashMap_put(framework->installedBundleMap, location,
framework->bundle);
+ hashMap_put(framework->installedBundleMap, strdup(location),
framework->bundle);
}
status = CELIX_DO_IF(status, bundle_getCurrentModule(framework->bundle,
&module));
if (status == CELIX_SUCCESS) {
@@ -527,6 +528,7 @@ celix_status_t fw_installBundle2(framewo
if (archive == NULL) {
id = framework_getNextBundleId(framework);
+
status = CELIX_DO_IF(status,
bundleCache_createArchive(framework->cache, id, location, inputFile, &archive));
} else {
// purge revision
@@ -542,7 +544,7 @@ celix_status_t fw_installBundle2(framewo
framework_releaseGlobalLock(framework);
if (status == CELIX_SUCCESS) {
- hashMap_put(framework->installedBundleMap, location,
*bundle);
+ hashMap_put(framework->installedBundleMap,
strdup(location), *bundle);
} else {
status = CELIX_BUNDLE_EXCEPTION;
status = CELIX_DO_IF(status,
bundleArchive_closeAndDelete(archive));
@@ -550,6 +552,7 @@ celix_status_t fw_installBundle2(framewo
}
}
}
+
framework_releaseInstallLock(framework, location);
if (status != CELIX_SUCCESS) {
@@ -1980,6 +1983,8 @@ static void *framework_shutdown(void *fr
}
}
+ hashMapIterator_destroy(iter);
+
err = celixThreadMutex_lock(&fw->mutex);
if (err != 0) {
fw_log(fw->logger, OSGI_FRAMEWORK_LOG_ERROR, "Error locking
the framework, cannot exit clean.");
Modified: celix/trunk/shell/private/src/install_command.c
URL:
http://svn.apache.org/viewvc/celix/trunk/shell/private/src/install_command.c?rev=1634802&r1=1634801&r2=1634802&view=diff
==============================================================================
--- celix/trunk/shell/private/src/install_command.c (original)
+++ celix/trunk/shell/private/src/install_command.c Tue Oct 28 07:10:01 2014
@@ -69,7 +69,7 @@ void installCommand_execute(command_pt c
info[0] = '\0';
while (sub != NULL) {
bundle_pt bundle = NULL;
- installCommand_install(command, &bundle, strdup(sub),
out, err);
+ installCommand_install(command, &bundle, sub, out, err);
if (bundle != NULL) {
long id;
bundle_archive_pt archive = NULL;