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 2012/01/16 10:51:01 UTC
svn commit: r1231885 - in /incubator/celix/trunk: ./
examples/echo_service/client/ examples/whiteboard/tracker_depman/
framework/private/src/ utils/private/src/
Author: abroekhuis
Date: Mon Jan 16 09:51:01 2012
New Revision: 1231885
URL: http://svn.apache.org/viewvc?rev=1231885&view=rev
Log:
Linux compatibility
Tested source on linux and fixed several compiler warnings as well as memory leaks.
Modified:
incubator/celix/trunk/examples/echo_service/client/echo_client.c
incubator/celix/trunk/examples/whiteboard/tracker_depman/dependency_activator.c
incubator/celix/trunk/framework/private/src/bundle.c
incubator/celix/trunk/framework/private/src/bundle_archive.c
incubator/celix/trunk/framework/private/src/bundle_cache.c
incubator/celix/trunk/framework/private/src/framework.c
incubator/celix/trunk/framework/private/src/miniunz.c
incubator/celix/trunk/target.cmake
incubator/celix/trunk/utils/private/src/hash_map.c
Modified: incubator/celix/trunk/examples/echo_service/client/echo_client.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/examples/echo_service/client/echo_client.c?rev=1231885&r1=1231884&r2=1231885&view=diff
==============================================================================
--- incubator/celix/trunk/examples/echo_service/client/echo_client.c (original)
+++ incubator/celix/trunk/examples/echo_service/client/echo_client.c Mon Jan 16 09:51:01 2012
@@ -64,7 +64,7 @@ void echoClient_stop(ECHO_CLIENT client)
void echoClient_destroy(ECHO_CLIENT client) {
client->tracker = NULL;
- client->sender = NULL;
+ client->sender = 0;
free(client);
client = NULL;
}
Modified: incubator/celix/trunk/examples/whiteboard/tracker_depman/dependency_activator.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/examples/whiteboard/tracker_depman/dependency_activator.c?rev=1231885&r1=1231884&r2=1231885&view=diff
==============================================================================
--- incubator/celix/trunk/examples/whiteboard/tracker_depman/dependency_activator.c (original)
+++ incubator/celix/trunk/examples/whiteboard/tracker_depman/dependency_activator.c Mon Jan 16 09:51:01 2012
@@ -43,7 +43,7 @@ void * dm_create(BUNDLE_CONTEXT context)
arrayList_create(pool, &data->publishers);
data->context = NULL;
data->running = false;
- data->sender = NULL;
+ data->sender = 0;
data->service = NULL;
data->logger = NULL;
return data;
Modified: incubator/celix/trunk/framework/private/src/bundle.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/bundle.c?rev=1231885&r1=1231884&r2=1231885&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/bundle.c (original)
+++ incubator/celix/trunk/framework/private/src/bundle.c Mon Jan 16 09:51:01 2012
@@ -89,7 +89,7 @@ celix_status_t bundle_create(BUNDLE * bu
status = CELIX_ILLEGAL_STATE;
} else {
(*bundle)->lockCount = 0;
- (*bundle)->lockThread = NULL;
+ (*bundle)->lockThread = 0;
resolver_addModule(module);
@@ -129,7 +129,7 @@ celix_status_t bundle_createFromArchive(
status = CELIX_ILLEGAL_STATE;
} else {
(*bundle)->lockCount = 0;
- (*bundle)->lockThread = NULL;
+ (*bundle)->lockThread = 0;
resolver_addModule(module);
}
@@ -487,7 +487,7 @@ celix_status_t bundle_unlock(BUNDLE bund
}
bundle->lockCount--;
if (bundle->lockCount == 0) {
- bundle->lockThread = NULL;
+ bundle->lockThread = 0;
}
*unlocked = true;
}
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=1231885&r1=1231884&r2=1231885&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/bundle_archive.c (original)
+++ incubator/celix/trunk/framework/private/src/bundle_archive.c Mon Jan 16 09:51:01 2012
@@ -648,13 +648,15 @@ celix_status_t bundleArchive_initialize(
} else {
apr_file_t *bundleIdFile;
apr_status_t apr_status;
+ apr_pool_t *spool;
- char * bundleId = (char *)malloc(strlen(archive->archiveRoot) + 10);
- strcpy(bundleId, archive->archiveRoot);
- strcat(bundleId, "/bundle.id");
+ apr_pool_create(&spool, archive->mp);
+ char * bundleId = (char *)apr_palloc(spool, sizeof(*bundleId) * (strlen(archive->archiveRoot) + 11));
+ bundleId = apr_pstrcat(spool, archive->archiveRoot, "/bundle.id", NULL);
apr_status = apr_file_open(&bundleIdFile, bundleId, APR_FOPEN_CREATE|APR_FOPEN_WRITE, APR_OS_DEFAULT, archive->mp);
- free(bundleId);
+ apr_pool_destroy(spool);
+
if (apr_status != APR_SUCCESS) {
status = CELIX_FILE_IO_EXCEPTION;
} else {
@@ -664,7 +666,7 @@ celix_status_t bundleArchive_initialize(
// Ignore close status, let it fail if needed again
apr_file_close(bundleIdFile);
- bundleLocation = (char *)malloc(strlen(archive->archiveRoot) + 16);
+ bundleLocation = (char *)malloc(strlen(archive->archiveRoot) + 17);
strcpy(bundleLocation,archive->archiveRoot);
strcat(bundleLocation, "/bundle.location");
Modified: incubator/celix/trunk/framework/private/src/bundle_cache.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/bundle_cache.c?rev=1231885&r1=1231884&r2=1231885&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/bundle_cache.c (original)
+++ incubator/celix/trunk/framework/private/src/bundle_cache.c Mon Jan 16 09:51:01 2012
@@ -135,13 +135,13 @@ celix_status_t bundleCache_getArchives(B
celix_status_t bundleCache_createArchive(BUNDLE_CACHE cache, apr_pool_t *bundlePool, long id, char * location, char *inputFile, BUNDLE_ARCHIVE *bundle_archive) {
celix_status_t status;
- char archiveRoot[256];
+ char *archiveRoot;
BUNDLE_ARCHIVE archive;
if (cache && location && bundlePool) {
- sprintf(archiveRoot, "%s/bundle%ld", cache->cacheDir, id);
+ archiveRoot = apr_psprintf(bundlePool, "%s/bundle%ld", cache->cacheDir, id);
- status = bundleArchive_create(apr_pstrdup(cache->mp, archiveRoot), id, location, inputFile, bundlePool, bundle_archive);
+ status = bundleArchive_create(archiveRoot, id, location, inputFile, bundlePool, bundle_archive);
}
return status;
Modified: incubator/celix/trunk/framework/private/src/framework.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/framework.c?rev=1231885&r1=1231884&r2=1231885&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/framework.c (original)
+++ incubator/celix/trunk/framework/private/src/framework.c Mon Jan 16 09:51:01 2012
@@ -184,7 +184,7 @@ celix_status_t framework_create(FRAMEWOR
(*framework)->globalLockWaitersList = NULL;
arrayList_create((*framework)->mp, &(*framework)->globalLockWaitersList);
(*framework)->globalLockCount = 0;
- (*framework)->globalLockThread = NULL;
+ (*framework)->globalLockThread = 0;
(*framework)->nextBundleId = 1l;
(*framework)->cache = NULL;
@@ -889,6 +889,8 @@ celix_status_t fw_uninstallBundle(FRAMEW
celix_status_t refreshStatus = fw_refreshBundles(framework, bundles, 1);
if (refreshStatus != CELIX_SUCCESS) {
printf("Could not refresh bundle");
+ } else {
+ bundle_destroy(bundle);
}
framework_releaseGlobalLock(framework);
@@ -920,6 +922,9 @@ celix_status_t fw_refreshBundles(FRAMEWO
}
values = hashMapValues_create(map);
hashMapValues_toArray(values, (void *) &newTargets, &nrofvalues);
+ hashMapValues_destroy(values);
+
+ hashMap_destroy(map, false, false);
if (newTargets != NULL) {
int i = 0;
@@ -954,6 +959,7 @@ celix_status_t fw_refreshBundles(FRAMEWO
bundle_update(framework->bundle, NULL);
}
free(helpers);
+ free(newTargets);
}
framework_releaseGlobalLock(framework);
@@ -1034,6 +1040,7 @@ celix_status_t fw_getDependentBundles(FR
MODULE dependent = arrayList_get(dependents, depIdx);
arrayList_add(*list, module_getBundle(dependent));
}
+ arrayList_destroy(dependents);
}
} else {
status = CELIX_ILLEGAL_ARGUMENT;
@@ -1055,6 +1062,7 @@ celix_status_t fw_populateDependentGraph
fw_populateDependentGraph(framework, arrayList_get(dependents, depIdx), map);
}
}
+ arrayList_destroy(dependents);
}
} else {
status = CELIX_ILLEGAL_ARGUMENT;
@@ -1528,7 +1536,7 @@ celix_status_t framework_acquireBundleLo
celix_status_t status = CELIX_SUCCESS;
bool locked;
- apr_os_thread_t lockingThread = NULL;
+ apr_os_thread_t lockingThread = 0;
int err = apr_thread_mutex_lock(framework->bundleLock);
if (err != APR_SUCCESS) {
@@ -1542,7 +1550,7 @@ celix_status_t framework_acquireBundleLo
thread_equalsSelf(framework->globalLockThread, &isSelf);
while (!lockable
- || ((framework->globalLockThread != NULL)
+ || ((framework->globalLockThread != 0)
&& !isSelf)) {
BUNDLE_STATE state;
bundle_getState(bundle, &state);
@@ -1552,8 +1560,8 @@ celix_status_t framework_acquireBundleLo
} else
bundle_getLockingThread(bundle, &lockingThread);
if (isSelf
- && (lockingThread != NULL)
- && arrayList_contains(framework->globalLockWaitersList, lockingThread)) {
+ && (lockingThread != 0)
+ && arrayList_contains(framework->globalLockWaitersList, &lockingThread)) {
framework->interrupted = true;
// pthread_cond_signal_thread_np(&framework->condition, bundle_getLockingThread(bundle));
apr_thread_cond_signal(framework->condition);
@@ -1588,7 +1596,7 @@ celix_status_t framework_acquireBundleLo
bool framework_releaseBundleLock(FRAMEWORK framework, BUNDLE bundle) {
bool unlocked;
- apr_os_thread_t lockingThread = NULL;
+ apr_os_thread_t lockingThread = 0;
apr_thread_mutex_lock(framework->bundleLock);
@@ -1598,7 +1606,7 @@ bool framework_releaseBundleLock(FRAMEWO
return false;
}
bundle_getLockingThread(bundle, &lockingThread);
- if (lockingThread == NULL) {
+ if (lockingThread == 0) {
apr_thread_cond_broadcast(framework->condition);
}
@@ -1616,10 +1624,10 @@ bool framework_acquireGlobalLock(FRAMEWO
thread_equalsSelf(framework->globalLockThread, &isSelf);
while (!interrupted
- && (framework->globalLockThread != NULL)
+ && (framework->globalLockThread != 0)
&& (!isSelf)) {
apr_os_thread_t currentThread = apr_os_thread_current();
- arrayList_add(framework->globalLockWaitersList, currentThread);
+ arrayList_add(framework->globalLockWaitersList, ¤tThread);
apr_thread_cond_broadcast(framework->condition);
apr_thread_cond_wait(framework->condition, framework->bundleLock);
@@ -1628,7 +1636,7 @@ bool framework_acquireGlobalLock(FRAMEWO
framework->interrupted = false;
}
- arrayList_removeElement(framework->globalLockWaitersList, currentThread);
+ arrayList_removeElement(framework->globalLockWaitersList, ¤tThread);
}
if (!interrupted) {
@@ -1651,7 +1659,7 @@ celix_status_t framework_releaseGlobalLo
if (framework->globalLockThread == pthread_self()) {
framework->globalLockCount--;
if (framework->globalLockCount == 0) {
- framework->globalLockThread = NULL;
+ framework->globalLockThread = 0;
if (apr_thread_cond_broadcast(framework->condition) != 0) {
celix_log("Failed to broadcast global lock release.");
ret = CELIX_FRAMEWORK_EXCEPTION;
Modified: incubator/celix/trunk/framework/private/src/miniunz.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/miniunz.c?rev=1231885&r1=1231884&r2=1231885&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/miniunz.c (original)
+++ incubator/celix/trunk/framework/private/src/miniunz.c Mon Jan 16 09:51:01 2012
@@ -85,7 +85,7 @@ void change_file_date(filename,dosdate,t
SetFileTime(hFile,&ftm,&ftLastAcc,&ftm);
CloseHandle(hFile);
#else
-#ifdef unix || __APPLE__
+#if defined(unix) || defined(__APPLE__)
struct utimbuf ut;
struct tm newdate;
newdate.tm_sec = tmu_date.tm_sec;
Modified: incubator/celix/trunk/target.cmake
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/target.cmake?rev=1231885&r1=1231884&r2=1231885&view=diff
==============================================================================
--- incubator/celix/trunk/target.cmake (original)
+++ incubator/celix/trunk/target.cmake Mon Jan 16 09:51:01 2012
@@ -17,7 +17,7 @@
#deploy("name" BUNDLES receiver receiver-2.0 sender shell shell_tui)
#deploy("shell test" BUNDLES shell)
-deploy("hello_world" BUNDLES shell shell_tui hello_world log_service log_writer)
+deploy("hello_world" BUNDLES shell shell_tui hello_world log_service)
#deploy("deployer" BUNDLES shell shell_tui deployer)
#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)
Modified: incubator/celix/trunk/utils/private/src/hash_map.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/utils/private/src/hash_map.c?rev=1231885&r1=1231884&r2=1231885&view=diff
==============================================================================
--- incubator/celix/trunk/utils/private/src/hash_map.c (original)
+++ incubator/celix/trunk/utils/private/src/hash_map.c Mon Jan 16 09:51:01 2012
@@ -501,6 +501,7 @@ void hashMapValues_toArray(HASH_MAP_VALU
}
(*array)[i] = hashMapIterator_nextValue(it);
}
+ hashMapIterator_destroy(it);
}
bool hashMapValues_remove(HASH_MAP_VALUES values, void * value) {