celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From abroekh...@apache.org
Subject svn commit: r1655818 - in /celix/trunk/deployment_admin/private: include/ src/
Date Thu, 29 Jan 2015 19:23:22 GMT
Author: abroekhuis
Date: Thu Jan 29 19:23:22 2015
New Revision: 1655818

URL: http://svn.apache.org/r1655818
Log:
CELIX-206: Remove APR from the DeploymentAdmin

Modified:
    celix/trunk/deployment_admin/private/include/deployment_admin.h
    celix/trunk/deployment_admin/private/include/deployment_package.h
    celix/trunk/deployment_admin/private/include/log.h
    celix/trunk/deployment_admin/private/include/log_store.h
    celix/trunk/deployment_admin/private/include/log_sync.h
    celix/trunk/deployment_admin/private/src/deployment_admin.c
    celix/trunk/deployment_admin/private/src/deployment_admin_activator.c
    celix/trunk/deployment_admin/private/src/deployment_package.c
    celix/trunk/deployment_admin/private/src/log.c
    celix/trunk/deployment_admin/private/src/log_store.c
    celix/trunk/deployment_admin/private/src/log_sync.c

Modified: celix/trunk/deployment_admin/private/include/deployment_admin.h
URL: http://svn.apache.org/viewvc/celix/trunk/deployment_admin/private/include/deployment_admin.h?rev=1655818&r1=1655817&r2=1655818&view=diff
==============================================================================
--- celix/trunk/deployment_admin/private/include/deployment_admin.h (original)
+++ celix/trunk/deployment_admin/private/include/deployment_admin.h Thu Jan 29 19:23:22 2015
@@ -27,15 +27,12 @@
 #ifndef DEPLOYMENT_ADMIN_H_
 #define DEPLOYMENT_ADMIN_H_
 
-#include <apr_thread_proc.h>
-
 #include "bundle_context.h"
 
 typedef struct deployment_admin *deployment_admin_pt;
 
 struct deployment_admin {
-	apr_pool_t *pool;
-	apr_thread_t *poller;
+	celix_thread_t poller;
 	bundle_context_pt context;
 
 	bool running;
@@ -44,7 +41,7 @@ struct deployment_admin {
 	char *targetIdentification;
 	char *pollUrl;
 	char *auditlogUrl;
-	apr_time_t auditlogId;
+	unsigned long long auditlogId;
 	unsigned int aditlogSeqNr;
 };
 
@@ -52,7 +49,7 @@ typedef enum {
 	DEPLOYMENT_ADMIN_AUDIT_EVENT__FRAMEWORK_STARTED = 1005
 } DEPLOYMENT_ADMIN_AUDIT_EVENT;
 
-celix_status_t deploymentAdmin_create(apr_pool_t *pool, bundle_context_pt context, deployment_admin_pt
*admin);
+celix_status_t deploymentAdmin_create(bundle_context_pt context, deployment_admin_pt *admin);
 celix_status_t deploymentAdmin_destroy(deployment_admin_pt admin);
 
 #endif /* DEPLOYMENT_ADMIN_H_ */

Modified: celix/trunk/deployment_admin/private/include/deployment_package.h
URL: http://svn.apache.org/viewvc/celix/trunk/deployment_admin/private/include/deployment_package.h?rev=1655818&r1=1655817&r2=1655818&view=diff
==============================================================================
--- celix/trunk/deployment_admin/private/include/deployment_package.h (original)
+++ celix/trunk/deployment_admin/private/include/deployment_package.h Thu Jan 29 19:23:22
2015
@@ -27,8 +27,6 @@
 #ifndef DEPLOYMENT_PACKAGE_H_
 #define DEPLOYMENT_PACKAGE_H_
 
-#include <apr_general.h>
-
 #include "version.h"
 #include "bundle_context.h"
 
@@ -55,7 +53,6 @@ struct resource_info {
 typedef struct resource_info *resource_info_pt;
 
 struct deployment_package {
-	apr_pool_t *pool;
 	bundle_context_pt context;
 	manifest_pt manifest;
 	array_list_pt bundleInfos;
@@ -66,7 +63,7 @@ struct deployment_package {
 
 typedef struct deployment_package *deployment_package_pt;
 
-celix_status_t deploymentPackage_create(apr_pool_t *pool, bundle_context_pt context, manifest_pt
manifest, deployment_package_pt *package);
+celix_status_t deploymentPackage_create(bundle_context_pt context, manifest_pt manifest,
deployment_package_pt *package);
 celix_status_t deploymentPackage_destroy(deployment_package_pt package);
 celix_status_t deploymentPackage_getName(deployment_package_pt package, char **name);
 celix_status_t deploymentPackage_getBundleInfos(deployment_package_pt package, array_list_pt
*infos);

Modified: celix/trunk/deployment_admin/private/include/log.h
URL: http://svn.apache.org/viewvc/celix/trunk/deployment_admin/private/include/log.h?rev=1655818&r1=1655817&r2=1655818&view=diff
==============================================================================
--- celix/trunk/deployment_admin/private/include/log.h (original)
+++ celix/trunk/deployment_admin/private/include/log.h Thu Jan 29 19:23:22 2015
@@ -27,8 +27,6 @@
 #ifndef LOG_H_
 #define LOG_H_
 
-#include <apr_general.h>
-
 #include "log_event.h"
 #include "log_store.h"
 
@@ -37,7 +35,7 @@
 
 typedef struct log *log_pt;
 
-celix_status_t log_create(apr_pool_t *pool, log_store_pt store, log_pt *log);
+celix_status_t log_create(log_store_pt store, log_pt *log);
 celix_status_t log_log(log_pt log, unsigned int type, properties_pt properties);
 
 celix_status_t log_bundleChanged(void * listener, bundle_event_pt event);

Modified: celix/trunk/deployment_admin/private/include/log_store.h
URL: http://svn.apache.org/viewvc/celix/trunk/deployment_admin/private/include/log_store.h?rev=1655818&r1=1655817&r2=1655818&view=diff
==============================================================================
--- celix/trunk/deployment_admin/private/include/log_store.h (original)
+++ celix/trunk/deployment_admin/private/include/log_store.h Thu Jan 29 19:23:22 2015
@@ -34,7 +34,7 @@
 
 typedef struct log_store *log_store_pt;
 
-celix_status_t logStore_create(apr_pool_t *pool, log_store_pt *store);
+celix_status_t logStore_create(log_store_pt *store);
 celix_status_t logStore_put(log_store_pt store, unsigned int type, properties_pt properties,
log_event_pt *event);
 
 celix_status_t logStore_getLogId(log_store_pt store, unsigned long *id);

Modified: celix/trunk/deployment_admin/private/include/log_sync.h
URL: http://svn.apache.org/viewvc/celix/trunk/deployment_admin/private/include/log_sync.h?rev=1655818&r1=1655817&r2=1655818&view=diff
==============================================================================
--- celix/trunk/deployment_admin/private/include/log_sync.h (original)
+++ celix/trunk/deployment_admin/private/include/log_sync.h Thu Jan 29 19:23:22 2015
@@ -31,6 +31,6 @@
 
 typedef struct log_sync *log_sync_pt;
 
-celix_status_t logSync_create(apr_pool_t *pool, char *targetId, log_store_pt store, log_sync_pt
*logSync);
+celix_status_t logSync_create(char *targetId, log_store_pt store, log_sync_pt *logSync);
 
 #endif /* LOG_SYNC_H_ */

Modified: celix/trunk/deployment_admin/private/src/deployment_admin.c
URL: http://svn.apache.org/viewvc/celix/trunk/deployment_admin/private/src/deployment_admin.c?rev=1655818&r1=1655817&r2=1655818&view=diff
==============================================================================
--- celix/trunk/deployment_admin/private/src/deployment_admin.c (original)
+++ celix/trunk/deployment_admin/private/src/deployment_admin.c Thu Jan 29 19:23:22 2015
@@ -30,14 +30,14 @@
 #include <unistd.h>
 #include <string.h>
 
+#include <dirent.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
 #include <curl/curl.h>
 #include <curl/easy.h>
 
-#include <apr.h>
-#include <apr_thread_proc.h>
-#include <apr_strings.h>
-#include <apr_time.h>
-#include <apr_uuid.h>
+#include <uuid/uuid.h>
 
 #include "celixbool.h"
 #include "deployment_admin.h"
@@ -61,10 +61,10 @@
 
 #define VERSIONS "/versions"
 
-static void* APR_THREAD_FUNC deploymentAdmin_poll(apr_thread_t *thd, void *deploymentAdmin);
+static void* deploymentAdmin_poll(void *deploymentAdmin);
 celix_status_t deploymentAdmin_download(char * url, char **inputFile);
 size_t deploymentAdmin_writeData(void *ptr, size_t size, size_t nmemb, FILE *stream);
-static celix_status_t deploymentAdmin_deleteTree(char * directory, apr_pool_t *mp);
+static celix_status_t deploymentAdmin_deleteTree(char * directory);
 celix_status_t deploymentAdmin_readVersions(deployment_admin_pt admin, array_list_pt *versions);
 
 celix_status_t deploymentAdmin_stopDeploymentPackageBundles(deployment_admin_pt admin, deployment_package_pt
target);
@@ -76,16 +76,13 @@ celix_status_t deploymentAdmin_dropDeplo
 celix_status_t deploymentAdmin_startDeploymentPackageBundles(deployment_admin_pt admin, deployment_package_pt
source);
 static celix_status_t deploymentAdmin_updateAuditPool(deployment_admin_pt admin, DEPLOYMENT_ADMIN_AUDIT_EVENT
auditEvent);
 
-celix_status_t deploymentAdmin_create(apr_pool_t *pool, bundle_context_pt context, deployment_admin_pt
*admin) {
+celix_status_t deploymentAdmin_create(bundle_context_pt context, deployment_admin_pt *admin)
{
 	celix_status_t status = CELIX_SUCCESS;
-	apr_pool_t *subpool;
-	apr_pool_create(&subpool, pool);
 
-	*admin = apr_palloc(subpool, sizeof(**admin));
+	*admin = calloc(1, sizeof(**admin));
 	if (!*admin) {
 		status = CELIX_ENOMEM;
 	} else {
-		(*admin)->pool = subpool;
 		(*admin)->running = true;
 		(*admin)->context = context;
 		(*admin)->current = NULL;
@@ -95,7 +92,10 @@ celix_status_t deploymentAdmin_create(ap
 		(*admin)->auditlogUrl = NULL;
 
         bundleContext_getProperty(context, IDENTIFICATION_ID, &(*admin)->targetIdentification);
-        (*admin)->auditlogId = apr_time_now();
+
+        struct timeval tv;
+		gettimeofday(&tv,NULL);
+		(*admin)->auditlogId =  tv.tv_sec*(uint64_t)1000000+tv.tv_usec;
         (*admin)->aditlogSeqNr = 0;
 
 		if ((*admin)->targetIdentification == NULL ) {
@@ -108,8 +108,17 @@ celix_status_t deploymentAdmin_create(ap
 			    fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "URL must be set using \"deployment_admin_url\"\n");
 				status = CELIX_ILLEGAL_ARGUMENT;
 			} else {
-				(*admin)->pollUrl = apr_pstrcat(subpool, url, "/deployment/", (*admin)->targetIdentification,
VERSIONS, NULL);
-				(*admin)->auditlogUrl = apr_pstrcat(subpool, url, "/auditlog", NULL);
+				int pollUrlLength = strlen(url) + strlen((*admin)->targetIdentification) + strlen(VERSIONS)
+ 13;
+				int auditlogUrlLength = strlen(url) + 10;
+
+				char pollUrl[pollUrlLength];
+				char auditlogUrl[auditlogUrlLength];
+
+				snprintf(pollUrl, pollUrlLength, "%s/deployment/%s%s", url, (*admin)->targetIdentification,
VERSIONS);
+				snprintf(auditlogUrl, auditlogUrlLength, "%s/auditlog", url);
+
+				(*admin)->pollUrl = strdup(pollUrl);
+				(*admin)->auditlogUrl = strdup(auditlogUrl);
 
 //				log_store_pt store = NULL;
 //				log_pt log = NULL;
@@ -121,7 +130,7 @@ celix_status_t deploymentAdmin_create(ap
 //				log_log(log, 20000, NULL);
 
 
-				apr_thread_create(&(*admin)->poller, NULL, deploymentAdmin_poll, *admin, subpool);
+				celixThread_create(&(*admin)->poller, NULL, deploymentAdmin_poll, *admin);
 			}
 		}
 	}
@@ -149,6 +158,11 @@ celix_status_t deploymentAdmin_destroy(d
 		free(admin->current);
 	}
 
+	free(admin->pollUrl);
+	free(admin->auditlogUrl);
+
+	free(admin);
+
 	return status;
 }
 
@@ -169,7 +183,7 @@ static celix_status_t deploymentAdmin_up
 	char url[strlen(admin->auditlogUrl)+6];
 	sprintf(url, "%s/send", admin->auditlogUrl);
 	char entry[512];
-	int entrySize = snprintf(entry, 512, "%s,%lld,%u,0,%i\n", admin->targetIdentification,
admin->auditlogId, admin->aditlogSeqNr++, auditEvent);
+	int entrySize = snprintf(entry, 512, "%s,%llu,%u,0,%i\n", admin->targetIdentification,
admin->auditlogId, admin->aditlogSeqNr++, auditEvent);
 	if (entrySize >= 512) {
 		status = CELIX_BUNDLE_EXCEPTION;
 		fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "Error, entry buffer is too small");
@@ -189,7 +203,7 @@ static celix_status_t deploymentAdmin_up
 	return status;
 }
 
-static void * APR_THREAD_FUNC deploymentAdmin_poll(apr_thread_t *thd, void *deploymentAdmin)
{
+static void *deploymentAdmin_poll(void *deploymentAdmin) {
 	deployment_admin_pt admin = deploymentAdmin;
 
 	/*first poll send framework started audit event, note this will register the target in Apache
ACE*/
@@ -204,13 +218,16 @@ static void * APR_THREAD_FUNC deployment
 
 		if (last != NULL) {
 			if (admin->current == NULL || strcmp(last, admin->current) > 0) {
-				char *request = NULL;
+				int length = strlen(admin->pollUrl) + strlen(last) + 2;
+				char request[length];
 				if (admin->current == NULL) {
-					request = apr_pstrcat(admin->pool, admin->pollUrl, "/", last, NULL);
+					snprintf(request, length, "%s/%s", admin->pollUrl, last);
 				} else {
-					// We do not yet support fix packages
-					//request = apr_pstrcat(admin->pool, VERSIONS, "/", last, "?current=", admin->current,
NULL);
-					request = apr_pstrcat(admin->pool, admin->pollUrl, "/", last, NULL);
+					// TODO
+					//      We do not yet support fix packages
+					//		Check string lenght!
+					// snprintf(request, length, "%s/%s?current=%s", admin->pollUrl, last, admin->current);
+					snprintf(request, length, "%s/%s", admin->pollUrl, last);
 				}
 
 				char *inputFilename = NULL;
@@ -223,29 +240,36 @@ static void * APR_THREAD_FUNC deployment
 
 					// Handle file
 					char tmpDir[256];
-					char uuidStr[128];
-                    apr_uuid_t tmpUuid;
-                    apr_uuid_get(&tmpUuid);
-                    apr_uuid_format(uuidStr, &tmpUuid);
-                    sprintf(tmpDir, "%s%s", entry, uuidStr);
-					apr_dir_make(tmpDir, APR_UREAD|APR_UWRITE|APR_UEXECUTE, admin->pool);
+					char uuid[37];
+					uuid_t uid;
+					uuid_generate(uid);
+					uuid_unparse(uid, uuid);
+                    snprintf(tmpDir, 256, "%s%s", entry, uuid);
+                    mkdir(tmpDir, S_IRWXU);
 
 					// TODO: update to use bundle cache DataFile instead of module entries.
 					unzip_extractDeploymentPackage(inputFilename, tmpDir);
-					char *manifest = apr_pstrcat(admin->pool, tmpDir, "/META-INF/MANIFEST.MF", NULL);
+					int length = strlen(tmpDir + 22);
+					char manifest[length];
+					snprintf(manifest, length, "%s/META-INF/MANIFEST.MF", tmpDir);
 					manifest_pt mf = NULL;
 					manifest_createFromFile(manifest, &mf);
 					deployment_package_pt source = NULL;
-					deploymentPackage_create(admin->pool, admin->context, mf, &source);
+					deploymentPackage_create(admin->context, mf, &source);
 					char *name = NULL;
 					deploymentPackage_getName(source, &name);
 
-					char *repoDir = apr_pstrcat(admin->pool, entry, "repo", NULL);
-					apr_dir_make(repoDir, APR_UREAD|APR_UWRITE|APR_UEXECUTE, admin->pool);
-					char *repoCache = apr_pstrcat(admin->pool, entry, "repo/", name, NULL);
-					deploymentAdmin_deleteTree(repoCache, admin->pool);
-					apr_status_t stat = apr_file_rename(tmpDir, repoCache, admin->pool);
-					if (stat != APR_SUCCESS) {
+					int repoDirLength = strlen(entry) + 5;
+					char repoDir[repoDirLength];
+					snprintf(repoDir, repoDirLength, "%srepo", entry);
+					mkdir(repoDir, S_IRWXU);
+
+					int repoCacheLength = strlen(entry) + strlen(name) + 6;
+					char repoCache[repoCacheLength];
+					snprintf(repoCache, repoCacheLength, "%srepo/%s", entry, name);
+					deploymentAdmin_deleteTree(repoCache);
+					int stat = rename(tmpDir, repoCache);
+					if (stat != 0) {
 						fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "No success");
 					}
 
@@ -262,8 +286,8 @@ static void * APR_THREAD_FUNC deployment
 					deploymentAdmin_dropDeploymentPackageBundles(admin, source, target);
 					deploymentAdmin_startDeploymentPackageBundles(admin, source);
 
-					deploymentAdmin_deleteTree(repoCache, admin->pool);
-					deploymentAdmin_deleteTree(tmpDir, admin->pool);
+					deploymentAdmin_deleteTree(repoCache);
+					deploymentAdmin_deleteTree(tmpDir);
 					remove(inputFilename);
 					admin->current = strdup(last);
 					hashMap_put(admin->packages, name, source);
@@ -276,7 +300,7 @@ static void * APR_THREAD_FUNC deployment
 		sleep(5);
 	}
 
-	apr_thread_exit(thd, APR_SUCCESS);
+	celixThread_exit(NULL);
 	return NULL;
 }
 
@@ -325,10 +349,10 @@ celix_status_t deploymentAdmin_readVersi
 		curl_easy_cleanup(curl);
 
 		char *last;
-		char *token = apr_strtok(chunk.memory, "\n", &last);
+		char *token = strtok_r(chunk.memory, "\n", &last);
 		while (token != NULL) {
-			arrayList_add(*versions, apr_pstrdup(admin->pool, token));
-			token = apr_strtok(NULL, "\n", &last);
+			arrayList_add(*versions, strdup(token));
+			token = strtok_r(NULL, "\n", &last);
 		}
 	}
 
@@ -378,35 +402,43 @@ size_t deploymentAdmin_writeData(void *p
     return written;
 }
 
-static celix_status_t deploymentAdmin_deleteTree(char * directory, apr_pool_t *mp) {
-    celix_status_t status = CELIX_SUCCESS;
-	apr_dir_t *dir;
-
-	if (directory && mp) {
-        if (apr_dir_open(&dir, directory, mp) == APR_SUCCESS) {
-            apr_finfo_t dp;
-            while ((apr_dir_read(&dp, APR_FINFO_DIRENT|APR_FINFO_TYPE, dir)) == APR_SUCCESS)
{
-                if ((strcmp((dp.name), ".") != 0) && (strcmp((dp.name), "..") !=
0)) {
-                    char subdir[strlen(directory) + strlen(dp.name) + 2];
-                    strcpy(subdir, directory);
-                    strcat(subdir, "/");
-                    strcat(subdir, dp.name);
-
-                    if (dp.filetype == APR_DIR) {
-                    	deploymentAdmin_deleteTree(subdir, mp);
-                    } else {
-                        remove(subdir);
+
+static celix_status_t deploymentAdmin_deleteTree(char * directory) {
+	DIR *dir;
+	celix_status_t status = CELIX_SUCCESS;
+	dir = opendir(directory);
+	if (dir == NULL) {
+	    status = CELIX_FILE_IO_EXCEPTION;
+	} else {
+		struct dirent *dp;
+		while ((dp = readdir(dir)) != NULL) {
+		    if ((strcmp((dp->d_name), ".") != 0) && (strcmp((dp->d_name), "..") !=
0)) {
+                char subdir[512];
+                snprintf(subdir, sizeof(subdir), "%s/%s", directory, dp->d_name);
+
+                if (dp->d_type == DT_DIR) {
+                    status = deploymentAdmin_deleteTree(subdir);
+                } else {
+                    if (remove(subdir) != 0) {
+                        status = CELIX_FILE_IO_EXCEPTION;
+                        break;
                     }
                 }
-            }
-            remove(directory);
-        } else {
-            status = CELIX_FILE_IO_EXCEPTION;
-        }
-	} else {
-	    status = CELIX_ILLEGAL_ARGUMENT;
+		    }
+		}
+
+		if (closedir(dir) != 0) {
+			status = CELIX_FILE_IO_EXCEPTION;
+		}
+		if (status == CELIX_SUCCESS) {
+            if (rmdir(directory) != 0) {
+				status = CELIX_FILE_IO_EXCEPTION;
+			}
+		}
 	}
 
+	framework_logIfError(logger, status, NULL, "Failed to delete tree");
+
 	return status;
 }
 
@@ -447,8 +479,15 @@ celix_status_t deploymentAdmin_updateDep
 		bundle_getEntry(bundle, "/", &entry);
 		char *name = NULL;
 		deploymentPackage_getName(source, &name);
-		char *bundlePath = apr_pstrcat(admin->pool, entry, "repo/", name, "/", info->path,
NULL);
-		char *bsn = apr_pstrcat(admin->pool, "osgi-dp:", info->symbolicName, NULL);
+
+		int bundlePathLength = strlen(entry) + strlen(name) + strlen(info->path) + 7;
+		int bsnLength = strlen(info->symbolicName) + 9;
+
+		char bundlePath[bundlePathLength];
+		snprintf(bundlePath, bundlePathLength, "%srepo/%s/%s", entry, name, info->path);
+
+		char bsn[bsnLength];
+		snprintf(bsn, bsnLength, "osgi-dp:%s", info->symbolicName);
 
 		bundle_pt updateBundle = NULL;
 		deploymentPackage_getBundle(source, info->symbolicName, &updateBundle);
@@ -516,12 +555,11 @@ celix_status_t deploymentAdmin_processDe
 	int i;
 	for (i = 0; i < arrayList_size(infos); i++) {
 		resource_info_pt info = arrayList_get(infos, i);
-		apr_pool_t *tmpPool = NULL;
 		array_list_pt services = NULL;
-		char *filter = NULL;
+		int length = strlen(OSGI_FRAMEWORK_SERVICE_PID) + strlen(info->resourceProcessor) +
4;
+		char filter[length];
 
-		apr_pool_create(&tmpPool, admin->pool);
-		filter = apr_pstrcat(tmpPool, "(", OSGI_FRAMEWORK_SERVICE_PID, "=", info->resourceProcessor,
")", NULL);
+		snprintf(filter, length, "(%s=%s)", OSGI_FRAMEWORK_SERVICE_PID, info->resourceProcessor);
 
 		status = bundleContext_getServiceReferences(admin->context, DEPLOYMENTADMIN_RESOURCE_PROCESSOR_SERVICE,
filter, &services);
 		if (status == CELIX_SUCCESS) {
@@ -542,7 +580,9 @@ celix_status_t deploymentAdmin_processDe
 					bundle_getEntry(bundle, "/", &entry);
 					deploymentPackage_getName(source, &name);
 
-					char *resourcePath = apr_pstrcat(admin->pool, entry, "repo/", name, "/", info->path,
NULL);
+					int length = strlen(entry) + strlen(name) + strlen(info->path) + 7;
+					char resourcePath[length];
+					snprintf(resourcePath, length, "%srepo/%s/%s", entry, name, info->path, NULL);
 					deploymentPackage_getName(source, &packageName);
 
 					processor->begin(processor->processor, packageName);
@@ -573,14 +613,11 @@ celix_status_t deploymentAdmin_dropDeplo
 			resource_info_pt sourceInfo = NULL;
 			deploymentPackage_getResourceInfoByPath(source, info->path, &sourceInfo);
 			if (sourceInfo == NULL) {
-				apr_pool_t *tmpPool = NULL;
 				array_list_pt services = NULL;
-				char *filter = NULL;
-
-
-				apr_pool_create(&tmpPool, admin->pool);
-				filter = apr_pstrcat(tmpPool, "(", OSGI_FRAMEWORK_SERVICE_PID, "=", info->resourceProcessor,
")", NULL);
+				int length = strlen(OSGI_FRAMEWORK_SERVICE_PID) + strlen(info->resourceProcessor)
+ 4;
+				char filter[length];
 
+				snprintf(filter, length, "(%s=%s)", OSGI_FRAMEWORK_SERVICE_PID, info->resourceProcessor);
 				status = bundleContext_getServiceReferences(admin->context, DEPLOYMENTADMIN_RESOURCE_PROCESSOR_SERVICE,
filter, &services);
 				if (status == CELIX_SUCCESS) {
 					if (services != NULL && arrayList_size(services) > 0) {

Modified: celix/trunk/deployment_admin/private/src/deployment_admin_activator.c
URL: http://svn.apache.org/viewvc/celix/trunk/deployment_admin/private/src/deployment_admin_activator.c?rev=1655818&r1=1655817&r2=1655818&view=diff
==============================================================================
--- celix/trunk/deployment_admin/private/src/deployment_admin_activator.c (original)
+++ celix/trunk/deployment_admin/private/src/deployment_admin_activator.c Thu Jan 29 19:23:22
2015
@@ -29,7 +29,6 @@
 #include "deployment_admin.h"
 
 struct bundle_activator {
-	apr_pool_t *pool;
 	deployment_admin_pt admin;
 };
 
@@ -38,26 +37,15 @@ typedef struct bundle_activator* bundle_
 celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
 	celix_status_t status = CELIX_SUCCESS;
 
-	apr_pool_t *parentPool = NULL;
-	apr_pool_t *pool = NULL;
 	bundle_activator_pt activator = NULL;
 
-	status = bundleContext_getMemoryPool(context, &parentPool);
-	if (status == CELIX_SUCCESS) {
-		if (apr_pool_create(&pool, parentPool) != APR_SUCCESS) {
-			status = CELIX_BUNDLE_EXCEPTION;
-		} else {
-			activator = apr_palloc(pool, sizeof(*activator));
-			if (!activator) {
-				status = CELIX_ENOMEM;
-			} else {
-				activator->pool = pool;
-
-				status = deploymentAdmin_create(pool, context, &activator->admin);
-
-				*userData = activator;
-			}
-		}
+	activator = calloc(1, sizeof(*activator));
+	if (!activator) {
+		status = CELIX_ENOMEM;
+	} else {
+		status = deploymentAdmin_create(context, &activator->admin);
+
+		*userData = activator;
 	}
 
 	return status;
@@ -82,6 +70,8 @@ celix_status_t bundleActivator_destroy(v
 
 	status = deploymentAdmin_destroy(activator->admin);
 
+	free(activator);
+
 	return status;
 }
 

Modified: celix/trunk/deployment_admin/private/src/deployment_package.c
URL: http://svn.apache.org/viewvc/celix/trunk/deployment_admin/private/src/deployment_package.c?rev=1655818&r1=1655817&r2=1655818&view=diff
==============================================================================
--- celix/trunk/deployment_admin/private/src/deployment_package.c (original)
+++ celix/trunk/deployment_admin/private/src/deployment_package.c Thu Jan 29 19:23:22 2015
@@ -41,14 +41,13 @@ celix_status_t deploymentPackage_process
 static celix_status_t deploymentPackage_isBundleResource(properties_pt attributes, bool *isBundleResource);
 static celix_status_t deploymentPackage_parseBooleanHeader(char *value, bool *boolValue);
 
-celix_status_t deploymentPackage_create(apr_pool_t *pool, bundle_context_pt context, manifest_pt
manifest, deployment_package_pt *package) {
+celix_status_t deploymentPackage_create(bundle_context_pt context, manifest_pt manifest,
deployment_package_pt *package) {
 	celix_status_t status = CELIX_SUCCESS;
 
-	*package = apr_palloc(pool, sizeof(**package));
+	*package = calloc(1, sizeof(**package));
 	if (!package) {
 		status = CELIX_ENOMEM;
 	} else {
-		(*package)->pool = pool;
 		(*package)->context = context;
 		(*package)->manifest = manifest;
 		(*package)->bundleInfos = NULL;
@@ -87,6 +86,8 @@ celix_status_t deploymentPackage_destroy
 	arrayList_destroy(package->bundleInfos);
 	arrayList_destroy(package->resourceInfos);
 
+	free(package);
+
 	return status;
 }
 
@@ -155,7 +156,7 @@ celix_status_t deploymentPackage_process
 		bool isBundleResource;
 		deploymentPackage_isBundleResource(values, &isBundleResource);
 		if (isBundleResource) {
-			bundle_info_pt info = apr_palloc(package->pool, sizeof(*info));
+			bundle_info_pt info = calloc(1, sizeof(*info));
 			info->path = name;
 			info->attributes = values;
 			info->symbolicName = properties_get(values, (char *) OSGI_FRAMEWORK_BUNDLE_SYMBOLICNAME);
@@ -167,7 +168,7 @@ celix_status_t deploymentPackage_process
 
 			arrayList_add(package->bundleInfos, info);
 		} else {
-			resource_info_pt info = apr_palloc(package->pool, sizeof(*info));
+			resource_info_pt info = calloc(1, sizeof(*info));
 			info->path = name;
 			info->attributes = values;
 			info->resourceProcessor = properties_get(values, (char *) RESOURCE_PROCESSOR);

Modified: celix/trunk/deployment_admin/private/src/log.c
URL: http://svn.apache.org/viewvc/celix/trunk/deployment_admin/private/src/log.c?rev=1655818&r1=1655817&r2=1655818&view=diff
==============================================================================
--- celix/trunk/deployment_admin/private/src/log.c (original)
+++ celix/trunk/deployment_admin/private/src/log.c Thu Jan 29 19:23:22 2015
@@ -25,7 +25,7 @@
  */
 
 #include <stddef.h>
-#include <apr_general.h>
+#include <stdlib.h>
 
 #include "celix_errno.h"
 
@@ -36,10 +36,10 @@ struct log {
 	log_store_pt logStore;
 };
 
-celix_status_t log_create(apr_pool_t *pool, log_store_pt store, log_pt *log) {
+celix_status_t log_create(log_store_pt store, log_pt *log) {
 	celix_status_t status = CELIX_SUCCESS;
 
-	*log = apr_palloc(pool, sizeof(**log));
+	*log = calloc(1, sizeof(**log));
 	if (!*log) {
 		status = CELIX_ENOMEM;
 	} else {
@@ -49,6 +49,11 @@ celix_status_t log_create(apr_pool_t *po
 	return status;
 }
 
+celix_status_t log_destroy(log_pt *log) {
+	free(*log);
+	return CELIX_SUCCESS;
+}
+
 celix_status_t log_log(log_pt log, unsigned int type, properties_pt properties) {
 	celix_status_t status = CELIX_SUCCESS;
 

Modified: celix/trunk/deployment_admin/private/src/log_store.c
URL: http://svn.apache.org/viewvc/celix/trunk/deployment_admin/private/src/log_store.c?rev=1655818&r1=1655817&r2=1655818&view=diff
==============================================================================
--- celix/trunk/deployment_admin/private/src/log_store.c (original)
+++ celix/trunk/deployment_admin/private/src/log_store.c Thu Jan 29 19:23:22 2015
@@ -24,7 +24,6 @@
  *  \copyright	Apache License, Version 2.0
  */
 #include <stdlib.h>
-#include <apr_general.h>
 
 #include <time.h>
 
@@ -35,8 +34,6 @@
 #include "log.h"
 
 struct log_store {
-	apr_pool_t *pool;
-
 	unsigned long storeId;
 
 	array_list_pt logEvents;
@@ -44,13 +41,12 @@ struct log_store {
 
 static celix_status_t logStore_getNextID(log_store_pt store, unsigned long *id);
 
-celix_status_t logStore_create(apr_pool_t *pool, log_store_pt *store) {
+celix_status_t logStore_create(log_store_pt *store) {
 	celix_status_t status = CELIX_SUCCESS;
-	*store = apr_palloc(pool, sizeof(**store));
+	*store = calloc(1, sizeof(**store));
 	if (!*store) {
 		status = CELIX_ENOMEM;
 	} else {
-		(*store)->pool = pool;
 		(*store)->storeId = 1;
 		arrayList_create(&(*store)->logEvents);
 	}
@@ -61,7 +57,7 @@ celix_status_t logStore_create(apr_pool_
 celix_status_t logStore_put(log_store_pt store, unsigned int type, properties_pt properties,
log_event_pt *event) {
 	celix_status_t status = CELIX_SUCCESS;
 
-	*event = apr_palloc(store->pool, sizeof(**event));
+	*event = calloc(1, sizeof(**event));
 	(*event)->targetId = NULL;
 	(*event)->logId = store->storeId;
 	(*event)->id = 0;

Modified: celix/trunk/deployment_admin/private/src/log_sync.c
URL: http://svn.apache.org/viewvc/celix/trunk/deployment_admin/private/src/log_sync.c?rev=1655818&r1=1655817&r2=1655818&view=diff
==============================================================================
--- celix/trunk/deployment_admin/private/src/log_sync.c (original)
+++ celix/trunk/deployment_admin/private/src/log_sync.c Thu Jan 29 19:23:22 2015
@@ -28,10 +28,6 @@
 #include <string.h>
 #include <unistd.h>
 
-#include <apr_general.h>
-#include <apr_thread_proc.h>
-#include <apr_strings.h>
-
 #include <curl/curl.h>
 #include <curl/easy.h>
 
@@ -39,17 +35,18 @@
 #include "celix_log.h"
 #include "celixbool.h"
 
+#include "celix_threads.h"
+
 #include "log_sync.h"
 #include "log_event.h"
 
 struct log_sync {
-	apr_pool_t *pool;
 	log_store_pt logStore;
 
 	char *targetId;
 	bool running;
 
-	apr_thread_t *syncTask;
+	celix_thread_t syncTask;
 };
 
 struct log_descriptor {
@@ -63,22 +60,21 @@ typedef struct log_descriptor *log_descr
 
 celix_status_t logSync_queryLog(log_sync_pt logSync, char *targetId, long logId, char **queryReply);
 static size_t logSync_readQeury(void *contents, size_t size, size_t nmemb, void *userp);
-static void *APR_THREAD_FUNC logSync_synchronize(apr_thread_t *thd, void *logSyncP);
+static void *logSync_synchronize(void *logSyncP);
 
-celix_status_t logSync_create(apr_pool_t *pool, char *targetId, log_store_pt store, log_sync_pt
*logSync) {
+celix_status_t logSync_create(char *targetId, log_store_pt store, log_sync_pt *logSync) {
 	celix_status_t status = CELIX_SUCCESS;
 
-	*logSync = apr_palloc(pool, sizeof(**logSync));
+	*logSync = calloc(1, sizeof(**logSync));
 	if (!*logSync) {
 		status = CELIX_ENOMEM;
 	} else {
-		(*logSync)->pool = pool;
 		(*logSync)->logStore = store;
 		(*logSync)->targetId = targetId;
-		(*logSync)->syncTask = NULL;
+		(*logSync)->syncTask = celix_thread_default;
 		(*logSync)->running = true;
 
-		apr_thread_create(&(*logSync)->syncTask, NULL, logSync_synchronize, *logSync, pool);
+		celixThread_create(&(*logSync)->syncTask, NULL, logSync_synchronize, *logSync);
 	}
 
 	return status;
@@ -89,24 +85,24 @@ celix_status_t logSync_parseLogDescripto
 
 	fw_log(logger, OSGI_FRAMEWORK_LOG_DEBUG, "Descriptor: %s", descriptorString);
 	char *last = NULL;
-	char *targetId = apr_strtok(descriptorString, ",", &last);
-	char *logIdStr = apr_strtok(NULL, ",", &last);
+	char *targetId = strtok_r(descriptorString, ",", &last);
+	char *logIdStr = strtok_r(NULL, ",", &last);
 	long logId = 0;
 	if (logIdStr != NULL) {
 		logId = atol(logIdStr);
 	}
-	char *range = apr_strtok(NULL, ",", &last);
+	char *range = strtok_r(NULL, ",", &last);
 	fw_log(logger, OSGI_FRAMEWORK_LOG_DEBUG, "Range: %s", range);
 
 	long low = 0;
 	long high = 0;
 	if (range != NULL) {
 		char *rangeToken = NULL;
-		low = atol(apr_strtok(range, "-", &rangeToken));
-		high = atol(apr_strtok(NULL, "-", &rangeToken));
+		low = atol(strtok_r(range, "-", &rangeToken));
+		high = atol(strtok_r(NULL, "-", &rangeToken));
 	}
 
-	*descriptor = apr_palloc(logSync->pool, sizeof(**descriptor));
+	*descriptor = calloc(1, sizeof(**descriptor));
 	if (!*descriptor) {
 		status = CELIX_ENOMEM;
 	} else {
@@ -119,7 +115,7 @@ celix_status_t logSync_parseLogDescripto
 	return status;
 }
 
-static void *APR_THREAD_FUNC logSync_synchronize(apr_thread_t *thd, void *logSyncP) {
+static void *logSync_synchronize(void *logSyncP) {
 	log_sync_pt logSync = logSyncP;
 
 		while (logSync->running) {
@@ -147,7 +143,7 @@ static void *APR_THREAD_FUNC logSync_syn
 	}
 
 
-	apr_thread_exit(thd, APR_SUCCESS);
+	celixThread_exit(NULL);
 	return NULL;
 }
 
@@ -159,8 +155,9 @@ struct MemoryStruct {
 celix_status_t logSync_queryLog(log_sync_pt logSync, char *targetId, long logId, char **queryReply)
{
 	// http://localhost:8080/auditlog/query?tid=targetid&logid=logid
 	celix_status_t status = CELIX_SUCCESS;
-
-	char *query = apr_pstrcat(logSync->pool, "http://localhost:8080/auditlog/query?tid=",
targetId, "&logid=1", NULL);
+	int length = strlen(targetId) + 60;
+	char query[length];
+	snprintf(query, length, "http://localhost:8080/auditlog/query?tid=%s&logid=1", targetId);
 
 	CURL *curl;
 	CURLcode res;
@@ -181,7 +178,7 @@ celix_status_t logSync_queryLog(log_sync
 		/* always cleanup */
 		curl_easy_cleanup(curl);
 
-		*queryReply = apr_pstrdup(logSync->pool, chunk.memory);
+		*queryReply = strdup(chunk.memory);
 	}
 
 	return status;



Mime
View raw message