celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pnol...@apache.org
Subject [2/5] celix git commit: CELIX-354: Fixes concerning high impact issues reported by coverity
Date Wed, 20 Apr 2016 16:31:10 GMT
http://git-wip-us.apache.org/repos/asf/celix/blob/777b8311/remote_services/discovery/private/src/endpoint_discovery_poller.c
----------------------------------------------------------------------
diff --git a/remote_services/discovery/private/src/endpoint_discovery_poller.c b/remote_services/discovery/private/src/endpoint_discovery_poller.c
index b6e8455..95dc847 100644
--- a/remote_services/discovery/private/src/endpoint_discovery_poller.c
+++ b/remote_services/discovery/private/src/endpoint_discovery_poller.c
@@ -53,14 +53,14 @@ static celix_status_t endpointDiscoveryPoller_endpointDescriptionEquals(void *en
  * Allocates memory and initializes a new endpoint_discovery_poller instance.
  */
 celix_status_t endpointDiscoveryPoller_create(discovery_pt discovery, bundle_context_pt context, endpoint_discovery_poller_pt *poller) {
-    celix_status_t status;
+	celix_status_t status;
 
-    *poller = malloc(sizeof(struct endpoint_discovery_poller));
-    if (!*poller) {
-        return CELIX_ENOMEM;
-    }
+	*poller = malloc(sizeof(struct endpoint_discovery_poller));
+	if (!*poller) {
+		return CELIX_ENOMEM;
+	}
 
-    (*poller)->loghelper = &discovery->loghelper;
+	(*poller)->loghelper = &discovery->loghelper;
 
 	status = celixThreadMutex_create(&(*poller)->pollerLock, NULL);
 	if (status != CELIX_SUCCESS) {
@@ -96,10 +96,10 @@ celix_status_t endpointDiscoveryPoller_create(discovery_pt discovery, bundle_con
 	// Clean up after ourselves...
 	free(endpoints);
 
-    status = celixThreadMutex_lock(&(*poller)->pollerLock);
-    if (status != CELIX_SUCCESS) {
-        return CELIX_BUNDLE_EXCEPTION;
-    }
+	status = celixThreadMutex_lock(&(*poller)->pollerLock);
+	if (status != CELIX_SUCCESS) {
+		return CELIX_BUNDLE_EXCEPTION;
+	}
 
 	(*poller)->running = true;
 
@@ -109,22 +109,22 @@ celix_status_t endpointDiscoveryPoller_create(discovery_pt discovery, bundle_con
 	}
 
 
-    status = celixThreadMutex_unlock(&(*poller)->pollerLock);
+	status = celixThreadMutex_unlock(&(*poller)->pollerLock);
 
-    return status;
+	return status;
 }
 
 /**
  * Destroys and frees up memory for a given endpoint_discovery_poller struct.
  */
 celix_status_t endpointDiscoveryPoller_destroy(endpoint_discovery_poller_pt poller) {
-    celix_status_t status;
+	celix_status_t status;
 
-    poller->running = false;
+	poller->running = false;
 
-    celixThread_join(poller->pollerThread, NULL);
+	celixThread_join(poller->pollerThread, NULL);
 
-    hash_map_iterator_pt iterator = hashMapIterator_create(poller->entries);
+	hash_map_iterator_pt iterator = hashMapIterator_create(poller->entries);
 	while (hashMapIterator_hasNext(iterator)) {
 		hash_map_entry_pt entry = hashMapIterator_nextEntry(iterator);
 
@@ -143,32 +143,32 @@ celix_status_t endpointDiscoveryPoller_destroy(endpoint_discovery_poller_pt poll
 
 	hashMap_destroy(poller->entries, true, false);
 
-    status = celixThreadMutex_unlock(&poller->pollerLock);
+	status = celixThreadMutex_unlock(&poller->pollerLock);
 
-    poller->loghelper = NULL;
+	poller->loghelper = NULL;
 
-    free(poller);
+	free(poller);
 
 	return status;
 }
 
 
 celix_status_t endpointDiscoveryPoller_getDiscoveryEndpoints(endpoint_discovery_poller_pt poller, array_list_pt urls) {
-    celixThreadMutex_lock(&(poller)->pollerLock);
+	celixThreadMutex_lock(&(poller)->pollerLock);
 
-    hash_map_iterator_pt iterator = hashMapIterator_create(poller->entries);
+	hash_map_iterator_pt iterator = hashMapIterator_create(poller->entries);
 
-    while(hashMapIterator_hasNext(iterator))  {
-        hash_map_entry_pt entry = hashMapIterator_nextEntry(iterator);
-        char* toAdd = strdup((char*) hashMapEntry_getKey(entry));
-        arrayList_add(urls, toAdd);
-    }
+	while(hashMapIterator_hasNext(iterator))  {
+		hash_map_entry_pt entry = hashMapIterator_nextEntry(iterator);
+		char* toAdd = strdup((char*) hashMapEntry_getKey(entry));
+		arrayList_add(urls, toAdd);
+	}
 
-    hashMapIterator_destroy(iterator);
+	hashMapIterator_destroy(iterator);
 
-    celixThreadMutex_unlock(&(poller)->pollerLock);
+	celixThreadMutex_unlock(&(poller)->pollerLock);
 
-    return CELIX_SUCCESS;
+	return CELIX_SUCCESS;
 }
 
 /**
@@ -250,7 +250,7 @@ celix_status_t endpointDiscoveryPoller_poll(endpoint_discovery_poller_pt poller,
 	status = endpointDiscoveryPoller_getEndpoints(poller, url, &updatedEndpoints);
 
 	if (status != CELIX_SUCCESS) {
-		status = celixThreadMutex_unlock(&poller->pollerLock);
+		celixThreadMutex_unlock(&poller->pollerLock);
 	} else {
 		if (updatedEndpoints) {
 			for (unsigned int i = arrayList_size(currentEndpoints); i > 0; i--) {
@@ -275,10 +275,10 @@ celix_status_t endpointDiscoveryPoller_poll(endpoint_discovery_poller_pt poller,
 				}
 			}
 		}
+	}
 
-		if (updatedEndpoints) {
-			arrayList_destroy(updatedEndpoints);
-		}
+	if (updatedEndpoints) {
+		arrayList_destroy(updatedEndpoints);
 	}
 
 	return status;
@@ -322,86 +322,86 @@ static void *endpointDiscoveryPoller_performPeriodicPoll(void *data) {
 
 
 struct MemoryStruct {
-  char *memory;
-  size_t size;
+	char *memory;
+	size_t size;
 };
 
 static size_t endpointDiscoveryPoller_writeMemory(void *contents, size_t size, size_t nmemb, void *memoryPtr) {
-    size_t realsize = size * nmemb;
-    struct MemoryStruct *mem = (struct MemoryStruct *)memoryPtr;
+	size_t realsize = size * nmemb;
+	struct MemoryStruct *mem = (struct MemoryStruct *)memoryPtr;
 
-    mem->memory = realloc(mem->memory, mem->size + realsize + 1);
-    if(mem->memory == NULL) {
-    	printf("ENDPOINT_POLLER: not enough memory (realloc returned NULL)!");
-        return 0;
-    }
+	mem->memory = realloc(mem->memory, mem->size + realsize + 1);
+	if(mem->memory == NULL) {
+		printf("ENDPOINT_POLLER: not enough memory (realloc returned NULL)!");
+		return 0;
+	}
 
-    memcpy(&(mem->memory[mem->size]), contents, realsize);
-    mem->size += realsize;
-    mem->memory[mem->size] = 0;
+	memcpy(&(mem->memory[mem->size]), contents, realsize);
+	mem->size += realsize;
+	mem->memory[mem->size] = 0;
 
-    return realsize;
+	return realsize;
 }
 
 static celix_status_t endpointDiscoveryPoller_getEndpoints(endpoint_discovery_poller_pt poller, char *url, array_list_pt *updatedEndpoints) {
-    celix_status_t status = CELIX_SUCCESS;
-
+	celix_status_t status = CELIX_SUCCESS;
 
-    CURL *curl = NULL;
-    CURLcode res = CURLE_OK;
 
-    struct MemoryStruct chunk;
-    chunk.memory = malloc(1);
-    chunk.size = 0;
+	CURL *curl = NULL;
+	CURLcode res = CURLE_OK;
 
-    curl = curl_easy_init();
-    if (!curl) {
-        status = CELIX_ILLEGAL_STATE;
-    } else {
-        curl_easy_setopt(curl, CURLOPT_URL, url);
-        curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1);
-        curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, endpointDiscoveryPoller_writeMemory);
-        curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&chunk);
-        curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 5L);
-        curl_easy_setopt(curl, CURLOPT_TIMEOUT, 10L);
-        res = curl_easy_perform(curl);
+	struct MemoryStruct chunk;
+	chunk.memory = malloc(1);
+	chunk.size = 0;
 
-        curl_easy_cleanup(curl);
-    }
+	curl = curl_easy_init();
+	if (!curl) {
+		status = CELIX_ILLEGAL_STATE;
+	} else {
+		curl_easy_setopt(curl, CURLOPT_URL, url);
+		curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1);
+		curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, endpointDiscoveryPoller_writeMemory);
+		curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&chunk);
+		curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 5L);
+		curl_easy_setopt(curl, CURLOPT_TIMEOUT, 10L);
+		res = curl_easy_perform(curl);
+
+		curl_easy_cleanup(curl);
+	}
 
-    // process endpoints file
-    if (res == CURLE_OK) {
-        endpoint_descriptor_reader_pt reader = NULL;
+	// process endpoints file
+	if (res == CURLE_OK) {
+		endpoint_descriptor_reader_pt reader = NULL;
 
-    	status = endpointDescriptorReader_create(poller, &reader);
-    	if (status == CELIX_SUCCESS) {
+		status = endpointDescriptorReader_create(poller, &reader);
+		if (status == CELIX_SUCCESS) {
 			status = endpointDescriptorReader_parseDocument(reader, chunk.memory, updatedEndpoints);
-    	}
+		}
 
-    	if (reader) {
+		if (reader) {
 			endpointDescriptorReader_destroy(reader);
-    	}
-    } else {
-    	logHelper_log(*poller->loghelper, OSGI_LOGSERVICE_ERROR, "ENDPOINT_POLLER: unable to read endpoints from %s, reason: %s", url, curl_easy_strerror(res));
-    }
+		}
+	} else {
+		logHelper_log(*poller->loghelper, OSGI_LOGSERVICE_ERROR, "ENDPOINT_POLLER: unable to read endpoints from %s, reason: %s", url, curl_easy_strerror(res));
+	}
 
-    // clean up endpoints file
-    if (chunk.memory) {
-        free(chunk.memory);
-    }
+	// clean up endpoints file
+	if (chunk.memory) {
+		free(chunk.memory);
+	}
 
-    return status;
+	return status;
 }
 
 static celix_status_t endpointDiscoveryPoller_endpointDescriptionEquals(void *endpointPtr, void *comparePtr, bool *equals) {
-    endpoint_description_pt endpoint = (endpoint_description_pt) endpointPtr;
-    endpoint_description_pt compare = (endpoint_description_pt) comparePtr;
+	endpoint_description_pt endpoint = (endpoint_description_pt) endpointPtr;
+	endpoint_description_pt compare = (endpoint_description_pt) comparePtr;
 
-    if (strcmp(endpoint->id, compare->id) == 0) {
-        *equals = true;
-    } else {
-        *equals = false;
-    }
+	if (strcmp(endpoint->id, compare->id) == 0) {
+		*equals = true;
+	} else {
+		*equals = false;
+	}
 
-    return CELIX_SUCCESS;
+	return CELIX_SUCCESS;
 }

http://git-wip-us.apache.org/repos/asf/celix/blob/777b8311/remote_services/discovery/private/src/endpoint_discovery_server.c
----------------------------------------------------------------------
diff --git a/remote_services/discovery/private/src/endpoint_discovery_server.c b/remote_services/discovery/private/src/endpoint_discovery_server.c
index 818d239..02cc923 100644
--- a/remote_services/discovery/private/src/endpoint_discovery_server.c
+++ b/remote_services/discovery/private/src/endpoint_discovery_server.c
@@ -47,21 +47,21 @@
 #define CIVETWEB_REQUEST_HANDLED 1
 
 static const char *response_headers =
-  "HTTP/1.1 200 OK\r\n"
-  "Cache: no-cache\r\n"
-  "Content-Type: application/xml;charset=utf-8\r\n"
-  "\r\n";
+		"HTTP/1.1 200 OK\r\n"
+		"Cache: no-cache\r\n"
+		"Content-Type: application/xml;charset=utf-8\r\n"
+		"\r\n";
 
 struct endpoint_discovery_server {
 	log_helper_pt* loghelper;
-    hash_map_pt entries; // key = endpointId, value = endpoint_descriptor_pt
+	hash_map_pt entries; // key = endpointId, value = endpoint_descriptor_pt
 
-    celix_thread_mutex_t serverLock;
+	celix_thread_mutex_t serverLock;
 
-    const char* path;
-    const char *port;
-    const char* ip;
-    struct mg_context* ctx;
+	const char* path;
+	const char *port;
+	const char* ip;
+	struct mg_context* ctx;
 };
 
 // Forward declarations...
@@ -75,7 +75,7 @@ static celix_status_t endpointDiscoveryServer_getIpAdress(char* interface, char*
 celix_status_t endpointDiscoveryServer_create(discovery_pt discovery, bundle_context_pt context, endpoint_discovery_server_pt *server) {
 	celix_status_t status;
 
-	char *port = 0;
+	char *port = NULL;
 	char *ip = NULL;
 	char *detectedIp = NULL;
 	char *path = NULL;
@@ -97,7 +97,7 @@ celix_status_t endpointDiscoveryServer_create(discovery_pt discovery, bundle_con
 	}
 
 	bundleContext_getProperty(context, DISCOVERY_SERVER_IP, &ip);
-	#ifndef ANDROID
+#ifndef ANDROID
 	if (ip == NULL) {
 		char *interface = NULL;
 
@@ -112,7 +112,7 @@ celix_status_t endpointDiscoveryServer_create(discovery_pt discovery, bundle_con
 
 		ip = detectedIp;
 	}
-	#endif
+#endif
 
 	if (ip != NULL) {
 		logHelper_log(*(*server)->loghelper, OSGI_LOGSERVICE_INFO, "Using %s for service annunciation", ip);
@@ -140,17 +140,17 @@ celix_status_t endpointDiscoveryServer_create(discovery_pt discovery, bundle_con
 	(*server)->path = format_path(path);
 
 	const struct mg_callbacks callbacks = {
-		.begin_request = endpointDiscoveryServer_callback,
+			.begin_request = endpointDiscoveryServer_callback,
 	};
 
 	unsigned int port_counter = 0;
+	char newPort[10];
 
 	do {
-		char newPort[10];
 		const char *options[] = {
-			"listening_ports", port,
-			"num_threads", DEFAULT_SERVER_THREADS,
-			NULL
+				"listening_ports", port,
+				"num_threads", DEFAULT_SERVER_THREADS,
+				NULL
 		};
 
 		(*server)->ctx = mg_start(&callbacks, (*server), options);
@@ -161,14 +161,14 @@ celix_status_t endpointDiscoveryServer_create(discovery_pt discovery, bundle_con
 		}
 		else {
 			errno = 0;
-	        char* endptr = port;
-	        long currentPort = strtol(port, &endptr, 10);
+			char* endptr = port;
+			long currentPort = strtol(port, &endptr, 10);
 
-	        if (*endptr || errno != 0) {
-	            currentPort = strtol(DEFAULT_SERVER_PORT, NULL, 10);
-	        }
+			if (*endptr || errno != 0) {
+				currentPort = strtol(DEFAULT_SERVER_PORT, NULL, 10);
+			}
 
-	        port_counter++;
+			port_counter++;
 			snprintf(&newPort[0], 10,  "%ld", (currentPort+1));
 
 			logHelper_log(discovery->loghelper, OSGI_LOGSERVICE_ERROR, "Error while starting discovery server on port %s - retrying on port %s...", port, newPort);
@@ -313,23 +313,27 @@ static celix_status_t endpointDiscoveryServer_getEndpoints(endpoint_discovery_se
 
 static int endpointDiscoveryServer_writeEndpoints(struct mg_connection* conn, array_list_pt endpoints) {
 	celix_status_t status;
+	int rv = CIVETWEB_REQUEST_NOT_HANDLED;
 
-    endpoint_descriptor_writer_pt writer = NULL;
-    status = endpointDescriptorWriter_create(&writer);
-    if (status != CELIX_SUCCESS) {
-    	return CIVETWEB_REQUEST_NOT_HANDLED;
-    }
+	endpoint_descriptor_writer_pt writer = NULL;
+	status = endpointDescriptorWriter_create(&writer);
+	if (status == CELIX_SUCCESS) {
 
-    char *buffer = NULL;
-    status = endpointDescriptorWriter_writeDocument(writer, endpoints, &buffer);
-    if (buffer) {
-    	mg_write(conn, response_headers, strlen(response_headers));
-    	mg_write(conn, buffer, strlen(buffer));
-    }
+		char *buffer = NULL;
+		status = endpointDescriptorWriter_writeDocument(writer, endpoints, &buffer);
+		if (buffer) {
+			mg_write(conn, response_headers, strlen(response_headers));
+			mg_write(conn, buffer, strlen(buffer));
+		}
 
-    status = endpointDescriptorWriter_destroy(writer);
+		rv = CIVETWEB_REQUEST_HANDLED;
+	}
+
+	if(writer!=NULL){
+		endpointDescriptorWriter_destroy(writer);
+	}
 
-	return CIVETWEB_REQUEST_HANDLED;
+	return rv;
 }
 
 // returns all endpoints as XML...
@@ -338,17 +342,17 @@ static int endpointDiscoveryServer_returnAllEndpoints(endpoint_discovery_server_
 
 	array_list_pt endpoints = NULL;
 
-    if (celixThreadMutex_lock(&server->serverLock) == CELIX_SUCCESS) {
-        endpointDiscoveryServer_getEndpoints(server, NULL, &endpoints);
-        if (endpoints) {
-            status = endpointDiscoveryServer_writeEndpoints(conn, endpoints);
+	if (celixThreadMutex_lock(&server->serverLock) == CELIX_SUCCESS) {
+		endpointDiscoveryServer_getEndpoints(server, NULL, &endpoints);
+		if (endpoints) {
+			status = endpointDiscoveryServer_writeEndpoints(conn, endpoints);
 
-            arrayList_destroy(endpoints);
-        }
+			arrayList_destroy(endpoints);
+		}
 
 
-        celixThreadMutex_unlock(&server->serverLock);
-    }
+		celixThreadMutex_unlock(&server->serverLock);
+	}
 
 	return status;
 }
@@ -360,14 +364,14 @@ static int endpointDiscoveryServer_returnEndpoint(endpoint_discovery_server_pt s
 	array_list_pt endpoints = NULL;
 
 	if (celixThreadMutex_lock(&server->serverLock) == CELIX_SUCCESS) {
-        endpointDiscoveryServer_getEndpoints(server, endpoint_id, &endpoints);
-        if (endpoints) {
-            status = endpointDiscoveryServer_writeEndpoints(conn, endpoints);
+		endpointDiscoveryServer_getEndpoints(server, endpoint_id, &endpoints);
+		if (endpoints) {
+			status = endpointDiscoveryServer_writeEndpoints(conn, endpoints);
 
-            arrayList_destroy(endpoints);
-        }
+			arrayList_destroy(endpoints);
+		}
 
-        celixThreadMutex_unlock(&server->serverLock);
+		celixThreadMutex_unlock(&server->serverLock);
 	}
 
 	return status;
@@ -404,10 +408,10 @@ static celix_status_t endpointDiscoveryServer_getIpAdress(char* interface, char*
 	celix_status_t status = CELIX_BUNDLE_EXCEPTION;
 
 	struct ifaddrs *ifaddr, *ifa;
-    char host[NI_MAXHOST];
+	char host[NI_MAXHOST];
 
-    if (getifaddrs(&ifaddr) != -1)
-    {
+	if (getifaddrs(&ifaddr) != -1)
+	{
 		for (ifa = ifaddr; ifa != NULL && status != CELIX_SUCCESS; ifa = ifa->ifa_next)
 		{
 			if (ifa->ifa_addr == NULL)
@@ -426,8 +430,8 @@ static celix_status_t endpointDiscoveryServer_getIpAdress(char* interface, char*
 		}
 
 		freeifaddrs(ifaddr);
-    }
+	}
 
-    return status;
+	return status;
 }
 #endif

http://git-wip-us.apache.org/repos/asf/celix/blob/777b8311/remote_services/discovery_shm/private/src/discovery_shmWatcher.c
----------------------------------------------------------------------
diff --git a/remote_services/discovery_shm/private/src/discovery_shmWatcher.c b/remote_services/discovery_shm/private/src/discovery_shmWatcher.c
index e69edfc..2123876 100644
--- a/remote_services/discovery_shm/private/src/discovery_shmWatcher.c
+++ b/remote_services/discovery_shm/private/src/discovery_shmWatcher.c
@@ -196,24 +196,19 @@ celix_status_t discoveryShmWatcher_create(discovery_pt discovery) {
         if (status == CELIX_SUCCESS) {
             discovery->watcher = watcher;
         }
+        else{
+        	discovery->watcher = NULL;
+        	free(watcher);
+        }
 
     }
 
     if (status == CELIX_SUCCESS) {
-        status = celixThreadMutex_create(&watcher->watcherLock, NULL);
-    }
-
-    if (status == CELIX_SUCCESS) {
-        status = celixThreadMutex_lock(&watcher->watcherLock);
-    }
-
-    if (status == CELIX_SUCCESS) {
-    	watcher->running = true;
-        status = celixThread_create(&watcher->watcherThread, NULL, discoveryShmWatcher_run, discovery);
-    }
-
-    if (status == CELIX_SUCCESS) {
-        status = celixThreadMutex_unlock(&watcher->watcherLock);
+        status += celixThreadMutex_create(&watcher->watcherLock, NULL);
+        status += celixThreadMutex_lock(&watcher->watcherLock);
+        watcher->running = true;
+        status += celixThread_create(&watcher->watcherThread, NULL, discoveryShmWatcher_run, discovery);
+        status += celixThreadMutex_unlock(&watcher->watcherLock);
     }
 
     return status;

http://git-wip-us.apache.org/repos/asf/celix/blob/777b8311/remote_services/remote_service_admin/private/src/remote_proxy_factory_impl.c
----------------------------------------------------------------------
diff --git a/remote_services/remote_service_admin/private/src/remote_proxy_factory_impl.c b/remote_services/remote_service_admin/private/src/remote_proxy_factory_impl.c
index b2ffd29..9f996d6 100644
--- a/remote_services/remote_service_admin/private/src/remote_proxy_factory_impl.c
+++ b/remote_services/remote_service_admin/private/src/remote_proxy_factory_impl.c
@@ -175,7 +175,7 @@ static celix_status_t remoteProxyFactory_registerProxyService(remote_proxy_facto
 	if (status == CELIX_SUCCESS) {
 		proxy_instance_ptr->properties = properties_create();
 		if (!proxy_instance_ptr->properties) {
-			status = CELIX_BUNDLE_EXCEPTION;
+			status = CELIX_ENOMEM;
 		}
 	}
 
@@ -205,6 +205,15 @@ static celix_status_t remoteProxyFactory_registerProxyService(remote_proxy_facto
 		hashMap_put(remote_proxy_factory_ptr->proxy_instances, endpointDescription, proxy_instance_ptr);
 	}
 
+	if(status!=CELIX_SUCCESS){
+		if(proxy_instance_ptr != NULL){
+			if(proxy_instance_ptr->properties != NULL){
+				properties_destroy(proxy_instance_ptr->properties);
+			}
+			free(proxy_instance_ptr);
+		}
+	}
+
 	return status;
 }
 

http://git-wip-us.apache.org/repos/asf/celix/blob/777b8311/remote_services/remote_service_admin_dfi/rsa/private/src/import_registration_dfi.c
----------------------------------------------------------------------
diff --git a/remote_services/remote_service_admin_dfi/rsa/private/src/import_registration_dfi.c b/remote_services/remote_service_admin_dfi/rsa/private/src/import_registration_dfi.c
index 2507ea8..4c6f7b4 100644
--- a/remote_services/remote_service_admin_dfi/rsa/private/src/import_registration_dfi.c
+++ b/remote_services/remote_service_admin_dfi/rsa/private/src/import_registration_dfi.c
@@ -73,7 +73,7 @@ celix_status_t importRegistration_create(bundle_context_pt context, endpoint_des
 
         celixThreadMutex_create(&reg->mutex, NULL);
         celixThreadMutex_create(&reg->proxiesMutex, NULL);
-        version_createVersionFromString((char*)serviceVersion,&(reg->version));
+        status = version_createVersionFromString((char*)serviceVersion,&(reg->version));
 
         reg->factory->handle = reg;
         reg->factory->getService = (void *)importRegistration_getService;
@@ -86,6 +86,9 @@ celix_status_t importRegistration_create(bundle_context_pt context, endpoint_des
         printf("IMPORT REGISTRATION IS %p\n", reg);
         *out = reg;
     }
+    else{
+    	importRegistration_destroy(reg);
+    }
 
     return status;
 }

http://git-wip-us.apache.org/repos/asf/celix/blob/777b8311/remote_services/remote_service_admin_dfi/rsa/private/src/remote_service_admin_dfi.c
----------------------------------------------------------------------
diff --git a/remote_services/remote_service_admin_dfi/rsa/private/src/remote_service_admin_dfi.c b/remote_services/remote_service_admin_dfi/rsa/private/src/remote_service_admin_dfi.c
index 8d463c1..1ac5470 100644
--- a/remote_services/remote_service_admin_dfi/rsa/private/src/remote_service_admin_dfi.c
+++ b/remote_services/remote_service_admin_dfi/rsa/private/src/remote_service_admin_dfi.c
@@ -186,8 +186,10 @@ celix_status_t remoteServiceAdmin_create(bundle_context_pt context, remote_servi
         memset(&callbacks, 0, sizeof(callbacks));
         callbacks.begin_request = remoteServiceAdmin_callback;
 
+        char newPort[10];
+
         do {
-            char newPort[10];
+
             const char *options[] = { "listening_ports", port, "num_threads", "5", NULL};
 
             (*admin)->ctx = mg_start(&callbacks, (*admin), options);
@@ -198,11 +200,10 @@ celix_status_t remoteServiceAdmin_create(bundle_context_pt context, remote_servi
 
             }
             else {
+            	errno = 0;
                 char* endptr = port;
                 int currentPort = strtol(port, &endptr, 10);
 
-                errno = 0;
-
                 if (*endptr || errno != 0) {
                     currentPort = strtol(DEFAULT_PORT, NULL, 10);
                 }

http://git-wip-us.apache.org/repos/asf/celix/blob/777b8311/remote_services/remote_service_admin_shm/private/src/remote_service_admin_impl.c
----------------------------------------------------------------------
diff --git a/remote_services/remote_service_admin_shm/private/src/remote_service_admin_impl.c b/remote_services/remote_service_admin_shm/private/src/remote_service_admin_impl.c
index adcfe91..014e5a0 100644
--- a/remote_services/remote_service_admin_shm/private/src/remote_service_admin_impl.c
+++ b/remote_services/remote_service_admin_shm/private/src/remote_service_admin_impl.c
@@ -65,838 +65,847 @@ celix_status_t remoteServiceAdmin_removeSharedIdentityFile(remote_service_admin_
 celix_status_t remoteServiceAdmin_removeSharedIdentityFiles(remote_service_admin_pt admin);
 
 celix_status_t remoteServiceAdmin_create(bundle_context_pt context, remote_service_admin_pt *admin) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    *admin = calloc(1, sizeof(**admin));
-
-    if (!*admin) {
-        status = CELIX_ENOMEM;
-    } else {
-        (*admin)->context = context;
-        (*admin)->exportedServices = hashMap_create(NULL, NULL, NULL, NULL);
-        (*admin)->importedServices = hashMap_create(utils_stringHash, NULL, utils_stringEquals, NULL);
-        (*admin)->exportedIpcSegment = hashMap_create(NULL, NULL, NULL, NULL);
-        (*admin)->importedIpcSegment = hashMap_create(NULL, NULL, NULL, NULL);
-        (*admin)->pollThread = hashMap_create(NULL, NULL, NULL, NULL);
-        (*admin)->pollThreadRunning = hashMap_create(NULL, NULL, NULL, NULL);
-
-        if (logHelper_create(context, &(*admin)->loghelper) == CELIX_SUCCESS) {
-            logHelper_start((*admin)->loghelper);
-        }
-    }
-
-    return status;
+	celix_status_t status = CELIX_SUCCESS;
+
+	*admin = calloc(1, sizeof(**admin));
+
+	if (!*admin) {
+		status = CELIX_ENOMEM;
+	} else {
+		(*admin)->context = context;
+		(*admin)->exportedServices = hashMap_create(NULL, NULL, NULL, NULL);
+		(*admin)->importedServices = hashMap_create(utils_stringHash, NULL, utils_stringEquals, NULL);
+		(*admin)->exportedIpcSegment = hashMap_create(NULL, NULL, NULL, NULL);
+		(*admin)->importedIpcSegment = hashMap_create(NULL, NULL, NULL, NULL);
+		(*admin)->pollThread = hashMap_create(NULL, NULL, NULL, NULL);
+		(*admin)->pollThreadRunning = hashMap_create(NULL, NULL, NULL, NULL);
+
+		if (logHelper_create(context, &(*admin)->loghelper) == CELIX_SUCCESS) {
+			logHelper_start((*admin)->loghelper);
+		}
+	}
+
+	return status;
 }
 
 celix_status_t remoteServiceAdmin_destroy(remote_service_admin_pt* admin) {
-    celix_status_t status = CELIX_SUCCESS;
+	celix_status_t status = CELIX_SUCCESS;
 
-    hashMap_destroy((*admin)->exportedServices, false, false);
-    hashMap_destroy((*admin)->importedServices, false, false);
-    hashMap_destroy((*admin)->exportedIpcSegment, false, false);
-    hashMap_destroy((*admin)->importedIpcSegment, false, false);
-    hashMap_destroy((*admin)->pollThread, false, false);
-    hashMap_destroy((*admin)->pollThreadRunning, false, false);
+	hashMap_destroy((*admin)->exportedServices, false, false);
+	hashMap_destroy((*admin)->importedServices, false, false);
+	hashMap_destroy((*admin)->exportedIpcSegment, false, false);
+	hashMap_destroy((*admin)->importedIpcSegment, false, false);
+	hashMap_destroy((*admin)->pollThread, false, false);
+	hashMap_destroy((*admin)->pollThreadRunning, false, false);
 
-    free(*admin);
+	free(*admin);
 
-    *admin = NULL;
+	*admin = NULL;
 
-    return status;
+	return status;
 }
 
 celix_status_t remoteServiceAdmin_stop(remote_service_admin_pt admin) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    celixThreadMutex_lock(&admin->exportedServicesLock);
-
-    hash_map_iterator_pt iter = hashMapIterator_create(admin->exportedServices);
-    while (hashMapIterator_hasNext(iter)) {
-        array_list_pt exports = hashMapIterator_nextValue(iter);
-        int i;
-        for (i = 0; i < arrayList_size(exports); i++) {
-            export_registration_pt export = arrayList_get(exports, i);
-            exportRegistration_stopTracking(export);
-        }
-    }
-    hashMapIterator_destroy(iter);
-    celixThreadMutex_unlock(&admin->exportedServicesLock);
-
-    celixThreadMutex_lock(&admin->importedServicesLock);
-
-    iter = hashMapIterator_create(admin->importedServices);
-    while (hashMapIterator_hasNext(iter)) {
-        hash_map_entry_pt entry = hashMapIterator_nextEntry(iter);
-
-        char* service = hashMapEntry_getKey(entry);
-        import_registration_factory_pt importFactory = hashMapEntry_getValue(entry);
-
-        if (importFactory != NULL) {
-
-            int i;
-            for (i = 0; i < arrayList_size(importFactory->registrations); i++) {
-                import_registration_pt importRegistration = arrayList_get(importFactory->registrations, i);
-
-                if (importFactory->trackedFactory != NULL) {
-                    importFactory->trackedFactory->unregisterProxyService(importFactory->trackedFactory->factory, importRegistration->endpointDescription);
-                }
-            }
-            serviceTracker_close(importFactory->proxyFactoryTracker);
-            importRegistrationFactory_close(importFactory);
-
-            hashMap_remove(admin->importedServices, service);
-            importRegistrationFactory_destroy(&importFactory);
-        }
-    }
-    hashMapIterator_destroy(iter);
-    celixThreadMutex_unlock(&admin->importedServicesLock);
-
-    // set stop-thread-variable
-    iter = hashMapIterator_create(admin->pollThreadRunning);
-    while (hashMapIterator_hasNext(iter)) {
-        bool *pollThreadRunning = hashMapIterator_nextValue(iter);
-        *pollThreadRunning = false;
-    }
-    hashMapIterator_destroy(iter);
-
-    // release lock
-    iter = hashMapIterator_create(admin->exportedIpcSegment);
-    while (hashMapIterator_hasNext(iter)) {
-        ipc_segment_pt ipc = hashMapIterator_nextValue(iter);
-        remoteServiceAdmin_unlock(ipc->semId, 1);
-    }
-    hashMapIterator_destroy(iter);
-
-    // wait till threads has stopped
-    iter = hashMapIterator_create(admin->pollThread);
-    while (hashMapIterator_hasNext(iter)) {
-        celix_thread_t *pollThread = hashMapIterator_nextValue(iter);
-
-        if (pollThread != NULL) {
-            status = celixThread_join(*pollThread, NULL);
-        }
-    }
-    hashMapIterator_destroy(iter);
-
-    iter = hashMapIterator_create(admin->importedIpcSegment);
-    while (hashMapIterator_hasNext(iter)) {
-        ipc_segment_pt ipc = hashMapIterator_nextValue(iter);
-        remoteServiceAdmin_detachIpcSegment(ipc);
-        free(ipc);
-    }
-    hashMapIterator_destroy(iter);
-
-    iter = hashMapIterator_create(admin->exportedIpcSegment);
-    while (hashMapIterator_hasNext(iter)) {
-        ipc_segment_pt ipc = hashMapIterator_nextValue(iter);
-        remoteServiceAdmin_deleteIpcSegment(ipc);
-        free(ipc);
-    }
-    hashMapIterator_destroy(iter);
-
-    remoteServiceAdmin_removeSharedIdentityFiles(admin);
-
-    logHelper_stop(admin->loghelper);
-    logHelper_destroy(&admin->loghelper);
-    return status;
+	celix_status_t status = CELIX_SUCCESS;
+
+	celixThreadMutex_lock(&admin->exportedServicesLock);
+
+	hash_map_iterator_pt iter = hashMapIterator_create(admin->exportedServices);
+	while (hashMapIterator_hasNext(iter)) {
+		array_list_pt exports = hashMapIterator_nextValue(iter);
+		int i;
+		for (i = 0; i < arrayList_size(exports); i++) {
+			export_registration_pt export = arrayList_get(exports, i);
+			exportRegistration_stopTracking(export);
+		}
+	}
+	hashMapIterator_destroy(iter);
+	celixThreadMutex_unlock(&admin->exportedServicesLock);
+
+	celixThreadMutex_lock(&admin->importedServicesLock);
+
+	iter = hashMapIterator_create(admin->importedServices);
+	while (hashMapIterator_hasNext(iter)) {
+		hash_map_entry_pt entry = hashMapIterator_nextEntry(iter);
+
+		char* service = hashMapEntry_getKey(entry);
+		import_registration_factory_pt importFactory = hashMapEntry_getValue(entry);
+
+		if (importFactory != NULL) {
+
+			int i;
+			for (i = 0; i < arrayList_size(importFactory->registrations); i++) {
+				import_registration_pt importRegistration = arrayList_get(importFactory->registrations, i);
+
+				if (importFactory->trackedFactory != NULL) {
+					importFactory->trackedFactory->unregisterProxyService(importFactory->trackedFactory->factory, importRegistration->endpointDescription);
+				}
+			}
+			serviceTracker_close(importFactory->proxyFactoryTracker);
+			importRegistrationFactory_close(importFactory);
+
+			hashMap_remove(admin->importedServices, service);
+			importRegistrationFactory_destroy(&importFactory);
+		}
+	}
+	hashMapIterator_destroy(iter);
+	celixThreadMutex_unlock(&admin->importedServicesLock);
+
+	// set stop-thread-variable
+	iter = hashMapIterator_create(admin->pollThreadRunning);
+	while (hashMapIterator_hasNext(iter)) {
+		bool *pollThreadRunning = hashMapIterator_nextValue(iter);
+		*pollThreadRunning = false;
+	}
+	hashMapIterator_destroy(iter);
+
+	// release lock
+	iter = hashMapIterator_create(admin->exportedIpcSegment);
+	while (hashMapIterator_hasNext(iter)) {
+		ipc_segment_pt ipc = hashMapIterator_nextValue(iter);
+		remoteServiceAdmin_unlock(ipc->semId, 1);
+	}
+	hashMapIterator_destroy(iter);
+
+	// wait till threads has stopped
+	iter = hashMapIterator_create(admin->pollThread);
+	while (hashMapIterator_hasNext(iter)) {
+		celix_thread_t *pollThread = hashMapIterator_nextValue(iter);
+
+		if (pollThread != NULL) {
+			status = celixThread_join(*pollThread, NULL);
+		}
+	}
+	hashMapIterator_destroy(iter);
+
+	iter = hashMapIterator_create(admin->importedIpcSegment);
+	while (hashMapIterator_hasNext(iter)) {
+		ipc_segment_pt ipc = hashMapIterator_nextValue(iter);
+		remoteServiceAdmin_detachIpcSegment(ipc);
+		free(ipc);
+	}
+	hashMapIterator_destroy(iter);
+
+	iter = hashMapIterator_create(admin->exportedIpcSegment);
+	while (hashMapIterator_hasNext(iter)) {
+		ipc_segment_pt ipc = hashMapIterator_nextValue(iter);
+		remoteServiceAdmin_deleteIpcSegment(ipc);
+		free(ipc);
+	}
+	hashMapIterator_destroy(iter);
+
+	remoteServiceAdmin_removeSharedIdentityFiles(admin);
+
+	logHelper_stop(admin->loghelper);
+	logHelper_destroy(&admin->loghelper);
+	return status;
 }
 
 static int remoteServiceAdmin_getCount(int semId, int semNr) {
-    int token = -1;
-    unsigned short semVals[3];
-    union semun semArg;
+	int token = -1;
+	unsigned short semVals[3];
+	union semun semArg;
 
-    semArg.array = semVals;
+	semArg.array = semVals;
 
-    if (semctl(semId, 0, GETALL, semArg) == 0) {
-        token = semArg.array[semNr];
-    }
+	if (semctl(semId, 0, GETALL, semArg) == 0) {
+		token = semArg.array[semNr];
+	}
 
-    return token;
+	return token;
 }
 
 static celix_status_t remoteServiceAdmin_lock(int semId, int semNr) {
-    celix_status_t status = CELIX_SUCCESS;
-    int semOpStatus = 0;
-    struct sembuf semOperation;
+	celix_status_t status = CELIX_SUCCESS;
+	int semOpStatus = 0;
+	struct sembuf semOperation;
 
-    semOperation.sem_num = semNr;
-    semOperation.sem_op = -1;
-    semOperation.sem_flg = 0;
+	semOperation.sem_num = semNr;
+	semOperation.sem_op = -1;
+	semOperation.sem_flg = 0;
 
-    do {
-        status = CELIX_SUCCESS;
+	do {
+		status = CELIX_SUCCESS;
 
-        if ((semOpStatus = semop(semId, &semOperation, 1)) != 0) {
-            status = CELIX_BUNDLE_EXCEPTION;
-        }
-    } while (semOpStatus == -1 && errno == EINTR);
+		if ((semOpStatus = semop(semId, &semOperation, 1)) != 0) {
+			status = CELIX_BUNDLE_EXCEPTION;
+		}
+	} while (semOpStatus == -1 && errno == EINTR);
 
-    return status;
+	return status;
 }
 
 static celix_status_t remoteServiceAdmin_unlock(int semId, int semNr) {
-    celix_status_t status = CELIX_SUCCESS;
-    int semOpStatus = 0;
-    struct sembuf semOperation;
+	celix_status_t status = CELIX_SUCCESS;
+	int semOpStatus = 0;
+	struct sembuf semOperation;
 
-    semOperation.sem_num = semNr;
-    semOperation.sem_op = 1;
-    semOperation.sem_flg = 0;
+	semOperation.sem_num = semNr;
+	semOperation.sem_op = 1;
+	semOperation.sem_flg = 0;
 
-    do {
-        status = CELIX_SUCCESS;
+	do {
+		status = CELIX_SUCCESS;
 
-        if ((semOpStatus = semop(semId, &semOperation, 1)) != 0) {
-            status = CELIX_BUNDLE_EXCEPTION;
-        }
-    } while (semOpStatus == -1 && errno == EINTR);
+		if ((semOpStatus = semop(semId, &semOperation, 1)) != 0) {
+			status = CELIX_BUNDLE_EXCEPTION;
+		}
+	} while (semOpStatus == -1 && errno == EINTR);
 
-    return status;
+	return status;
 }
 
 celix_status_t remoteServiceAdmin_send(remote_service_admin_pt admin, endpoint_description_pt recpEndpoint, char *request, char **reply, int *replyStatus) {
-    celix_status_t status = CELIX_SUCCESS;
-    ipc_segment_pt ipc = NULL;
+	celix_status_t status = CELIX_SUCCESS;
+	ipc_segment_pt ipc = NULL;
 
-    if ((ipc = hashMap_get(admin->importedIpcSegment, recpEndpoint->service)) != NULL) {
-        int semid = ipc->semId;
+	if ((ipc = hashMap_get(admin->importedIpcSegment, recpEndpoint->service)) != NULL) {
+		int semid = ipc->semId;
 
-        /* lock critical area */
-        remoteServiceAdmin_lock(semid, 0);
+		/* lock critical area */
+		remoteServiceAdmin_lock(semid, 0);
 
-        /* write method and data */
-        strcpy(ipc->shmBaseAdress, request);
+		/* write method and data */
+		strcpy(ipc->shmBaseAdress, request);
 
-        /* Check the status of the send-receive semaphore and reset them if not correct */
-        if (remoteServiceAdmin_getCount(ipc->semId, 1) > 0) {
-            semctl(semid, 1, SETVAL, (int) 0);
-        }
-        if (remoteServiceAdmin_getCount(ipc->semId, 2) > 0) {
-            semctl(semid, 2, SETVAL, (int) 0);
-        }
+		/* Check the status of the send-receive semaphore and reset them if not correct */
+		if (remoteServiceAdmin_getCount(ipc->semId, 1) > 0) {
+			semctl(semid, 1, SETVAL, (int) 0);
+		}
+		if (remoteServiceAdmin_getCount(ipc->semId, 2) > 0) {
+			semctl(semid, 2, SETVAL, (int) 0);
+		}
 
-        /* Inform receiver we are invoking the remote service */
-        remoteServiceAdmin_unlock(semid, 1);
+		/* Inform receiver we are invoking the remote service */
+		remoteServiceAdmin_unlock(semid, 1);
 
-        /* Wait until the receiver finished his operations */
-        remoteServiceAdmin_lock(semid, 2);
+		/* Wait until the receiver finished his operations */
+		remoteServiceAdmin_lock(semid, 2);
 
-        /* read reply */
-        *reply = strdup(ipc->shmBaseAdress);
+		/* read reply */
+		*reply = strdup(ipc->shmBaseAdress);
 
-        /* TODO: fix replyStatus */
-        *replyStatus = 0;
+		/* TODO: fix replyStatus */
+		*replyStatus = 0;
 
-        /* release critical area */
-        remoteServiceAdmin_unlock(semid, 0);
+		/* release critical area */
+		remoteServiceAdmin_unlock(semid, 0);
 
-    } else {
-        status = CELIX_ILLEGAL_STATE; /* could not find ipc segment */
-    }
+	} else {
+		status = CELIX_ILLEGAL_STATE; /* could not find ipc segment */
+	}
 
-    return status;
+	return status;
 }
 
 static void * remoteServiceAdmin_receiveFromSharedMemory(void *data) {
-    recv_shm_thread_pt thread_data = data;
+	recv_shm_thread_pt thread_data = data;
 
-    remote_service_admin_pt admin = thread_data->admin;
-    endpoint_description_pt exportedEndpointDesc = thread_data->endpointDescription;
+	remote_service_admin_pt admin = thread_data->admin;
+	endpoint_description_pt exportedEndpointDesc = thread_data->endpointDescription;
 
-    ipc_segment_pt ipc;
+	ipc_segment_pt ipc;
 
-    if ((ipc = hashMap_get(admin->exportedIpcSegment, exportedEndpointDesc->service)) != NULL) {
-        bool *pollThreadRunning = hashMap_get(admin->pollThreadRunning, exportedEndpointDesc);
+	if ((ipc = hashMap_get(admin->exportedIpcSegment, exportedEndpointDesc->service)) != NULL) {
+		bool *pollThreadRunning = hashMap_get(admin->pollThreadRunning, exportedEndpointDesc);
 
-        while (*pollThreadRunning == true) {
-            if ((remoteServiceAdmin_lock(ipc->semId, 1) == CELIX_SUCCESS) && (*pollThreadRunning == true)) {
+		while (*pollThreadRunning == true) {
+			if ((remoteServiceAdmin_lock(ipc->semId, 1) == CELIX_SUCCESS) && (*pollThreadRunning == true)) {
 
-                // TODO: align data size
-                char *data = calloc(1024, sizeof(*data));
-                strcpy(data, ipc->shmBaseAdress);
+				// TODO: align data size
+				char *data = calloc(1024, sizeof(*data));
+				strcpy(data, ipc->shmBaseAdress);
 
-                hash_map_iterator_pt iter = hashMapIterator_create(admin->exportedServices);
+				hash_map_iterator_pt iter = hashMapIterator_create(admin->exportedServices);
 
-                while (hashMapIterator_hasNext(iter)) {
-                    hash_map_entry_pt entry = hashMapIterator_nextEntry(iter);
-                    array_list_pt exports = hashMapEntry_getValue(entry);
-                    int expIt = 0;
+				while (hashMapIterator_hasNext(iter)) {
+					hash_map_entry_pt entry = hashMapIterator_nextEntry(iter);
+					array_list_pt exports = hashMapEntry_getValue(entry);
+					int expIt = 0;
 
-                    for (expIt = 0; expIt < arrayList_size(exports); expIt++) {
-                        export_registration_pt export = arrayList_get(exports, expIt);
+					for (expIt = 0; expIt < arrayList_size(exports); expIt++) {
+						export_registration_pt export = arrayList_get(exports, expIt);
 
-                        if ((strcmp(exportedEndpointDesc->service, export->endpointDescription->service) == 0) && (export->endpoint != NULL)) {
-                            char *reply = NULL;
+						if ((strcmp(exportedEndpointDesc->service, export->endpointDescription->service) == 0) && (export->endpoint != NULL)) {
+							char *reply = NULL;
 
-                            /* TODO: fix handling of handleRequest return value*/
-                            export->endpoint->handleRequest(export->endpoint->endpoint, data, &reply);
+							/* TODO: fix handling of handleRequest return value*/
+									export->endpoint->handleRequest(export->endpoint->endpoint, data, &reply);
 
-                            if (reply != NULL) {
-                                if ((strlen(reply) * sizeof(char)) >= RSA_SHM_MEMSIZE) {
-                                    logHelper_log(admin->loghelper, OSGI_LOGSERVICE_ERROR, "receiveFromSharedMemory : size of message bigger than shared memory message. NOT SENDING.");
-                                } else {
-                                    strcpy(ipc->shmBaseAdress, reply);
-                                }
-                                free(reply);
-                            }
-                        } else {
-                            logHelper_log(admin->loghelper, OSGI_LOGSERVICE_ERROR, "receiveFromSharedMemory : No endpoint set for %s.", export->endpointDescription->service);
-                        }
-                    }
-                }
-                hashMapIterator_destroy(iter);
-                free(data);
+									if (reply != NULL) {
+										if ((strlen(reply) * sizeof(char)) >= RSA_SHM_MEMSIZE) {
+											logHelper_log(admin->loghelper, OSGI_LOGSERVICE_ERROR, "receiveFromSharedMemory : size of message bigger than shared memory message. NOT SENDING.");
+										} else {
+											strcpy(ipc->shmBaseAdress, reply);
+										}
+										free(reply);
+									}
+						} else {
+							logHelper_log(admin->loghelper, OSGI_LOGSERVICE_ERROR, "receiveFromSharedMemory : No endpoint set for %s.", export->endpointDescription->service);
+						}
+					}
+				}
+				hashMapIterator_destroy(iter);
+				free(data);
 
-                remoteServiceAdmin_unlock(ipc->semId, 2);
+				remoteServiceAdmin_unlock(ipc->semId, 2);
 
-            }
-        }
-    }
+			}
+		}
+	}
 
-    free(data);
+	free(data);
 
-    return NULL;
+	return NULL;
 }
 
 celix_status_t remoteServiceAdmin_getSharedIdentifierFile(remote_service_admin_pt admin, char *fwUuid, char* servicename, char* outFile) {
-    celix_status_t status = CELIX_SUCCESS;
-    snprintf(outFile, RSA_FILEPATH_LENGTH, "%s/%s/%s", P_tmpdir, fwUuid, servicename);
-
-    if (access(outFile, F_OK) != 0) {
-        char tmpDir[RSA_FILEPATH_LENGTH];
-
-        snprintf(tmpDir, RSA_FILEPATH_LENGTH, "%s/%s", P_tmpdir, fwUuid);
-
-        // we call, even if it already exists (and just don't care about the return value)
-        mkdir(tmpDir, 0755);
-
-        if (fopen(outFile, "wb") == NULL) {
-            logHelper_log(admin->loghelper, OSGI_LOGSERVICE_ERROR, "error while creating shared identifier file %s (%s)", outFile, strerror(errno));
-            status = CELIX_FILE_IO_EXCEPTION;
-        } else {
-            logHelper_log(admin->loghelper, OSGI_LOGSERVICE_DEBUG, "create shared identifier file %s", outFile);
-        }
-    } else {
-        logHelper_log(admin->loghelper, OSGI_LOGSERVICE_DEBUG, "shared identifier file %s already exists", outFile);
-    }
-
-    return status;
+	celix_status_t status = CELIX_SUCCESS;
+	snprintf(outFile, RSA_FILEPATH_LENGTH, "%s/%s/%s", P_tmpdir, fwUuid, servicename);
+
+	if (access(outFile, F_OK) != 0) {
+		char tmpDir[RSA_FILEPATH_LENGTH];
+
+		snprintf(tmpDir, RSA_FILEPATH_LENGTH, "%s/%s", P_tmpdir, fwUuid);
+
+		mkdir(tmpDir, 0755);
+		FILE *shid_file = fopen(outFile, "wb");
+		if (shid_file == NULL) {
+			logHelper_log(admin->loghelper, OSGI_LOGSERVICE_ERROR, "error while creating shared identifier file %s (%s)", outFile, strerror(errno));
+			status = CELIX_FILE_IO_EXCEPTION;
+		} else {
+			logHelper_log(admin->loghelper, OSGI_LOGSERVICE_DEBUG, "create shared identifier file %s", outFile);
+			fclose(shid_file);
+		}
+	} else {
+		logHelper_log(admin->loghelper, OSGI_LOGSERVICE_DEBUG, "shared identifier file %s already exists", outFile);
+	}
+
+	return status;
 }
 
 celix_status_t remoteServiceAdmin_removeSharedIdentityFile(remote_service_admin_pt admin, char *fwUuid, char* servicename) {
-    celix_status_t status = CELIX_SUCCESS;
-    char tmpPath[RSA_FILEPATH_LENGTH];
+	celix_status_t status = CELIX_SUCCESS;
+	char tmpPath[RSA_FILEPATH_LENGTH];
 
-    snprintf(tmpPath, RSA_FILEPATH_LENGTH, "%s/%s/%s", P_tmpdir, fwUuid, servicename);
+	snprintf(tmpPath, RSA_FILEPATH_LENGTH, "%s/%s/%s", P_tmpdir, fwUuid, servicename);
 
-    if (access(tmpPath, F_OK) == 0) {
-        logHelper_log(admin->loghelper, OSGI_LOGSERVICE_DEBUG, "removing shared identifier file %s", tmpPath);
-        unlink(tmpPath);
-    } else {
-        logHelper_log(admin->loghelper, OSGI_LOGSERVICE_ERROR, "cannot remove shared identifier file %s", tmpPath);
-    }
+	if (access(tmpPath, F_OK) == 0) {
+		logHelper_log(admin->loghelper, OSGI_LOGSERVICE_DEBUG, "removing shared identifier file %s", tmpPath);
+		unlink(tmpPath);
+	} else {
+		logHelper_log(admin->loghelper, OSGI_LOGSERVICE_ERROR, "cannot remove shared identifier file %s", tmpPath);
+	}
 
-    return status;
+	return status;
 }
 
 celix_status_t remoteServiceAdmin_removeSharedIdentityFiles(remote_service_admin_pt admin) {
-    char tmpDir[RSA_FILEPATH_LENGTH];
-    char* fwUuid = NULL;
-    bundleContext_getProperty(admin->context, OSGI_FRAMEWORK_FRAMEWORK_UUID, &fwUuid);
+	char tmpDir[RSA_FILEPATH_LENGTH];
+	char* fwUuid = NULL;
+	bundleContext_getProperty(admin->context, OSGI_FRAMEWORK_FRAMEWORK_UUID, &fwUuid);
 
-    snprintf(tmpDir, RSA_FILEPATH_LENGTH, "%s/%s", P_tmpdir, fwUuid);
+	snprintf(tmpDir, RSA_FILEPATH_LENGTH, "%s/%s", P_tmpdir, fwUuid);
 
-    DIR *d = opendir(tmpDir);
-    size_t path_len = strlen(tmpDir);
-    int retVal = 0;
+	DIR *d = opendir(tmpDir);
+	size_t path_len = strlen(tmpDir);
+	int retVal = 0;
 
-    if (d) {
-        struct dirent *p;
+	if (d) {
+		struct dirent *p;
 
-        while (!retVal && (p = readdir(d))) {
-            char* f_name;
-            size_t len;
+		while (!retVal && (p = readdir(d))) {
+			char* f_name;
+			size_t len;
 
-            if (!strcmp(p->d_name, ".") || !strcmp(p->d_name, "..")) {
-                continue;
-            }
+			if (!strcmp(p->d_name, ".") || !strcmp(p->d_name, "..")) {
+				continue;
+			}
 
-            len = path_len + strlen(p->d_name) + 2;
-            f_name = (char*) calloc(len, 1);
+			len = path_len + strlen(p->d_name) + 2;
+			f_name = (char*) calloc(len, 1);
 
-            if (f_name) {
-                struct stat statbuf;
+			if (f_name) {
+				struct stat statbuf;
 
-                snprintf(f_name, len, "%s/%s", tmpDir, p->d_name);
+				snprintf(f_name, len, "%s/%s", tmpDir, p->d_name);
 
-                if (!stat(f_name, &statbuf)) {
-                    logHelper_log(admin->loghelper, OSGI_LOGSERVICE_WARNING, "removing shared identifier file %s (unproper clean-up?)", f_name);
-                    retVal = unlink(f_name);
-                }
-            }
-            free(f_name);
-        }
-    }
+				if (!stat(f_name, &statbuf)) {
+					logHelper_log(admin->loghelper, OSGI_LOGSERVICE_WARNING, "removing shared identifier file %s (unproper clean-up?)", f_name);
+					retVal = unlink(f_name);
+				}
+			}
+			free(f_name);
+		}
+	}
 
-    closedir(d);
+	closedir(d);
 
-    if (!retVal) {
-        rmdir(tmpDir);
-    }
+	if (!retVal) {
+		rmdir(tmpDir);
+	}
 
-    return retVal;
+	return retVal;
 }
 
 celix_status_t remoteServiceAdmin_exportService(remote_service_admin_pt admin, char *serviceId, properties_pt properties, array_list_pt *registrations) {
-    celix_status_t status = CELIX_SUCCESS;
-    arrayList_create(registrations);
-
-    array_list_pt references = NULL;
-    service_reference_pt reference = NULL;
-    char filter[256];
-    char *exports = NULL;
-    char *provided = NULL;
-
-    snprintf(filter, 256, "(%s=%s)", (char *) OSGI_FRAMEWORK_SERVICE_ID, serviceId);
-
-    bundleContext_getServiceReferences(admin->context, NULL, filter, &references);
-
-    if (arrayList_size(references) >= 1) {
-        reference = arrayList_get(references, 0);
-    }
-
-    arrayList_destroy(references);
-
-    serviceReference_getProperty(reference, (char *) OSGI_RSA_SERVICE_EXPORTED_INTERFACES, &exports);
-    serviceReference_getProperty(reference, (char *) OSGI_FRAMEWORK_OBJECTCLASS, &provided);
-
-
-    if (reference == NULL) {
-        logHelper_log(admin->loghelper, OSGI_LOGSERVICE_ERROR, "expected a reference for service id %s.", serviceId);
-        status = CELIX_ILLEGAL_STATE;
-    }
-    else if (exports == NULL || provided == NULL) {
-        logHelper_log(admin->loghelper, OSGI_LOGSERVICE_WARNING, "No Services to export.");
-    } else {
-        logHelper_log(admin->loghelper, OSGI_LOGSERVICE_INFO, "Export services (%s)", exports);
-        array_list_pt interfaces = NULL;
-        arrayList_create(&interfaces);
-        if (strcmp(utils_stringTrim(exports), "*") == 0) {
-            char *provided_save_ptr = NULL;
-            char *interface = strtok_r(provided, ",", &provided_save_ptr);
-            while (interface != NULL) {
-                arrayList_add(interfaces, utils_stringTrim(interface));
-                interface = strtok_r(NULL, ",", &provided_save_ptr);
-            }
-        } else {
-            char *provided_save_ptr = NULL;
-            char *pinterface = strtok_r(provided, ",", &provided_save_ptr);
-            while (pinterface != NULL) {
-                char *exports_save_ptr = NULL;
-                char *einterface = strtok_r(exports, ",", &exports_save_ptr);
-                while (einterface != NULL) {
-                    if (strcmp(einterface, pinterface) == 0) {
-                        arrayList_add(interfaces, einterface);
-                    }
-                    einterface = strtok_r(NULL, ",", &exports_save_ptr);
-                }
-                pinterface = strtok_r(NULL, ",", &provided_save_ptr);
-            }
-        }
-
-        if (arrayList_size(interfaces) != 0) {
-            int iter = 0;
-            for (iter = 0; iter < arrayList_size(interfaces); iter++) {
-                char *interface = arrayList_get(interfaces, iter);
-                export_registration_pt registration = NULL;
-
-                exportRegistration_create(admin->loghelper, reference, NULL, admin, admin->context, &registration);
-                arrayList_add(*registrations, registration);
-
-                remoteServiceAdmin_installEndpoint(admin, registration, reference, interface);
-                exportRegistration_open(registration);
-                exportRegistration_startTracking(registration);
-
-                if (remoteServiceAdmin_createOrAttachShm(admin->exportedIpcSegment, admin, registration->endpointDescription, true) == CELIX_SUCCESS) {
-                    recv_shm_thread_pt recvThreadData = NULL;
-
-                    if ((recvThreadData = calloc(1, sizeof(*recvThreadData))) == NULL) {
-                        status = CELIX_ENOMEM;
-                    } else {
-                        recvThreadData->admin = admin;
-                        recvThreadData->endpointDescription = registration->endpointDescription;
-
-                        celix_thread_t* pollThread = calloc(1, sizeof(*pollThread));
-                        bool *pollThreadRunningPtr = calloc(1, sizeof(*pollThreadRunningPtr));
-                        *pollThreadRunningPtr = true;
-
-                        hashMap_put(admin->pollThreadRunning, registration->endpointDescription, pollThreadRunningPtr);
-
-                        // start receiving thread
-                        status = celixThread_create(pollThread, NULL, remoteServiceAdmin_receiveFromSharedMemory, recvThreadData);
-
-                        hashMap_put(admin->pollThread, registration->endpointDescription, pollThread);
-                    }
-                }
-            }
-
-            celixThreadMutex_lock(&admin->exportedServicesLock);
-            hashMap_put(admin->exportedServices, reference, *registrations);
-            celixThreadMutex_unlock(&admin->exportedServicesLock);
-
-        }
-        arrayList_destroy(interfaces);
-    }
-
-    return status;
+	celix_status_t status = CELIX_SUCCESS;
+	arrayList_create(registrations);
+
+	array_list_pt references = NULL;
+	service_reference_pt reference = NULL;
+	char filter[256];
+	char *exports = NULL;
+	char *provided = NULL;
+
+	snprintf(filter, 256, "(%s=%s)", (char *) OSGI_FRAMEWORK_SERVICE_ID, serviceId);
+
+	bundleContext_getServiceReferences(admin->context, NULL, filter, &references);
+
+	if (arrayList_size(references) >= 1) {
+		reference = arrayList_get(references, 0);
+	}
+
+	arrayList_destroy(references);
+
+	serviceReference_getProperty(reference, (char *) OSGI_RSA_SERVICE_EXPORTED_INTERFACES, &exports);
+	serviceReference_getProperty(reference, (char *) OSGI_FRAMEWORK_OBJECTCLASS, &provided);
+
+
+	if (reference == NULL) {
+		logHelper_log(admin->loghelper, OSGI_LOGSERVICE_ERROR, "expected a reference for service id %s.", serviceId);
+		status = CELIX_ILLEGAL_STATE;
+	}
+	else if (exports == NULL || provided == NULL) {
+		logHelper_log(admin->loghelper, OSGI_LOGSERVICE_WARNING, "No Services to export.");
+	} else {
+		logHelper_log(admin->loghelper, OSGI_LOGSERVICE_INFO, "Export services (%s)", exports);
+		array_list_pt interfaces = NULL;
+		arrayList_create(&interfaces);
+		if (strcmp(utils_stringTrim(exports), "*") == 0) {
+			char *provided_save_ptr = NULL;
+			char *interface = strtok_r(provided, ",", &provided_save_ptr);
+			while (interface != NULL) {
+				arrayList_add(interfaces, utils_stringTrim(interface));
+				interface = strtok_r(NULL, ",", &provided_save_ptr);
+			}
+		} else {
+			char *provided_save_ptr = NULL;
+			char *pinterface = strtok_r(provided, ",", &provided_save_ptr);
+			while (pinterface != NULL) {
+				char *exports_save_ptr = NULL;
+				char *einterface = strtok_r(exports, ",", &exports_save_ptr);
+				while (einterface != NULL) {
+					if (strcmp(einterface, pinterface) == 0) {
+						arrayList_add(interfaces, einterface);
+					}
+					einterface = strtok_r(NULL, ",", &exports_save_ptr);
+				}
+				pinterface = strtok_r(NULL, ",", &provided_save_ptr);
+			}
+		}
+
+		if (arrayList_size(interfaces) != 0) {
+			int iter = 0;
+			for (iter = 0; iter < arrayList_size(interfaces); iter++) {
+				char *interface = arrayList_get(interfaces, iter);
+				export_registration_pt registration = NULL;
+
+				exportRegistration_create(admin->loghelper, reference, NULL, admin, admin->context, &registration);
+				arrayList_add(*registrations, registration);
+
+				remoteServiceAdmin_installEndpoint(admin, registration, reference, interface);
+				exportRegistration_open(registration);
+				exportRegistration_startTracking(registration);
+
+				if (remoteServiceAdmin_createOrAttachShm(admin->exportedIpcSegment, admin, registration->endpointDescription, true) == CELIX_SUCCESS) {
+					recv_shm_thread_pt recvThreadData = NULL;
+
+					if ((recvThreadData = calloc(1, sizeof(*recvThreadData))) == NULL) {
+						status = CELIX_ENOMEM;
+					} else {
+						recvThreadData->admin = admin;
+						recvThreadData->endpointDescription = registration->endpointDescription;
+
+						celix_thread_t* pollThread = calloc(1, sizeof(*pollThread));
+						bool *pollThreadRunningPtr = calloc(1, sizeof(*pollThreadRunningPtr));
+						*pollThreadRunningPtr = true;
+
+						hashMap_put(admin->pollThreadRunning, registration->endpointDescription, pollThreadRunningPtr);
+
+						// start receiving thread
+						status = celixThread_create(pollThread, NULL, remoteServiceAdmin_receiveFromSharedMemory, recvThreadData);
+
+						hashMap_put(admin->pollThread, registration->endpointDescription, pollThread);
+					}
+				}
+			}
+
+			celixThreadMutex_lock(&admin->exportedServicesLock);
+			hashMap_put(admin->exportedServices, reference, *registrations);
+			celixThreadMutex_unlock(&admin->exportedServicesLock);
+
+		}
+		arrayList_destroy(interfaces);
+	}
+
+	return status;
 }
 
 celix_status_t remoteServiceAdmin_removeExportedService(remote_service_admin_pt admin, export_registration_pt registration) {
-    celix_status_t status;
-    ipc_segment_pt ipc = NULL;
+	celix_status_t status;
+	ipc_segment_pt ipc = NULL;
 
-    export_reference_pt ref = NULL;
-    status = exportRegistration_getExportReference(registration, &ref);
+	export_reference_pt ref = NULL;
+	status = exportRegistration_getExportReference(registration, &ref);
 
-    if (status == CELIX_SUCCESS) {
-        bool *pollThreadRunning = NULL;
+	if (status == CELIX_SUCCESS) {
+		bool *pollThreadRunning = NULL;
 
-        service_reference_pt servRef;
-        celixThreadMutex_lock(&admin->exportedServicesLock);
-        exportReference_getExportedService(ref, &servRef);
+		service_reference_pt servRef;
+		celixThreadMutex_lock(&admin->exportedServicesLock);
+		exportReference_getExportedService(ref, &servRef);
 
-        array_list_pt exports = (array_list_pt)hashMap_remove(admin->exportedServices, servRef);
-        if(exports!=NULL){
-        	arrayList_destroy(exports);
-        }
+		array_list_pt exports = (array_list_pt)hashMap_remove(admin->exportedServices, servRef);
+		if(exports!=NULL){
+			arrayList_destroy(exports);
+		}
 
-        exportRegistration_close(registration);
+		exportRegistration_close(registration);
 
-        if ((pollThreadRunning = hashMap_get(admin->pollThreadRunning, registration->endpointDescription)) != NULL) {
-            *pollThreadRunning = false;
+		if ((pollThreadRunning = hashMap_get(admin->pollThreadRunning, registration->endpointDescription)) != NULL) {
+			*pollThreadRunning = false;
 
-            if ((ipc = hashMap_get(admin->exportedIpcSegment, registration->endpointDescription->service)) != NULL) {
-                celix_thread_t* pollThread;
+			if ((ipc = hashMap_get(admin->exportedIpcSegment, registration->endpointDescription->service)) != NULL) {
+				celix_thread_t* pollThread;
 
-                remoteServiceAdmin_unlock(ipc->semId, 1);
+				remoteServiceAdmin_unlock(ipc->semId, 1);
 
-                if ((pollThread = hashMap_get(admin->pollThread, registration->endpointDescription)) != NULL) {
-                    status = celixThread_join(*pollThread, NULL);
+				if ((pollThread = hashMap_get(admin->pollThread, registration->endpointDescription)) != NULL) {
+					status = celixThread_join(*pollThread, NULL);
 
-                    if (status == CELIX_SUCCESS) {
-                        semctl(ipc->semId, 1 , IPC_RMID);
-                        shmctl(ipc->shmId, IPC_RMID, 0);
+					if (status == CELIX_SUCCESS) {
+						semctl(ipc->semId, 1 , IPC_RMID);
+						shmctl(ipc->shmId, IPC_RMID, 0);
 
-                        remoteServiceAdmin_removeSharedIdentityFile(admin, registration->endpointDescription->frameworkUUID, registration->endpointDescription->service);
+						remoteServiceAdmin_removeSharedIdentityFile(admin, registration->endpointDescription->frameworkUUID, registration->endpointDescription->service);
 
-                        hashMap_remove(admin->pollThreadRunning, registration->endpointDescription);
-                        hashMap_remove(admin->exportedIpcSegment, registration->endpointDescription->service);
-                        hashMap_remove(admin->pollThread, registration->endpointDescription);
+						hashMap_remove(admin->pollThreadRunning, registration->endpointDescription);
+						hashMap_remove(admin->exportedIpcSegment, registration->endpointDescription->service);
+						hashMap_remove(admin->pollThread, registration->endpointDescription);
 
-                        free(pollThreadRunning);
-                        free(pollThread);
-                        free(ipc);
-                    }
-                }
-            }
-        }
-        exportRegistration_destroy(&registration);
-    }
+						free(pollThreadRunning);
+						free(pollThread);
+						free(ipc);
+					}
+				}
+			}
+		}
+		exportRegistration_destroy(&registration);
+	}
 
-    if(ref!=NULL){
-    	free(ref);
-    }
+	if(ref!=NULL){
+		free(ref);
+	}
 
-    celixThreadMutex_unlock(&admin->exportedServicesLock);
+	celixThreadMutex_unlock(&admin->exportedServicesLock);
 
-    return status;
+	return status;
 }
 
 celix_status_t remoteServiceAdmin_getIpcSegment(remote_service_admin_pt admin, endpoint_description_pt endpointDescription, ipc_segment_pt* ipc) {
-    (*ipc) = (hashMap_containsKey(admin->importedIpcSegment, endpointDescription) == true) ? hashMap_get(admin->importedIpcSegment, endpointDescription) : NULL;
+	(*ipc) = (hashMap_containsKey(admin->importedIpcSegment, endpointDescription) == true) ? hashMap_get(admin->importedIpcSegment, endpointDescription) : NULL;
 
-    return (*ipc != NULL) ? CELIX_SUCCESS : CELIX_ILLEGAL_ARGUMENT;
+	return (*ipc != NULL) ? CELIX_SUCCESS : CELIX_ILLEGAL_ARGUMENT;
 }
 
 celix_status_t remoteServiceAdmin_detachIpcSegment(ipc_segment_pt ipc) {
-    return (shmdt(ipc->shmBaseAdress) != -1) ? CELIX_SUCCESS : CELIX_BUNDLE_EXCEPTION;
+	return (shmdt(ipc->shmBaseAdress) != -1) ? CELIX_SUCCESS : CELIX_BUNDLE_EXCEPTION;
 }
 
 celix_status_t remoteServiceAdmin_deleteIpcSegment(ipc_segment_pt ipc) {
-    return ((semctl(ipc->semId, 1 /*ignored*/, IPC_RMID) != -1) && (shmctl(ipc->shmId, IPC_RMID, 0) != -1)) ? CELIX_SUCCESS : CELIX_BUNDLE_EXCEPTION;
+	return ((semctl(ipc->semId, 1 /*ignored*/, IPC_RMID) != -1) && (shmctl(ipc->shmId, IPC_RMID, 0) != -1)) ? CELIX_SUCCESS : CELIX_BUNDLE_EXCEPTION;
 }
 
 celix_status_t remoteServiceAdmin_createOrAttachShm(hash_map_pt ipcSegment, remote_service_admin_pt admin, endpoint_description_pt endpointDescription, bool createIfNotFound) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    /* setup ipc sehment */
-    ipc_segment_pt ipc = NULL;
-
-    properties_pt endpointProperties = endpointDescription->properties;
-
-    char *shmPath = NULL;
-    char *shmFtokId = NULL;
-
-    char *semPath = NULL;
-    char *semFtokId = NULL;
-
-    if ((shmPath = properties_get(endpointProperties, (char *) RSA_SHM_PATH_PROPERTYNAME)) == NULL) {
-        logHelper_log(admin->loghelper, OSGI_LOGSERVICE_DEBUG, "No value found for key %s in endpointProperties.", RSA_SHM_PATH_PROPERTYNAME);
-        status = CELIX_BUNDLE_EXCEPTION;
-    } else if ((shmFtokId = properties_get(endpointProperties, (char *) RSA_SHM_FTOK_ID_PROPERTYNAME)) == NULL) {
-        logHelper_log(admin->loghelper, OSGI_LOGSERVICE_DEBUG, "No value found for key %s in endpointProperties.", RSA_SHM_FTOK_ID_PROPERTYNAME);
-        status = CELIX_BUNDLE_EXCEPTION;
-    } else if ((semPath = properties_get(endpointProperties, (char *) RSA_SEM_PATH_PROPERTYNAME)) == NULL) {
-        logHelper_log(admin->loghelper, OSGI_LOGSERVICE_DEBUG, "No value found for key %s in endpointProperties.", RSA_SEM_PATH_PROPERTYNAME);
-        status = CELIX_BUNDLE_EXCEPTION;
-    } else if ((semFtokId = properties_get(endpointProperties, (char *) RSA_SEM_FTOK_ID_PROPERTYNAME)) == NULL) {
-        logHelper_log(admin->loghelper, OSGI_LOGSERVICE_DEBUG, "No value found for key %s in endpointProperties.", RSA_SEM_FTOK_ID_PROPERTYNAME);
-        status = CELIX_BUNDLE_EXCEPTION;
-    } else {
-        key_t shmKey = ftok(shmPath, atoi(shmFtokId));
-        ipc = calloc(1, sizeof(*ipc));
-
-        if ((ipc->shmId = shmget(shmKey, RSA_SHM_MEMSIZE, 0666)) < 0) {
-            logHelper_log(admin->loghelper, OSGI_LOGSERVICE_WARNING, "Could not attach to shared memory");
-
-            if (createIfNotFound == true) {
-                if ((ipc->shmId = shmget(shmKey, RSA_SHM_MEMSIZE, IPC_CREAT | 0666)) < 0) {
-                    logHelper_log(admin->loghelper, OSGI_LOGSERVICE_ERROR, "Creation of shared memory segment failed.");
-                    status = CELIX_BUNDLE_EXCEPTION;
-                } else if ((ipc->shmBaseAdress = shmat(ipc->shmId, 0, 0)) == (char *) -1) {
-                    logHelper_log(admin->loghelper, OSGI_LOGSERVICE_ERROR, "Attaching of shared memory segment failed.");
-                    status = CELIX_BUNDLE_EXCEPTION;
-                } else {
-                    logHelper_log(admin->loghelper, OSGI_LOGSERVICE_INFO, "shared memory segment sucessfully created at %p.", ipc->shmBaseAdress);
-                }
-            }
-        } else if ((ipc->shmBaseAdress = shmat(ipc->shmId, 0, 0)) == (char *) -1) {
-            logHelper_log(admin->loghelper, OSGI_LOGSERVICE_ERROR, "Attaching to shared memory segment failed.");
-            status = CELIX_BUNDLE_EXCEPTION;
-        } else {
-            logHelper_log(admin->loghelper, OSGI_LOGSERVICE_INFO, "sucessfully attached to shared memory at %p.", ipc->shmBaseAdress);
-        }
-    }
-
-    if ((status == CELIX_SUCCESS) && (ipc != NULL)) {
-        key_t semkey = ftok(semPath, atoi(semFtokId));
-        int semflg = (createIfNotFound == true) ? (0666 | IPC_CREAT) : (0666);
-        int semid = semget(semkey, 3, semflg);
-
-        if (semid != -1) {
-            // only reset semaphores if a create was supposed
-            if ((createIfNotFound == true) && ((semctl(semid, 0, SETVAL, (int) 1) == -1) || (semctl(semid, 1, SETVAL, (int) 0) == -1) || (semctl(semid, 2, SETVAL, (int) 0) == -1))) {
-                logHelper_log(admin->loghelper, OSGI_LOGSERVICE_ERROR, "error while initialize semaphores.");
-            }
-
-            logHelper_log(admin->loghelper, OSGI_LOGSERVICE_DEBUG, "semaphores w/ key %s and id %i added.", endpointDescription->service, semid);
-            ipc->semId = semid;
-
-            hashMap_put(ipcSegment, endpointDescription->service, ipc);
-        } else {
-            logHelper_log(admin->loghelper, OSGI_LOGSERVICE_ERROR, "error getting semaphores.");
-            status = CELIX_BUNDLE_EXCEPTION;
-        }
-    }
-
-    return status;
+	celix_status_t status = CELIX_SUCCESS;
+
+	/* setup ipc sehment */
+	ipc_segment_pt ipc = NULL;
+
+	properties_pt endpointProperties = endpointDescription->properties;
+
+	char *shmPath = NULL;
+	char *shmFtokId = NULL;
+
+	char *semPath = NULL;
+	char *semFtokId = NULL;
+
+	if ((shmPath = properties_get(endpointProperties, (char *) RSA_SHM_PATH_PROPERTYNAME)) == NULL) {
+		logHelper_log(admin->loghelper, OSGI_LOGSERVICE_DEBUG, "No value found for key %s in endpointProperties.", RSA_SHM_PATH_PROPERTYNAME);
+		status = CELIX_BUNDLE_EXCEPTION;
+	} else if ((shmFtokId = properties_get(endpointProperties, (char *) RSA_SHM_FTOK_ID_PROPERTYNAME)) == NULL) {
+		logHelper_log(admin->loghelper, OSGI_LOGSERVICE_DEBUG, "No value found for key %s in endpointProperties.", RSA_SHM_FTOK_ID_PROPERTYNAME);
+		status = CELIX_BUNDLE_EXCEPTION;
+	} else if ((semPath = properties_get(endpointProperties, (char *) RSA_SEM_PATH_PROPERTYNAME)) == NULL) {
+		logHelper_log(admin->loghelper, OSGI_LOGSERVICE_DEBUG, "No value found for key %s in endpointProperties.", RSA_SEM_PATH_PROPERTYNAME);
+		status = CELIX_BUNDLE_EXCEPTION;
+	} else if ((semFtokId = properties_get(endpointProperties, (char *) RSA_SEM_FTOK_ID_PROPERTYNAME)) == NULL) {
+		logHelper_log(admin->loghelper, OSGI_LOGSERVICE_DEBUG, "No value found for key %s in endpointProperties.", RSA_SEM_FTOK_ID_PROPERTYNAME);
+		status = CELIX_BUNDLE_EXCEPTION;
+	} else {
+		key_t shmKey = ftok(shmPath, atoi(shmFtokId));
+		ipc = calloc(1, sizeof(*ipc));
+		if(ipc == NULL){
+			return CELIX_ENOMEM;
+		}
+
+		if ((ipc->shmId = shmget(shmKey, RSA_SHM_MEMSIZE, 0666)) < 0) {
+			logHelper_log(admin->loghelper, OSGI_LOGSERVICE_WARNING, "Could not attach to shared memory");
+
+			if (createIfNotFound == true) {
+				if ((ipc->shmId = shmget(shmKey, RSA_SHM_MEMSIZE, IPC_CREAT | 0666)) < 0) {
+					logHelper_log(admin->loghelper, OSGI_LOGSERVICE_ERROR, "Creation of shared memory segment failed.");
+					status = CELIX_BUNDLE_EXCEPTION;
+				} else if ((ipc->shmBaseAdress = shmat(ipc->shmId, 0, 0)) == (char *) -1) {
+					logHelper_log(admin->loghelper, OSGI_LOGSERVICE_ERROR, "Attaching of shared memory segment failed.");
+					status = CELIX_BUNDLE_EXCEPTION;
+				} else {
+					logHelper_log(admin->loghelper, OSGI_LOGSERVICE_INFO, "shared memory segment sucessfully created at %p.", ipc->shmBaseAdress);
+				}
+			}
+		} else if ((ipc->shmBaseAdress = shmat(ipc->shmId, 0, 0)) == (char *) -1) {
+			logHelper_log(admin->loghelper, OSGI_LOGSERVICE_ERROR, "Attaching to shared memory segment failed.");
+			status = CELIX_BUNDLE_EXCEPTION;
+		} else {
+			logHelper_log(admin->loghelper, OSGI_LOGSERVICE_INFO, "sucessfully attached to shared memory at %p.", ipc->shmBaseAdress);
+		}
+	}
+
+	if(ipc != NULL){
+		if(status == CELIX_SUCCESS){
+			key_t semkey = ftok(semPath, atoi(semFtokId));
+			int semflg = (createIfNotFound == true) ? (0666 | IPC_CREAT) : (0666);
+			int semid = semget(semkey, 3, semflg);
+
+			if (semid != -1) {
+				// only reset semaphores if a create was supposed
+				if ((createIfNotFound == true) && ((semctl(semid, 0, SETVAL, (int) 1) == -1) || (semctl(semid, 1, SETVAL, (int) 0) == -1) || (semctl(semid, 2, SETVAL, (int) 0) == -1))) {
+					logHelper_log(admin->loghelper, OSGI_LOGSERVICE_ERROR, "error while initialize semaphores.");
+				}
+
+				logHelper_log(admin->loghelper, OSGI_LOGSERVICE_DEBUG, "semaphores w/ key %s and id %i added.", endpointDescription->service, semid);
+				ipc->semId = semid;
+
+				hashMap_put(ipcSegment, endpointDescription->service, ipc);
+			} else {
+				logHelper_log(admin->loghelper, OSGI_LOGSERVICE_ERROR, "error getting semaphores.");
+				status = CELIX_BUNDLE_EXCEPTION;
+			}
+		}
+		else{
+			free(ipc);
+		}
+	}
+
+
+	return status;
 }
 
 celix_status_t remoteServiceAdmin_installEndpoint(remote_service_admin_pt admin, export_registration_pt registration, service_reference_pt reference, char *interface) {
-    celix_status_t status = CELIX_SUCCESS;
-    properties_pt endpointProperties = properties_create();
-
-    unsigned int size = 0;
-    char **keys;
-
-    serviceReference_getPropertyKeys(reference, &keys, &size);
-    for (int i = 0; i < size; i++) {
-        char *key = keys[i];
-        char *value = NULL;
-
-        if (serviceReference_getProperty(reference, key, &value) == CELIX_SUCCESS && strcmp(key, (char*) OSGI_RSA_SERVICE_EXPORTED_INTERFACES) != 0 && strcmp(key, (char*) OSGI_FRAMEWORK_OBJECTCLASS) != 0) {
-            properties_set(endpointProperties, key, value);
-        }
-    }
-
-    hash_map_entry_pt entry = hashMap_getEntry(endpointProperties, (void *) OSGI_FRAMEWORK_SERVICE_ID);
-
-    char* key = hashMapEntry_getKey(entry);
-    char *serviceId = (char *) hashMap_remove(endpointProperties, (void *) OSGI_FRAMEWORK_SERVICE_ID);
-    char *uuid = NULL;
-
-    uuid_t endpoint_uid;
-    uuid_generate(endpoint_uid);
-    char endpoint_uuid[37];
-    uuid_unparse_lower(endpoint_uid, endpoint_uuid);
-
-    bundleContext_getProperty(admin->context, OSGI_FRAMEWORK_FRAMEWORK_UUID, &uuid);
-    properties_set(endpointProperties, (char*) OSGI_RSA_ENDPOINT_FRAMEWORK_UUID, uuid);
-    properties_set(endpointProperties, (char*) OSGI_FRAMEWORK_OBJECTCLASS, interface);
-    properties_set(endpointProperties, (char*) OSGI_RSA_ENDPOINT_SERVICE_ID, serviceId);
-    properties_set(endpointProperties, (char*) OSGI_RSA_ENDPOINT_ID, endpoint_uuid);
-    properties_set(endpointProperties, (char*) OSGI_RSA_SERVICE_IMPORTED, "true");
-//    properties_set(endpointProperties, (char*) OSGI_RSA_SERVICE_IMPORTED_CONFIGS, (char*) CONFIGURATION_TYPE);
-
-    if (properties_get(endpointProperties, (char *) RSA_SHM_PATH_PROPERTYNAME) == NULL) {
-        char sharedIdentifierFile[RSA_FILEPATH_LENGTH];
-
-        if (remoteServiceAdmin_getSharedIdentifierFile(admin, uuid, interface, sharedIdentifierFile) == CELIX_SUCCESS) {
-            properties_set(endpointProperties, (char *) RSA_SHM_PATH_PROPERTYNAME, sharedIdentifierFile);
-        } else {
-            properties_set(endpointProperties, (char *) RSA_SHM_PATH_PROPERTYNAME, (char *) RSA_SHM_DEFAULTPATH);
-        }
-    }
-    if (properties_get(endpointProperties, (char *) RSA_SHM_FTOK_ID_PROPERTYNAME) == NULL) {
-        properties_set(endpointProperties, (char *) RSA_SHM_FTOK_ID_PROPERTYNAME, (char *) RSA_SHM_DEFAULT_FTOK_ID);
-    }
-    if (properties_get(endpointProperties, (char *) RSA_SEM_PATH_PROPERTYNAME) == NULL) {
-        char sharedIdentifierFile[RSA_FILEPATH_LENGTH];
-
-        if (remoteServiceAdmin_getSharedIdentifierFile(admin, uuid, interface, sharedIdentifierFile) == CELIX_SUCCESS) {
-            properties_set(endpointProperties, (char *) RSA_SEM_PATH_PROPERTYNAME, sharedIdentifierFile);
-        } else {
-            properties_set(endpointProperties, (char *) RSA_SEM_PATH_PROPERTYNAME, (char *) RSA_SEM_DEFAULTPATH);
-        }
-    }
-    if (properties_get(endpointProperties, (char *) RSA_SEM_FTOK_ID_PROPERTYNAME) == NULL) {
-        properties_set(endpointProperties, (char *) RSA_SEM_FTOK_ID_PROPERTYNAME, (char *) RSA_SEM_DEFAULT_FTOK_ID);
-    }
-
-    endpoint_description_pt endpointDescription = NULL;
-    remoteServiceAdmin_createEndpointDescription(admin, reference, endpointProperties, interface, &endpointDescription);
-    exportRegistration_setEndpointDescription(registration, endpointDescription);
-
-    free(key);
-    free(serviceId);
-    free(keys);
-
-    return status;
+	celix_status_t status = CELIX_SUCCESS;
+	properties_pt endpointProperties = properties_create();
+
+	unsigned int size = 0;
+	char **keys;
+
+	serviceReference_getPropertyKeys(reference, &keys, &size);
+	for (int i = 0; i < size; i++) {
+		char *key = keys[i];
+		char *value = NULL;
+
+		if (serviceReference_getProperty(reference, key, &value) == CELIX_SUCCESS && strcmp(key, (char*) OSGI_RSA_SERVICE_EXPORTED_INTERFACES) != 0 && strcmp(key, (char*) OSGI_FRAMEWORK_OBJECTCLASS) != 0) {
+			properties_set(endpointProperties, key, value);
+		}
+	}
+
+	hash_map_entry_pt entry = hashMap_getEntry(endpointProperties, (void *) OSGI_FRAMEWORK_SERVICE_ID);
+
+	char* key = hashMapEntry_getKey(entry);
+	char *serviceId = (char *) hashMap_remove(endpointProperties, (void *) OSGI_FRAMEWORK_SERVICE_ID);
+	char *uuid = NULL;
+
+	uuid_t endpoint_uid;
+	uuid_generate(endpoint_uid);
+	char endpoint_uuid[37];
+	uuid_unparse_lower(endpoint_uid, endpoint_uuid);
+
+	bundleContext_getProperty(admin->context, OSGI_FRAMEWORK_FRAMEWORK_UUID, &uuid);
+	properties_set(endpointProperties, (char*) OSGI_RSA_ENDPOINT_FRAMEWORK_UUID, uuid);
+	properties_set(endpointProperties, (char*) OSGI_FRAMEWORK_OBJECTCLASS, interface);
+	properties_set(endpointProperties, (char*) OSGI_RSA_ENDPOINT_SERVICE_ID, serviceId);
+	properties_set(endpointProperties, (char*) OSGI_RSA_ENDPOINT_ID, endpoint_uuid);
+	properties_set(endpointProperties, (char*) OSGI_RSA_SERVICE_IMPORTED, "true");
+	//    properties_set(endpointProperties, (char*) OSGI_RSA_SERVICE_IMPORTED_CONFIGS, (char*) CONFIGURATION_TYPE);
+
+	if (properties_get(endpointProperties, (char *) RSA_SHM_PATH_PROPERTYNAME) == NULL) {
+		char sharedIdentifierFile[RSA_FILEPATH_LENGTH];
+
+		if (remoteServiceAdmin_getSharedIdentifierFile(admin, uuid, interface, sharedIdentifierFile) == CELIX_SUCCESS) {
+			properties_set(endpointProperties, (char *) RSA_SHM_PATH_PROPERTYNAME, sharedIdentifierFile);
+		} else {
+			properties_set(endpointProperties, (char *) RSA_SHM_PATH_PROPERTYNAME, (char *) RSA_SHM_DEFAULTPATH);
+		}
+	}
+	if (properties_get(endpointProperties, (char *) RSA_SHM_FTOK_ID_PROPERTYNAME) == NULL) {
+		properties_set(endpointProperties, (char *) RSA_SHM_FTOK_ID_PROPERTYNAME, (char *) RSA_SHM_DEFAULT_FTOK_ID);
+	}
+	if (properties_get(endpointProperties, (char *) RSA_SEM_PATH_PROPERTYNAME) == NULL) {
+		char sharedIdentifierFile[RSA_FILEPATH_LENGTH];
+
+		if (remoteServiceAdmin_getSharedIdentifierFile(admin, uuid, interface, sharedIdentifierFile) == CELIX_SUCCESS) {
+			properties_set(endpointProperties, (char *) RSA_SEM_PATH_PROPERTYNAME, sharedIdentifierFile);
+		} else {
+			properties_set(endpointProperties, (char *) RSA_SEM_PATH_PROPERTYNAME, (char *) RSA_SEM_DEFAULTPATH);
+		}
+	}
+	if (properties_get(endpointProperties, (char *) RSA_SEM_FTOK_ID_PROPERTYNAME) == NULL) {
+		properties_set(endpointProperties, (char *) RSA_SEM_FTOK_ID_PROPERTYNAME, (char *) RSA_SEM_DEFAULT_FTOK_ID);
+	}
+
+	endpoint_description_pt endpointDescription = NULL;
+	remoteServiceAdmin_createEndpointDescription(admin, reference, endpointProperties, interface, &endpointDescription);
+	exportRegistration_setEndpointDescription(registration, endpointDescription);
+
+	free(key);
+	free(serviceId);
+	free(keys);
+
+	return status;
 }
 
 celix_status_t remoteServiceAdmin_createEndpointDescription(remote_service_admin_pt admin, service_reference_pt reference, properties_pt endpointProperties, char *interface, endpoint_description_pt *description) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    *description = calloc(1, sizeof(**description));
-    if (!*description) {
-        status = CELIX_ENOMEM;
-    } else {
-        if (status == CELIX_SUCCESS) {
-            (*description)->properties = endpointProperties;
-            (*description)->frameworkUUID = properties_get(endpointProperties, (char*) OSGI_RSA_ENDPOINT_FRAMEWORK_UUID);
-            char *serviceId = NULL;
-            serviceReference_getProperty(reference, (char*) OSGI_FRAMEWORK_SERVICE_ID, &serviceId);
-            (*description)->serviceId = strtoull(serviceId, NULL, 0);
-            (*description)->id = properties_get(endpointProperties, (char*) OSGI_RSA_ENDPOINT_ID);
-            (*description)->service = interface;
-        }
-    }
-
-    return status;
+	celix_status_t status = CELIX_SUCCESS;
+
+	*description = calloc(1, sizeof(**description));
+	if (!*description) {
+		status = CELIX_ENOMEM;
+	} else {
+		if (status == CELIX_SUCCESS) {
+			(*description)->properties = endpointProperties;
+			(*description)->frameworkUUID = properties_get(endpointProperties, (char*) OSGI_RSA_ENDPOINT_FRAMEWORK_UUID);
+			char *serviceId = NULL;
+			serviceReference_getProperty(reference, (char*) OSGI_FRAMEWORK_SERVICE_ID, &serviceId);
+			(*description)->serviceId = strtoull(serviceId, NULL, 0);
+			(*description)->id = properties_get(endpointProperties, (char*) OSGI_RSA_ENDPOINT_ID);
+			(*description)->service = interface;
+		}
+	}
+
+	return status;
 }
 
 celix_status_t remoteServiceAdmin_destroyEndpointDescription(endpoint_description_pt *description) {
-    celix_status_t status = CELIX_SUCCESS;
+	celix_status_t status = CELIX_SUCCESS;
 
-    properties_destroy((*description)->properties);
-    free(*description);
+	properties_destroy((*description)->properties);
+	free(*description);
 
-    return status;
+	return status;
 }
 
 celix_status_t remoteServiceAdmin_getExportedServices(remote_service_admin_pt admin, array_list_pt *services) {
-    celix_status_t status = CELIX_SUCCESS;
-    return status;
+	celix_status_t status = CELIX_SUCCESS;
+	return status;
 }
 
 celix_status_t remoteServiceAdmin_getImportedEndpoints(remote_service_admin_pt admin, array_list_pt *services) {
-    celix_status_t status = CELIX_SUCCESS;
-    return status;
+	celix_status_t status = CELIX_SUCCESS;
+	return status;
 }
 
 celix_status_t remoteServiceAdmin_importService(remote_service_admin_pt admin, endpoint_description_pt endpointDescription, import_registration_pt *registration) {
-    celix_status_t status = CELIX_SUCCESS;
+	celix_status_t status = CELIX_SUCCESS;
 
-    logHelper_log(admin->loghelper, OSGI_LOGSERVICE_INFO, "RSA: Import service %s", endpointDescription->service);
+	logHelper_log(admin->loghelper, OSGI_LOGSERVICE_INFO, "RSA: Import service %s", endpointDescription->service);
 
-    celixThreadMutex_lock(&admin->importedServicesLock);
+	celixThreadMutex_lock(&admin->importedServicesLock);
 
-    import_registration_factory_pt registration_factory = (import_registration_factory_pt) hashMap_get(admin->importedServices, endpointDescription->service);
+	import_registration_factory_pt registration_factory = (import_registration_factory_pt) hashMap_get(admin->importedServices, endpointDescription->service);
 
-    // check whether we already have a registration_factory registered in the hashmap
-    if (registration_factory == NULL) {
-        status = importRegistrationFactory_install(admin->loghelper, endpointDescription->service, admin->context, &registration_factory);
-        if (status == CELIX_SUCCESS) {
-            hashMap_put(admin->importedServices, endpointDescription->service, registration_factory);
-        }
-    }
+	// check whether we already have a registration_factory registered in the hashmap
+	if (registration_factory == NULL) {
+		status = importRegistrationFactory_install(admin->loghelper, endpointDescription->service, admin->context, &registration_factory);
+		if (status == CELIX_SUCCESS) {
+			hashMap_put(admin->importedServices, endpointDescription->service, registration_factory);
+		}
+	}
 
-    // factory available
-    if (status != CELIX_SUCCESS || (registration_factory->trackedFactory == NULL)) {
-        logHelper_log(admin->loghelper, OSGI_LOGSERVICE_WARNING, "RSA: no proxyFactory available.");
-        if (status == CELIX_SUCCESS) {
-            status = CELIX_SERVICE_EXCEPTION;
-        }
-    } else {
-        // we create an importRegistration per imported service
-        importRegistration_create(endpointDescription, admin, (sendToHandle) &remoteServiceAdmin_send, admin->context, registration);
-        registration_factory->trackedFactory->registerProxyService(registration_factory->trackedFactory->factory, endpointDescription, admin, (sendToHandle) &remoteServiceAdmin_send);
+	// factory available
+	if (status != CELIX_SUCCESS || (registration_factory->trackedFactory == NULL)) {
+		logHelper_log(admin->loghelper, OSGI_LOGSERVICE_WARNING, "RSA: no proxyFactory available.");
+		if (status == CELIX_SUCCESS) {
+			status = CELIX_SERVICE_EXCEPTION;
+		}
+	} else {
+		// we create an importRegistration per imported service
+		importRegistration_create(endpointDescription, admin, (sendToHandle) &remoteServiceAdmin_send, admin->context, registration);
+		registration_factory->trackedFactory->registerProxyService(registration_factory->trackedFactory->factory, endpointDescription, admin, (sendToHandle) &remoteServiceAdmin_send);
 
-        arrayList_add(registration_factory->registrations, *registration);
-        remoteServiceAdmin_createOrAttachShm(admin->importedIpcSegment, admin, endpointDescription, false);
-    }
+		arrayList_add(registration_factory->registrations, *registration);
+		remoteServiceAdmin_createOrAttachShm(admin->importedIpcSegment, admin, endpointDescription, false);
+	}
 
-    celixThreadMutex_unlock(&admin->importedServicesLock);
+	celixThreadMutex_unlock(&admin->importedServicesLock);
 
-    return status;
+	return status;
 }
 
 celix_status_t remoteServiceAdmin_removeImportedService(remote_service_admin_pt admin, import_registration_pt registration) {
-    celix_status_t status = CELIX_SUCCESS;
+	celix_status_t status = CELIX_SUCCESS;
 
-    if (registration != NULL) {
+	if (registration != NULL) {
 
-        celixThreadMutex_lock(&admin->importedServicesLock);
+		celixThreadMutex_lock(&admin->importedServicesLock);
 
-        ipc_segment_pt ipc = NULL;
-        endpoint_description_pt endpointDescription = (endpoint_description_pt) registration->endpointDescription;
-        import_registration_factory_pt registration_factory = (import_registration_factory_pt) hashMap_get(admin->importedServices, endpointDescription->service);
+		ipc_segment_pt ipc = NULL;
+		endpoint_description_pt endpointDescription = (endpoint_description_pt) registration->endpointDescription;
+		import_registration_factory_pt registration_factory = (import_registration_factory_pt) hashMap_get(admin->importedServices, endpointDescription->service);
 
-        // detach from IPC
-        if (remoteServiceAdmin_getIpcSegment(admin, endpointDescription, &ipc) != CELIX_SUCCESS) {
-            logHelper_log(admin->loghelper, OSGI_LOGSERVICE_ERROR, "Error while retrieving IPC segment for imported service %s.", endpointDescription->service);
-        } else if (remoteServiceAdmin_detachIpcSegment(ipc) != CELIX_SUCCESS) {
-            logHelper_log(admin->loghelper, OSGI_LOGSERVICE_ERROR, "Error while detaching IPC segment for imported service %s.", endpointDescription->service);
-        }
+		// detach from IPC
+		if (remoteServiceAdmin_getIpcSegment(admin, endpointDescription, &ipc) != CELIX_SUCCESS) {
+			logHelper_log(admin->loghelper, OSGI_LOGSERVICE_ERROR, "Error while retrieving IPC segment for imported service %s.", endpointDescription->service);
+		} else if (remoteServiceAdmin_detachIpcSegment(ipc) != CELIX_SUCCESS) {
+			logHelper_log(admin->loghelper, OSGI_LOGSERVICE_ERROR, "Error while detaching IPC segment for imported service %s.", endpointDescription->service);
+		}
 
-        ipc = hashMap_remove(admin->importedIpcSegment,endpointDescription);
-        if(ipc!=NULL){
-        	free(ipc);
-        }
+		ipc = hashMap_remove(admin->importedIpcSegment,endpointDescription);
+		if(ipc!=NULL){
+			free(ipc);
+		}
 
-        // factory available
-        if ((registration_factory == NULL) || (registration_factory->trackedFactory == NULL)) {
-            logHelper_log(admin->loghelper, OSGI_LOGSERVICE_ERROR, "Error while retrieving registration factory for imported service %s.", endpointDescription->service);
-        } else {
-            registration_factory->trackedFactory->unregisterProxyService(registration_factory->trackedFactory->factory, endpointDescription);
-            arrayList_removeElement(registration_factory->registrations, registration);
-            importRegistration_destroy(registration);
+		// factory available
+		if ((registration_factory == NULL) || (registration_factory->trackedFactory == NULL)) {
+			logHelper_log(admin->loghelper, OSGI_LOGSERVICE_ERROR, "Error while retrieving registration factory for imported service %s.", endpointDescription->service);
+		} else {
+			registration_factory->trackedFactory->unregisterProxyService(registration_factory->trackedFactory->factory, endpointDescription);
+			arrayList_removeElement(registration_factory->registrations, registration);
+			importRegistration_destroy(registration);
 
-            if (arrayList_isEmpty(registration_factory->registrations) == true) {
-                logHelper_log(admin->loghelper, OSGI_LOGSERVICE_INFO, "closing proxy");
+			if (arrayList_isEmpty(registration_factory->registrations) == true) {
+				logHelper_log(admin->loghelper, OSGI_LOGSERVICE_INFO, "closing proxy");
 
-                serviceTracker_close(registration_factory->proxyFactoryTracker);
-                importRegistrationFactory_close(registration_factory);
+				serviceTracker_close(registration_factory->proxyFactoryTracker);
+				importRegistrationFactory_close(registration_factory);
 
-                hashMap_remove(admin->importedServices, endpointDescription->service);
+				hashMap_remove(admin->importedServices, endpointDescription->service);
 
-                importRegistrationFactory_destroy(&registration_factory);
-            }
-        }
+				importRegistrationFactory_destroy(&registration_factory);
+			}
+		}
 
-        celixThreadMutex_unlock(&admin->importedServicesLock);
-    }
+		celixThreadMutex_unlock(&admin->importedServicesLock);
+	}
 
-    return status;
+	return status;
 }


Mime
View raw message