celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bpe...@apache.org
Subject svn commit: r1647679 - in /celix/trunk/remote_services: remote_service_admin/private/include/ remote_service_admin/private/src/ remote_service_admin/public/include/ remote_service_admin_http/ remote_service_admin_http/private/include/ remote_service_ad...
Date Tue, 23 Dec 2014 21:31:36 GMT
Author: bpetri
Date: Tue Dec 23 21:31:35 2014
New Revision: 1647679

URL: http://svn.apache.org/r1647679
Log:
CELIX-119: remove apr from RSA_HTTP (this will breake the RSA_SHM for now)



Modified:
    celix/trunk/remote_services/remote_service_admin/private/include/export_registration_impl.h
    celix/trunk/remote_services/remote_service_admin/private/include/import_registration_impl.h
    celix/trunk/remote_services/remote_service_admin/private/include/remote_service_admin_impl.h
    celix/trunk/remote_services/remote_service_admin/private/src/export_registration_impl.c
    celix/trunk/remote_services/remote_service_admin/private/src/import_registration_impl.c
    celix/trunk/remote_services/remote_service_admin/public/include/remote_service_admin.h
    celix/trunk/remote_services/remote_service_admin_http/CMakeLists.txt
    celix/trunk/remote_services/remote_service_admin_http/private/include/remote_service_admin_http_impl.h
    celix/trunk/remote_services/remote_service_admin_http/private/src/remote_service_admin_activator.c
    celix/trunk/remote_services/remote_service_admin_http/private/src/remote_service_admin_impl.c

Modified: celix/trunk/remote_services/remote_service_admin/private/include/export_registration_impl.h
URL: http://svn.apache.org/viewvc/celix/trunk/remote_services/remote_service_admin/private/include/export_registration_impl.h?rev=1647679&r1=1647678&r2=1647679&view=diff
==============================================================================
--- celix/trunk/remote_services/remote_service_admin/private/include/export_registration_impl.h
(original)
+++ celix/trunk/remote_services/remote_service_admin/private/include/export_registration_impl.h
Tue Dec 23 21:31:35 2014
@@ -33,7 +33,6 @@
 #include "log_helper.h"
 
 struct export_registration {
-	apr_pool_t *pool;
 	bundle_context_pt context;
 	remote_service_admin_pt rsa;
 	endpoint_description_pt endpointDescription;
@@ -51,7 +50,7 @@ struct export_registration {
 	bool closed;
 };
 
-celix_status_t exportRegistration_create(apr_pool_t *pool, log_helper_pt helper, service_reference_pt
reference, endpoint_description_pt endpoint, remote_service_admin_pt rsa, bundle_context_pt
context, export_registration_pt *registration);
+celix_status_t exportRegistration_create(log_helper_pt helper, service_reference_pt reference,
endpoint_description_pt endpoint, remote_service_admin_pt rsa, bundle_context_pt context,
export_registration_pt *registration);
 celix_status_t exportRegistration_destroy(export_registration_pt *registration);
 celix_status_t exportRegistration_open(export_registration_pt registration);
 celix_status_t exportRegistration_close(export_registration_pt registration);

Modified: celix/trunk/remote_services/remote_service_admin/private/include/import_registration_impl.h
URL: http://svn.apache.org/viewvc/celix/trunk/remote_services/remote_service_admin/private/include/import_registration_impl.h?rev=1647679&r1=1647678&r2=1647679&view=diff
==============================================================================
--- celix/trunk/remote_services/remote_service_admin/private/include/import_registration_impl.h
(original)
+++ celix/trunk/remote_services/remote_service_admin/private/include/import_registration_impl.h
Tue Dec 23 21:31:35 2014
@@ -33,7 +33,6 @@
 #include "log_helper.h"
 
 struct import_registration {
-	apr_pool_t *pool;
 	bundle_context_pt context;
 	endpoint_description_pt endpointDescription;
 
@@ -50,7 +49,6 @@ struct import_registration {
 
 struct import_registration_factory
 {
-	apr_pool_t *pool;
 	char* serviceName;
 	log_helper_pt loghelper;
 	remote_proxy_factory_service_pt trackedFactory;
@@ -61,7 +59,7 @@ struct import_registration_factory
 };
 
 
-celix_status_t importRegistration_create(apr_pool_t *pool, endpoint_description_pt endpoint,
remote_service_admin_pt rsa, sendToHandle callback, bundle_context_pt context, import_registration_pt
*registration);
+celix_status_t importRegistration_create(endpoint_description_pt endpoint, remote_service_admin_pt
rsa, sendToHandle callback, bundle_context_pt context, import_registration_pt *registration);
 celix_status_t importRegistration_destroy(import_registration_pt registration);
 
 celix_status_t importRegistration_setEndpointDescription(import_registration_pt registration,
endpoint_description_pt endpointDescription);
@@ -77,7 +75,7 @@ celix_status_t importRegistration_create
 celix_status_t importRegistrationFactory_destroy(import_registration_factory_pt* registration_factory);
 //celix_status_t importRegistrationFactory_open(import_registration_factory_pt registration_factory);
 celix_status_t importRegistrationFactory_close(import_registration_factory_pt registration_factory);
-celix_status_t importRegistrationFactory_install(apr_pool_t *pool, log_helper_pt helper,
char* serviceName, bundle_context_pt context, import_registration_factory_pt *registration_factory);
+celix_status_t importRegistrationFactory_install(log_helper_pt helper, char* serviceName,
bundle_context_pt context, import_registration_factory_pt *registration_factory);
 
 
 

Modified: celix/trunk/remote_services/remote_service_admin/private/include/remote_service_admin_impl.h
URL: http://svn.apache.org/viewvc/celix/trunk/remote_services/remote_service_admin/private/include/remote_service_admin_impl.h?rev=1647679&r1=1647678&r2=1647679&view=diff
==============================================================================
--- celix/trunk/remote_services/remote_service_admin/private/include/remote_service_admin_impl.h
(original)
+++ celix/trunk/remote_services/remote_service_admin/private/include/remote_service_admin_impl.h
Tue Dec 23 21:31:35 2014
@@ -42,8 +42,8 @@ struct import_reference {
 	service_reference_pt reference;
 };
 
-celix_status_t remoteServiceAdmin_create(apr_pool_t *pool, bundle_context_pt context, remote_service_admin_pt
*admin);
-celix_status_t remoteServiceAdmin_destroy(remote_service_admin_pt admin);
+celix_status_t remoteServiceAdmin_create(bundle_context_pt context, remote_service_admin_pt
*admin);
+celix_status_t remoteServiceAdmin_destroy(remote_service_admin_pt *admin);
 
 celix_status_t remoteServiceAdmin_send(remote_service_admin_pt rsa, endpoint_description_pt
endpointDescription, char *methodSignature, char **reply, int* replyStatus);
 

Modified: celix/trunk/remote_services/remote_service_admin/private/src/export_registration_impl.c
URL: http://svn.apache.org/viewvc/celix/trunk/remote_services/remote_service_admin/private/src/export_registration_impl.c?rev=1647679&r1=1647678&r2=1647679&view=diff
==============================================================================
--- celix/trunk/remote_services/remote_service_admin/private/src/export_registration_impl.c
(original)
+++ celix/trunk/remote_services/remote_service_admin/private/src/export_registration_impl.c
Tue Dec 23 21:31:35 2014
@@ -25,8 +25,6 @@
  */
 #include <stdlib.h>
 
-#include <apr_strings.h>
-
 #include "constants.h"
 
 #include "celix_errno.h"
@@ -45,16 +43,13 @@ celix_status_t exportRegistration_endpoi
 
 celix_status_t exportRegistration_createEndpointTracker(export_registration_pt registration,
service_tracker_pt *tracker);
 
-celix_status_t exportRegistration_create(apr_pool_t *pool, log_helper_pt helper, service_reference_pt
reference, endpoint_description_pt endpoint, remote_service_admin_pt rsa, bundle_context_pt
context, export_registration_pt *registration) {
+celix_status_t exportRegistration_create(log_helper_pt helper, service_reference_pt reference,
endpoint_description_pt endpoint, remote_service_admin_pt rsa, bundle_context_pt context,
export_registration_pt *registration) {
 	celix_status_t status = CELIX_SUCCESS;
-	apr_pool_t *mypool = NULL;
-	apr_pool_create(&mypool, pool);
 
 	*registration = calloc(1, sizeof(**registration));
 	if (!*registration) {
 		status = CELIX_ENOMEM;
 	} else {
-		(*registration)->pool = mypool;
 		(*registration)->context = context;
 		(*registration)->closed = false;
 		(*registration)->endpointDescription = endpoint;
@@ -127,7 +122,9 @@ celix_status_t exportRegistration_create
 			exportRegistration_endpointAdded, exportRegistration_endpointModified, exportRegistration_endpointRemoved,
&customizer);
 
 	if (status == CELIX_SUCCESS) {
-		char *filter = apr_pstrcat(registration->pool, "(&(", OSGI_FRAMEWORK_OBJECTCLASS,
"=", OSGI_RSA_REMOTE_ENDPOINT, ")(remote.interface=", registration->endpointDescription->service,
"))", NULL);
+		char filter[512];
+
+		snprintf(filter, 512, "(&(%s=%s)(remote.interface=%s))", (char*) OSGI_FRAMEWORK_OBJECTCLASS,
(char*) OSGI_RSA_REMOTE_ENDPOINT, registration->endpointDescription->service);
 		status = serviceTracker_createWithFilter(registration->context, filter, customizer,
tracker);
 	}
 
@@ -173,7 +170,7 @@ celix_status_t exportRegistration_endpoi
 	remote_endpoint_service_pt endpoint = service;
 	if (registration->endpoint != NULL) {
 		remoteServiceAdmin_removeExportedService(registration);
-		registration->endpoint = NULL;
+//		registration->endpoint = NULL;
 		endpoint->setService(endpoint->endpoint, NULL);
 	}
 
@@ -189,7 +186,10 @@ celix_status_t exportRegistration_open(e
 	if (bundleStore == NULL) {
 		bundleStore = DEFAULT_BUNDLE_STORE;
 	}
-	char *name = apr_pstrcat(registration->pool, bundleStore, "/", registration->endpointDescription->service,
"_endpoint.zip", NULL);
+	char name[256];
+
+	snprintf(name, 256, "%s/%s_endpoint.zip", bundleStore, registration->endpointDescription->service);
+
 	status = bundleContext_installBundle(registration->context, name, &registration->bundle);
 	if (status == CELIX_SUCCESS) {
 		status = bundle_start(registration->bundle);
@@ -222,7 +222,7 @@ celix_status_t exportRegistration_getExp
 	celix_status_t status = CELIX_SUCCESS;
 
 	if (registration->exportReference == NULL) {
-		registration->exportReference = apr_palloc(registration->pool, sizeof(*registration->exportReference));
+		registration->exportReference = calloc(1, sizeof(*registration->exportReference));
 		if (registration->exportReference == NULL) {
 			status = CELIX_ENOMEM;
 		} else {

Modified: celix/trunk/remote_services/remote_service_admin/private/src/import_registration_impl.c
URL: http://svn.apache.org/viewvc/celix/trunk/remote_services/remote_service_admin/private/src/import_registration_impl.c?rev=1647679&r1=1647678&r2=1647679&view=diff
==============================================================================
--- celix/trunk/remote_services/remote_service_admin/private/src/import_registration_impl.c
(original)
+++ celix/trunk/remote_services/remote_service_admin/private/src/import_registration_impl.c
Tue Dec 23 21:31:35 2014
@@ -26,8 +26,6 @@
 
 #include <stdlib.h>
 
-#include <apr_strings.h>
-
 #include <constants.h>
 
 #include "celix_errno.h"
@@ -45,16 +43,13 @@ celix_status_t importRegistration_proxyF
 celix_status_t importRegistration_proxyFactoryModified(void * handle, service_reference_pt
reference, void *service);
 celix_status_t importRegistration_proxyFactoryRemoved(void * handle, service_reference_pt
reference, void *service);
 
-celix_status_t importRegistration_create(apr_pool_t *pool, endpoint_description_pt endpoint,
remote_service_admin_pt rsa, 	sendToHandle sendToCallback, bundle_context_pt context, import_registration_pt
*registration) {
+celix_status_t importRegistration_create(endpoint_description_pt endpoint, remote_service_admin_pt
rsa, 	sendToHandle sendToCallback, bundle_context_pt context, import_registration_pt *registration)
{
 	celix_status_t status = CELIX_SUCCESS;
-	apr_pool_t *mypool = NULL;
-	apr_pool_create(&mypool, pool);
 
-	*registration = apr_palloc(mypool, sizeof(**registration));
+	*registration = calloc(1, sizeof(**registration));
 	if (!*registration) {
 		status = CELIX_ENOMEM;
 	} else {
-		(*registration)->pool = mypool;
 		(*registration)->context = context;
 		(*registration)->closed = false;
 		(*registration)->endpointDescription = endpoint;
@@ -73,17 +68,14 @@ celix_status_t importRegistration_destro
 }
 
 
-celix_status_t importRegistrationFactory_create(apr_pool_t *pool, log_helper_pt helper, char*
serviceName, bundle_context_pt context, import_registration_factory_pt *registration_factory)
{
+celix_status_t importRegistrationFactory_create(log_helper_pt helper, char* serviceName,
bundle_context_pt context, import_registration_factory_pt *registration_factory) {
 	celix_status_t status = CELIX_SUCCESS;
-	apr_pool_t *mypool = NULL;
-	apr_pool_create(&mypool, pool);
 
 	*registration_factory = calloc(1, sizeof(**registration_factory));
 	if (!*registration_factory) {
 		status = CELIX_ENOMEM;
 	} else {
 		(*registration_factory)->serviceName = strdup(serviceName);
-		(*registration_factory)->pool = mypool;
 		(*registration_factory)->context = context;
 		(*registration_factory)->bundle = NULL;
 		(*registration_factory)->loghelper = helper;
@@ -124,7 +116,9 @@ celix_status_t importRegistrationFactory
 		bundleStore = DEFAULT_BUNDLE_STORE;
 	}
 
-	char *name = apr_pstrcat(registration_factory->pool, bundleStore, "/", registration_factory->serviceName,
"_proxy.zip", NULL);
+	char name[256];
+	snprintf(name, 256, "%s/%s_proxy.zip", bundleStore, registration_factory->serviceName);
+
 	status = bundleContext_installBundle(registration_factory->context, name, &registration_factory->bundle);
 
 	if (status == CELIX_SUCCESS) {
@@ -164,7 +158,9 @@ celix_status_t importRegistration_create
 	status = serviceTrackerCustomizer_create(registration_factory, importRegistration_proxyFactoryAdding,
importRegistration_proxyFactoryAdded, importRegistration_proxyFactoryModified, importRegistration_proxyFactoryRemoved,
&customizer);
 
 	if (status == CELIX_SUCCESS) {
-		char *filter = apr_pstrcat(registration_factory->pool, "(&(", OSGI_FRAMEWORK_OBJECTCLASS,
"=", OSGI_RSA_REMOTE_PROXY_FACTORY,")(proxy.interface=", registration_factory->serviceName,
"))", NULL);
+		char filter[512];
+
+		snprintf(filter, 512, "(&(%s=%s)(proxy.interface=%s))", (char*) OSGI_FRAMEWORK_OBJECTCLASS,
(char*) OSGI_RSA_REMOTE_PROXY_FACTORY, registration_factory->serviceName);
 		status = serviceTracker_createWithFilter(registration_factory->context, filter, customizer,
tracker);
 
 		if (status == CELIX_SUCCESS)
@@ -212,11 +208,11 @@ celix_status_t importRegistration_proxyF
 
 
 
-celix_status_t importRegistrationFactory_install(apr_pool_t *pool, log_helper_pt helper,
char* serviceName, bundle_context_pt context, import_registration_factory_pt *registration_factory)
+celix_status_t importRegistrationFactory_install(log_helper_pt helper, char* serviceName,
bundle_context_pt context, import_registration_factory_pt *registration_factory)
 {
 	celix_status_t status = CELIX_BUNDLE_EXCEPTION;
 
-	if ( (status = importRegistrationFactory_create(pool, helper, serviceName, context, registration_factory))
== CELIX_SUCCESS) {
+	if ( (status = importRegistrationFactory_create(helper, serviceName, context, registration_factory))
== CELIX_SUCCESS) {
 		// starting the proxy tracker first allows us to pick up already available proxy factories
 		importRegistration_createProxyFactoryTracker(*registration_factory, &((*registration_factory)->proxyFactoryTracker));
 		logHelper_log((*registration_factory)->loghelper, OSGI_LOGSERVICE_INFO, "remoteServiceAdmin_importService:
new registration_factory added for %s at %p", serviceName, (*registration_factory)->proxyFactoryTracker);
@@ -246,7 +242,7 @@ celix_status_t importRegistration_getImp
 	celix_status_t status = CELIX_SUCCESS;
 
 	if (registration->importReference == NULL) {
-		registration->importReference = apr_palloc(registration->pool, sizeof(*registration->importReference));
+		registration->importReference = calloc(1, sizeof(*registration->importReference));
 		if (registration->importReference == NULL) {
 			status = CELIX_ENOMEM;
 		} else {

Modified: celix/trunk/remote_services/remote_service_admin/public/include/remote_service_admin.h
URL: http://svn.apache.org/viewvc/celix/trunk/remote_services/remote_service_admin/public/include/remote_service_admin.h?rev=1647679&r1=1647678&r2=1647679&view=diff
==============================================================================
--- celix/trunk/remote_services/remote_service_admin/public/include/remote_service_admin.h
(original)
+++ celix/trunk/remote_services/remote_service_admin/public/include/remote_service_admin.h
Tue Dec 23 21:31:35 2014
@@ -42,6 +42,7 @@ typedef struct remote_service_admin *rem
 struct remote_service_admin_service {
 	remote_service_admin_pt admin;
 	celix_status_t (*exportService)(remote_service_admin_pt admin, char *serviceId, properties_pt
properties, array_list_pt *registrations);
+	celix_status_t (*removeExportedService)(export_registration_pt registration);
 	celix_status_t (*getExportedServices)(remote_service_admin_pt admin, array_list_pt *services);
 	celix_status_t (*getImportedEndpoints)(remote_service_admin_pt admin, array_list_pt *services);
 	celix_status_t (*importService)(remote_service_admin_pt admin, endpoint_description_pt endpoint,
import_registration_pt *registration);
@@ -52,6 +53,8 @@ struct remote_service_admin_service {
 	celix_status_t (*exportRegistration_close)(export_registration_pt registration);
 	celix_status_t (*exportRegistration_getException)(export_registration_pt registration);
 	celix_status_t (*exportRegistration_getExportReference)(export_registration_pt registration,
export_reference_pt *reference);
+	celix_status_t (*exportRegistration_freeExportReference)(export_reference_pt *reference);
+	celix_status_t (*exportRegistration_getEndpointDescription)(export_registration_pt registration,
endpoint_description_pt endpointDescription);
 
 	celix_status_t (*importReference_getImportedEndpoint)(import_reference_pt reference);
 	celix_status_t (*importReference_getImportedService)(import_reference_pt reference);

Modified: celix/trunk/remote_services/remote_service_admin_http/CMakeLists.txt
URL: http://svn.apache.org/viewvc/celix/trunk/remote_services/remote_service_admin_http/CMakeLists.txt?rev=1647679&r1=1647678&r2=1647679&view=diff
==============================================================================
--- celix/trunk/remote_services/remote_service_admin_http/CMakeLists.txt (original)
+++ celix/trunk/remote_services/remote_service_admin_http/CMakeLists.txt Tue Dec 23 21:31:35
2014
@@ -15,9 +15,8 @@
 # specific language governing permissions and limitations
 # under the License.
 
-find_package(APR REQUIRED)
-find_package(CURL REQUIRED)
 
+find_package(CURL REQUIRED)
 
 include_directories(${CURL_INCLUDE_DIRS})
 include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
@@ -44,4 +43,4 @@ bundle(remote_service_admin_http SOURCES
 
 install_bundle(remote_service_admin_http)
     
-target_link_libraries(remote_service_admin_http celix_framework  ${APRUTIL_LIBRARY} ${CURL_LIBRARIES})
+target_link_libraries(remote_service_admin_http celix_framework ${CURL_LIBRARIES})

Modified: celix/trunk/remote_services/remote_service_admin_http/private/include/remote_service_admin_http_impl.h
URL: http://svn.apache.org/viewvc/celix/trunk/remote_services/remote_service_admin_http/private/include/remote_service_admin_http_impl.h?rev=1647679&r1=1647678&r2=1647679&view=diff
==============================================================================
--- celix/trunk/remote_services/remote_service_admin_http/private/include/remote_service_admin_http_impl.h
(original)
+++ celix/trunk/remote_services/remote_service_admin_http/private/include/remote_service_admin_http_impl.h
Tue Dec 23 21:31:35 2014
@@ -32,7 +32,6 @@
 #include "civetweb.h"
 
 struct remote_service_admin {
-	apr_pool_t *pool;
 	bundle_context_pt context;
 	log_helper_pt loghelper;
 

Modified: celix/trunk/remote_services/remote_service_admin_http/private/src/remote_service_admin_activator.c
URL: http://svn.apache.org/viewvc/celix/trunk/remote_services/remote_service_admin_http/private/src/remote_service_admin_activator.c?rev=1647679&r1=1647678&r2=1647679&view=diff
==============================================================================
--- celix/trunk/remote_services/remote_service_admin_http/private/src/remote_service_admin_activator.c
(original)
+++ celix/trunk/remote_services/remote_service_admin_http/private/src/remote_service_admin_activator.c
Tue Dec 23 21:31:35 2014
@@ -33,33 +33,22 @@
 #include "import_registration_impl.h"
 
 struct activator {
-	apr_pool_t *pool;
 	remote_service_admin_pt admin;
 	service_registration_pt registration;
 };
 
 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;
 	struct activator *activator;
 
-	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;
-				activator->admin = NULL;
-				activator->registration = NULL;
+	activator = calloc(1, sizeof(*activator));
+	if (!activator) {
+		status = CELIX_ENOMEM;
+	} else {
+		activator->admin = NULL;
+		activator->registration = NULL;
 
-				*userData = activator;
-			}
-		}
+		*userData = activator;
 	}
 
 	return status;
@@ -70,14 +59,16 @@ celix_status_t bundleActivator_start(voi
 	struct activator *activator = userData;
 	remote_service_admin_service_pt remoteServiceAdmin = NULL;
 
-	status = remoteServiceAdmin_create(activator->pool, context, &activator->admin);
+	status = remoteServiceAdmin_create(context, &activator->admin);
 	if (status == CELIX_SUCCESS) {
-		remoteServiceAdmin = apr_palloc(activator->pool, sizeof(*remoteServiceAdmin));
+		// TODO: free
+		remoteServiceAdmin = calloc(1, sizeof(*remoteServiceAdmin));
 		if (!remoteServiceAdmin) {
 			status = CELIX_ENOMEM;
 		} else {
 			remoteServiceAdmin->admin = activator->admin;
 			remoteServiceAdmin->exportService = remoteServiceAdmin_exportService;
+
 			remoteServiceAdmin->getExportedServices = remoteServiceAdmin_getExportedServices;
 			remoteServiceAdmin->getImportedEndpoints = remoteServiceAdmin_getImportedEndpoints;
 			remoteServiceAdmin->importService = remoteServiceAdmin_importService;
@@ -111,11 +102,16 @@ celix_status_t bundleActivator_stop(void
 	serviceRegistration_unregister(activator->registration);
 	activator->registration = NULL;
 
+
 	return status;
 }
 
 celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) {
 	celix_status_t status = CELIX_SUCCESS;
+	struct activator *activator = userData;
+
+	free(activator);
+
 	return status;
 }
 

Modified: celix/trunk/remote_services/remote_service_admin_http/private/src/remote_service_admin_impl.c
URL: http://svn.apache.org/viewvc/celix/trunk/remote_services/remote_service_admin_http/private/src/remote_service_admin_impl.c?rev=1647679&r1=1647678&r2=1647679&view=diff
==============================================================================
--- celix/trunk/remote_services/remote_service_admin_http/private/src/remote_service_admin_impl.c
(original)
+++ celix/trunk/remote_services/remote_service_admin_http/private/src/remote_service_admin_impl.c
Tue Dec 23 21:31:35 2014
@@ -34,10 +34,7 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <string.h>
-#include <apr_strings.h>
-#include <apr_uuid.h>
 #include <uuid/uuid.h>
-#include <apr_network_io.h>
 
 #include <curl/curl.h>
 
@@ -95,10 +92,10 @@ static celix_status_t remoteServiceAdmin
 static size_t remoteServiceAdmin_readCallback(void *ptr, size_t size, size_t nmemb, void
*userp);
 static size_t remoteServiceAdmin_write(void *contents, size_t size, size_t nmemb, void *userp);
 
-celix_status_t remoteServiceAdmin_create(apr_pool_t *pool, bundle_context_pt context, 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 = apr_palloc(pool, sizeof(**admin));
+	*admin = calloc(1, sizeof(**admin));
 	if (!*admin) {
 		status = CELIX_ENOMEM;
 	} else {
@@ -106,8 +103,6 @@ celix_status_t remoteServiceAdmin_create
 		char *port = NULL;
 		char *ip = NULL;
 		char *detectedIp = NULL;
-
-		(*admin)->pool = pool;
 		(*admin)->context = context;
 		(*admin)->exportedServices = hashMap_create(NULL, NULL, NULL, NULL);
 		(*admin)->importedServices = hashMap_create(NULL, NULL, NULL, NULL);
@@ -142,7 +137,7 @@ celix_status_t remoteServiceAdmin_create
 
 		if (ip != NULL) {
 			logHelper_log((*admin)->loghelper, OSGI_LOGSERVICE_INFO, "RSA: Using %s for service
annunciation", ip);
-			(*admin)->ip = apr_pstrdup(pool, ip);
+			(*admin)->ip = strdup(ip);
 		}
 		else {
 			logHelper_log((*admin)->loghelper, OSGI_LOGSERVICE_WARNING, "RSA: No IP address for
service annunciation set. Using %s", DEFAULT_IP);
@@ -166,7 +161,7 @@ celix_status_t remoteServiceAdmin_create
 
 			if ((*admin)->ctx != NULL) {
 				logHelper_log((*admin)->loghelper, OSGI_LOGSERVICE_INFO, "RSA: Start webserver: %s",
port);
-				(*admin)->port = apr_pstrdup(pool, port);
+				(*admin)->port = strdup(port);
 
 			}
 			else {
@@ -191,6 +186,17 @@ celix_status_t remoteServiceAdmin_create
 	return status;
 }
 
+
+celix_status_t remoteServiceAdmin_destroy(remote_service_admin_pt *admin)
+{
+	celix_status_t status = CELIX_SUCCESS;
+
+	free(*admin);
+	*admin = NULL;
+
+	return status;
+}
+
 celix_status_t remoteServiceAdmin_stop(remote_service_admin_pt admin) {
 	celix_status_t status = CELIX_SUCCESS;
 
@@ -349,18 +355,14 @@ celix_status_t remoteServiceAdmin_export
 	arrayList_create(registrations);
 	array_list_pt references = NULL;
 	service_reference_pt reference = NULL;
-	apr_pool_t *tmpPool = NULL;
+	char filter [256];
 
-	apr_pool_create(&tmpPool, admin->pool);
-	if (tmpPool == NULL) {
-		return CELIX_ENOMEM;
-	} else {
-		char *filter = apr_pstrcat(admin->pool, "(", (char *)OSGI_FRAMEWORK_SERVICE_ID, "=",
serviceId, ")", NULL); /*FIXME memory leak*/
-		bundleContext_getServiceReferences(admin->context, NULL, filter, &references);
-		apr_pool_destroy(tmpPool);
-		if (arrayList_size(references) >= 1) {
-			reference = arrayList_get(references, 0);
-		}
+	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);
 	}
 
     if(references!=NULL){
@@ -384,26 +386,22 @@ celix_status_t remoteServiceAdmin_export
 		array_list_pt interfaces = NULL;
 		arrayList_create(&interfaces);
 		if (strcmp(utils_stringTrim(exports), "*") == 0) {
-			char *token;
-			char *interface = apr_strtok(provided, ",", &token);
+			char *interface = strtok(provided, ",");
 			while (interface != NULL) {
 				arrayList_add(interfaces, utils_stringTrim(interface));
-				interface = apr_strtok(NULL, ",", &token);
+				interface = strtok(NULL, ",");
 			}
 		} else {
-			char *exportToken;
-			char *providedToken;
-
-			char *pinterface = apr_strtok(provided, ",", &providedToken);
+			char *pinterface = strtok(provided, ",");
 			while (pinterface != NULL) {
-				char *einterface = apr_strtok(exports, ",", &exportToken);
+				char *einterface = strtok(exports, ",");
 				while (einterface != NULL) {
 					if (strcmp(einterface, pinterface) == 0) {
 						arrayList_add(interfaces, einterface);
 					}
-					einterface = apr_strtok(NULL, ",", &exportToken);
+					einterface = strtok(NULL, ",");
 				}
-				pinterface = apr_strtok(NULL, ",", &providedToken);
+				pinterface = strtok(NULL, ",");
 			}
 		}
 
@@ -413,7 +411,7 @@ celix_status_t remoteServiceAdmin_export
 				char *interface = arrayList_get(interfaces, iter);
 				export_registration_pt registration = NULL;
 
-				exportRegistration_create(admin->pool, admin->loghelper, reference, NULL, admin,
admin->context, &registration);
+				exportRegistration_create(admin->loghelper, reference, NULL, admin, admin->context,
&registration);
 				arrayList_add(*registrations, registration);
 
 				remoteServiceAdmin_installEndpoint(admin, registration, reference, interface);
@@ -469,8 +467,10 @@ celix_status_t remoteServiceAdmin_instal
 	char *uuid = NULL;
 
 	char buf[512];
-	sprintf(buf, "/service/%s/%s", serviceId, interface);
-    char *url = apr_pstrcat(admin->pool, "http://", admin->ip, ":", admin->port,
buf, NULL);
+	snprintf(buf, 512,  "/service/%s/%s", serviceId, interface);
+
+	char url[1024];
+	snprintf(url, 1024, "http://%s:%s%s", admin->ip, admin->port, buf);
 
 	uuid_t endpoint_uid;
 	uuid_generate(endpoint_uid);
@@ -540,7 +540,7 @@ celix_status_t remoteServiceAdmin_create
 		(*description)->id = properties_get(endpointProperties, (char*) OSGI_RSA_ENDPOINT_ID);
 		char *serviceId = NULL;
 		serviceReference_getProperty(reference, (char*) OSGI_FRAMEWORK_SERVICE_ID, &serviceId);
-		(*description)->serviceId = apr_atoi64(serviceId);
+		(*description)->serviceId = strtoull(serviceId, NULL, 0);
 		(*description)->frameworkUUID = properties_get(endpointProperties, (char*) OSGI_RSA_ENDPOINT_FRAMEWORK_UUID);
 		(*description)->service = interface;
 		(*description)->properties = endpointProperties;
@@ -585,7 +585,7 @@ celix_status_t remoteServiceAdmin_import
 	// check whether we already have a registration_factory registered in the hashmap
 	if (registration_factory == NULL)
 	{
-		status = importRegistrationFactory_install(admin->pool, admin->loghelper, endpointDescription->service,
admin->context, &registration_factory);
+		status = importRegistrationFactory_install(admin->loghelper, endpointDescription->service,
admin->context, &registration_factory);
 		if (status == CELIX_SUCCESS) {
 		    hashMap_put(admin->importedServices, endpointDescription->service, registration_factory);
 		}
@@ -599,7 +599,7 @@ celix_status_t remoteServiceAdmin_import
 	else
 	{
 		// we create an importRegistration per imported service
-		importRegistration_create(admin->pool, endpointDescription, admin, (sendToHandle) &remoteServiceAdmin_send,
admin->context, registration);
+		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);
@@ -662,7 +662,8 @@ celix_status_t remoteServiceAdmin_send(r
     get.writeptr = malloc(1);
 
     char *serviceUrl = properties_get(endpointDescription->properties, (char*) ENDPOINT_URL);
-    char *url = apr_pstrcat(rsa->pool, serviceUrl, NULL);
+    char url[256];
+    snprintf(url, 256, "%s", serviceUrl);
 
     celix_status_t status = CELIX_SUCCESS;
     CURL *curl;
@@ -672,9 +673,7 @@ celix_status_t remoteServiceAdmin_send(r
     if(!curl) {
         status = CELIX_ILLEGAL_STATE;
     } else {
-
-
-        curl_easy_setopt(curl, CURLOPT_URL, url);
+        curl_easy_setopt(curl, CURLOPT_URL, &url[0]);
         curl_easy_setopt(curl, CURLOPT_POST, 1L);
         curl_easy_setopt(curl, CURLOPT_READFUNCTION, remoteServiceAdmin_readCallback);
         curl_easy_setopt(curl, CURLOPT_READDATA, &post);



Mime
View raw message