Author: bpetri
Date: Sat Jul 26 00:19:31 2014
New Revision: 1613541
URL: http://svn.apache.org/r1613541
Log:
CELIX-129, CELIX-130
Adapt remote_service_admin_shm, discovery_shm. See CELIX-129, CELIX-130 for
details.
Modified:
celix/trunk/remote_services/discovery_shm/private/src/discovery.c
celix/trunk/remote_services/remote_service_admin_shm/private/src/remote_service_admin_impl.c
celix/trunk/remote_services/remote_service_admin_shm/public/include/remote_service_admin_shm.h
Modified: celix/trunk/remote_services/discovery_shm/private/src/discovery.c
URL:
http://svn.apache.org/viewvc/celix/trunk/remote_services/discovery_shm/private/src/discovery.c?rev=1613541&r1=1613540&r2=1613541&view=diff
==============================================================================
--- celix/trunk/remote_services/discovery_shm/private/src/discovery.c (original)
+++ celix/trunk/remote_services/discovery_shm/private/src/discovery.c Sat Jul
26 00:19:31 2014
@@ -370,7 +370,6 @@ celix_status_t discovery_decShmMapDiscov
}
hashMapIterator_destroy(shmItr);
-
hashMap_put(outRegServices, DISCOVERY_SHM_FW_SERVICES,
fwServices);
}
}
@@ -488,13 +487,43 @@ celix_status_t discovery_encShmMap(disco
hashMapIterator_destroy(regDiscoveryInstancesItr);
if ((status == CELIX_SUCCESS) && ((status =
netstring_encodeFromHashMap(discovery->pool, inRegDiscInstances, outEncMap)) !=
CELIX_SUCCESS))
- {
+ {
printf("DISCOVERY: discovery_encShmMapDiscoveryInstance :
encode shm map failed\n");
}
return status;
}
+
+celix_status_t discovery_freeShmMap(discovery_pt discovery, hash_map_pt
inSrcMap)
+{
+ hash_map_iterator_pt regDiscoveryInstancesItr =
hashMapIterator_create(inSrcMap);
+
+ while (hashMapIterator_hasNext(regDiscoveryInstancesItr) == true)
+ {
+ hash_map_pt regDiscoveryInstance =
hashMapIterator_nextValue(regDiscoveryInstancesItr);
+
+ if (regDiscoveryInstance != NULL)
+ {
+ hash_map_iterator_pt regDiscoveryServiceItr =
hashMapIterator_create(regDiscoveryInstance);
+
+ while (hashMapIterator_hasNext(regDiscoveryServiceItr)
== true)
+ {
+ hash_map_pt regDiscoveryService =
hashMapIterator_nextValue(regDiscoveryServiceItr);
+ hashMap_destroy(regDiscoveryService, false,
false);
+ }
+
+ hashMapIterator_destroy(regDiscoveryServiceItr);
+
+ }
+ hashMap_destroy(regDiscoveryInstance, false, false);
+ }
+
+ hashMapIterator_destroy(regDiscoveryInstancesItr);
+
+ return CELIX_SUCCESS;
+}
+
celix_status_t discovery_updateSHMServices(discovery_pt discovery,
endpoint_description_pt endpoint, bool addService)
{
celix_status_t status = CELIX_SUCCESS;
@@ -977,6 +1006,7 @@ celix_status_t discovery_updateLocalSHMS
hashMapIterator_destroy(lclFwItr);
+ discovery_freeShmMap(discovery, regDiscoveryInstances);
}
hashMap_destroy(regDiscoveryInstances, false, false);
discovery_unlock(shmData->semId, 0);
Modified:
celix/trunk/remote_services/remote_service_admin_shm/private/src/remote_service_admin_impl.c
URL:
http://svn.apache.org/viewvc/celix/trunk/remote_services/remote_service_admin_shm/private/src/remote_service_admin_impl.c?rev=1613541&r1=1613540&r2=1613541&view=diff
==============================================================================
---
celix/trunk/remote_services/remote_service_admin_shm/private/src/remote_service_admin_impl.c
(original)
+++
celix/trunk/remote_services/remote_service_admin_shm/private/src/remote_service_admin_impl.c
Sat Jul 26 00:19:31 2014
@@ -270,7 +270,7 @@ celix_status_t remoteServiceAdmin_wait(i
}
-celix_status_t remoteServiceAdmin_send(remote_service_admin_pt admin,
endpoint_description_pt recpEndpoint, char *method, char *data, char **reply,
int *replyStatus)
+celix_status_t remoteServiceAdmin_send(remote_service_admin_pt admin,
endpoint_description_pt recpEndpoint, char *data, char **reply, int
*replyStatus)
{
celix_status_t status = CELIX_SUCCESS;
@@ -283,7 +283,6 @@ celix_status_t remoteServiceAdmin_send(r
int semid = ipc->semId;
/* write method and data */
- hashMap_put(fncCallProps, RSA_FUNCTIONCALL_METHOD_PROPERTYNAME,
method);
hashMap_put(fncCallProps, RSA_FUNCTIONCALL_DATA_PROPERTYNAME, data);
if ((status = netstring_encodeFromHashMap(admin->pool, fncCallProps,
&encFncCallProps)) == CELIX_SUCCESS)
@@ -358,67 +357,60 @@ static void *APR_THREAD_FUNC remoteServi
}
else
{
- char *method = hashMap_get(receivedMethodCall,
RSA_FUNCTIONCALL_METHOD_PROPERTYNAME);
char *data = hashMap_get(receivedMethodCall,
RSA_FUNCTIONCALL_DATA_PROPERTYNAME);
- if (method == NULL)
- {
- fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "RSA :
receiveFromSharedMemory : no method found.");
- }
- else
- {
- 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;
+
+ 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;
+ char *encReply
= NULL;
+
+ celix_status_t
replyStatus = export->endpoint->handleRequest(export->endpoint->endpoint, data,
&reply);
+
hashMap_put(receivedMethodCall, RSA_FUNCTIONCALL_RETURNSTATUS_PROPERTYNAME,
apr_itoa(admin->pool, replyStatus));
+
+ if (reply !=
NULL)
+ {
+
hashMap_put(receivedMethodCall, RSA_FUNCTIONCALL_RETURN_PROPERTYNAME, reply);
+
+ //
write back
+ if
((status = netstring_encodeFromHashMap(admin->pool, receivedMethodCall,
&encReply)) == CELIX_SUCCESS)
+ {
+
+
if ((strlen(encReply) * sizeof(char)) >= RSA_SHM_MEMSIZE)
+
{
+
fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "RSA : receiveFromSharedMemory
: size of message bigger than shared memory message. NOT SENDING.");
+
}
+
else
+
{
+
strcpy(ipc->shmBaseAdress, encReply);
+
}
+ }
+ else
+ {
+
fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "RSA : receiveFromSharedMemory :
encoding of reply failed");
+ }
+ }
+ }
+ else
+ {
+ printf("RSA :
receiveFromSharedMemory : No endpoint set for %s\n",
export->endpointDescription->service );
+ }
+ }
+ }
+ hashMapIterator_destroy(iter);
- 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);
-
- if ( (strcmp(exportedEndpointDesc->service,
export->endpointDescription->service) == 0) && (export->endpoint != NULL))
- {
- char *reply = NULL;
- char *encReply = NULL;
-
- celix_status_t replyStatus =
export->endpoint->handleRequest(export->endpoint->endpoint, method, data,
&reply);
- hashMap_put(receivedMethodCall,
RSA_FUNCTIONCALL_RETURNSTATUS_PROPERTYNAME, apr_itoa(admin->pool, replyStatus));
-
- if (reply != NULL)
- {
- hashMap_put(receivedMethodCall,
RSA_FUNCTIONCALL_RETURN_PROPERTYNAME, reply);
-
- // write back
- if ((status =
netstring_encodeFromHashMap(admin->pool, receivedMethodCall, &encReply)) ==
CELIX_SUCCESS)
- {
-
- if ((strlen(encReply) *
sizeof(char)) >= RSA_SHM_MEMSIZE)
- {
- fw_log(logger,
OSGI_FRAMEWORK_LOG_ERROR, "RSA : receiveFromSharedMemory : size of message
bigger than shared memory message. NOT SENDING.");
- }
- else
- {
- strcpy(ipc->shmBaseAdress,
encReply);
- }
- }
- else
- {
- fw_log(logger,
OSGI_FRAMEWORK_LOG_ERROR, "RSA : receiveFromSharedMemory : encoding of reply
failed");
- }
- }
- }
- else
- {
- printf("RSA : receiveFromSharedMemory : No
endpoint set for %s\n", export->endpointDescription->service );
- }
- }
- }
- hashMapIterator_destroy(iter);
- }
}
hashMap_destroy(receivedMethodCall, false,
false);
remoteServiceAdmin_unlock(ipc->semId, 2);
Modified:
celix/trunk/remote_services/remote_service_admin_shm/public/include/remote_service_admin_shm.h
URL:
http://svn.apache.org/viewvc/celix/trunk/remote_services/remote_service_admin_shm/public/include/remote_service_admin_shm.h?rev=1613541&r1=1613540&r2=1613541&view=diff
==============================================================================
---
celix/trunk/remote_services/remote_service_admin_shm/public/include/remote_service_admin_shm.h
(original)
+++
celix/trunk/remote_services/remote_service_admin_shm/public/include/remote_service_admin_shm.h
Sat Jul 26 00:19:31 2014
@@ -27,7 +27,6 @@
#ifndef REMOTE_SERVICE_ADMIN_SHM_H_
#define REMOTE_SERVICE_ADMIN_SHM_H_
-#define RSA_FUNCTIONCALL_METHOD_PROPERTYNAME "method"
#define RSA_FUNCTIONCALL_DATA_PROPERTYNAME "data"
#define RSA_FUNCTIONCALL_RETURN_PROPERTYNAME "reply"
#define RSA_FUNCTIONCALL_RETURNSTATUS_PROPERTYNAME "replyStatus"