CELIX-237: Added several fixed and one work around for rsa dfi issues

Project: http://git-wip-us.apache.org/repos/asf/celix/repo
Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/746b30e8
Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/746b30e8
Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/746b30e8

Branch: refs/heads/feature/CELIX-269_depman
Commit: 746b30e8dd12921dd66da61bb7b2c4e4b506d5d7
Parents: e14cc7d
Author: Pepijn Noltes <pepijnnol...@gmail.com>
Authored: Wed Oct 14 21:39:41 2015 +0200
Committer: Pepijn Noltes <pepijnnol...@gmail.com>
Committed: Wed Oct 14 21:39:41 2015 +0200

----------------------------------------------------------------------
 framework/tst/multiple_frameworks_test.cpp      |  3 ++-
 .../dynamic_function_interface/dyn_interface.c  | 18 ++++++++---------
 .../dynamic_function_interface/dyn_type.c       |  2 +-
 .../dynamic_function_interface/json_rpc.c       | 21 ++++++++++++++------
 .../rsa/private/src/import_registration_dfi.c   |  5 +++++
 .../rsa_tst/rsa_client_server_tests.cpp         |  5 ++---
 6 files changed, 34 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/746b30e8/framework/tst/multiple_frameworks_test.cpp
----------------------------------------------------------------------
diff --git a/framework/tst/multiple_frameworks_test.cpp 
b/framework/tst/multiple_frameworks_test.cpp
index b732000..4e568cd 100644
--- a/framework/tst/multiple_frameworks_test.cpp
+++ b/framework/tst/multiple_frameworks_test.cpp
@@ -68,7 +68,8 @@ extern "C" {
     }
 
     static void testFrameworks(void) {
-        printf("testing startup/shutdown mutiple frameworks\n");    }
+        printf("testing startup/shutdown mutiple frameworks\n");
+    }
 
 }
 

http://git-wip-us.apache.org/repos/asf/celix/blob/746b30e8/remote_services/remote_service_admin_dfi/dynamic_function_interface/dyn_interface.c
----------------------------------------------------------------------
diff --git 
a/remote_services/remote_service_admin_dfi/dynamic_function_interface/dyn_interface.c
 
b/remote_services/remote_service_admin_dfi/dynamic_function_interface/dyn_interface.c
index d869d16..9bb7bcc 100644
--- 
a/remote_services/remote_service_admin_dfi/dynamic_function_interface/dyn_interface.c
+++ 
b/remote_services/remote_service_admin_dfi/dynamic_function_interface/dyn_interface.c
@@ -323,15 +323,6 @@ void dynInterface_destroy(dyn_interface_type *intf) {
         dynCommon_clearNamValHead(&intf->header);
         dynCommon_clearNamValHead(&intf->annotations);
 
-        struct type_entry *tmp = NULL;
-        struct type_entry *tInfo = TAILQ_FIRST(&intf->types);
-        while (tInfo != NULL) {
-            tmp = tInfo;
-            tInfo = TAILQ_NEXT(tInfo, entries);
-            dynType_destroy(tmp->type);
-            free(tmp);
-        }
-
         struct method_entry *mTmp = NULL;
         struct method_entry *mInfo = TAILQ_FIRST(&intf->methods);
         while (mInfo != NULL) {
@@ -350,6 +341,15 @@ void dynInterface_destroy(dyn_interface_type *intf) {
             free(mTmp);
         }
 
+        struct type_entry *tmp = NULL;
+        struct type_entry *tInfo = TAILQ_FIRST(&intf->types);
+        while (tInfo != NULL) {
+            tmp = tInfo;
+            tInfo = TAILQ_NEXT(tInfo, entries);
+            dynType_destroy(tmp->type);
+            free(tmp);
+        }
+
         free(intf);
     } 
 }

http://git-wip-us.apache.org/repos/asf/celix/blob/746b30e8/remote_services/remote_service_admin_dfi/dynamic_function_interface/dyn_type.c
----------------------------------------------------------------------
diff --git 
a/remote_services/remote_service_admin_dfi/dynamic_function_interface/dyn_type.c
 
b/remote_services/remote_service_admin_dfi/dynamic_function_interface/dyn_type.c
index 972278d..35275cd 100644
--- 
a/remote_services/remote_service_admin_dfi/dynamic_function_interface/dyn_type.c
+++ 
b/remote_services/remote_service_admin_dfi/dynamic_function_interface/dyn_type.c
@@ -297,8 +297,8 @@ static int dynType_parseComplex(FILE *stream, dyn_type 
*type) {
     if (status == OK) {
         type->complex.structType.type =  FFI_TYPE_STRUCT;
         type->complex.structType.elements = calloc(count + 1, 
sizeof(ffi_type));
-        type->complex.structType.elements[count] = NULL;
         if (type->complex.structType.elements != NULL) {
+            type->complex.structType.elements[count] = NULL;
             int index = 0;
             TAILQ_FOREACH(entry, &type->complex.entriesHead, entries) {
                 type->complex.structType.elements[index++] = 
dynType_ffiType(entry->type);

http://git-wip-us.apache.org/repos/asf/celix/blob/746b30e8/remote_services/remote_service_admin_dfi/dynamic_function_interface/json_rpc.c
----------------------------------------------------------------------
diff --git 
a/remote_services/remote_service_admin_dfi/dynamic_function_interface/json_rpc.c
 
b/remote_services/remote_service_admin_dfi/dynamic_function_interface/json_rpc.c
index 756b24e..1aa0d62 100644
--- 
a/remote_services/remote_service_admin_dfi/dynamic_function_interface/json_rpc.c
+++ 
b/remote_services/remote_service_admin_dfi/dynamic_function_interface/json_rpc.c
@@ -85,6 +85,9 @@ int jsonRpc_call(dyn_interface_type *intf, void *service, 
const char *request, c
     int i;
     int index = 0;
 
+    void *ptr = NULL;
+    void *ptrToPtr = &ptr;
+
     for (i = 0; i < nrOfArgs; i += 1) {
         dyn_type *argType = dynFunction_argumentTypeForIndex(func, i);
         enum dyn_function_argument_meta  meta = 
dynFunction_argumentMetaForIndex(func, i);
@@ -94,8 +97,7 @@ int jsonRpc_call(dyn_interface_type *intf, void *service, 
const char *request, c
         } else if (meta == DYN_FUNCTION_ARGUMENT_META__PRE_ALLOCATED_OUTPUT) {
             dynType_alloc(argType, &args[i]);
         } else if (meta == DYN_FUNCTION_ARGUMENT_META__OUTPUT) {
-            void *inMemPtr = calloc(1, sizeof(void *));
-            args[i] = &inMemPtr;
+            args[i] = &ptrToPtr;
         } else if (meta == DYN_FUNCTION_ARGUMENT_META__HANDLE) {
             args[i] = &handle;
         }
@@ -142,15 +144,22 @@ int jsonRpc_call(dyn_interface_type *intf, void *service, 
const char *request, c
                 }
                 dynType_free(argType, args[i]);
             } else if (meta == DYN_FUNCTION_ARGUMENT_META__OUTPUT) {
-                void ***out = args[i];
-                if (out != NULL && *out != NULL && **out != NULL) {
-                    status = jsonSerializer_serializeJson(argType, out, 
&jsonResult);
+                if (ptr != NULL) {
+
                     dyn_type *typedType = NULL;
                     if (status == OK) {
                         status = dynType_typedPointer_getTypedType(argType, 
&typedType);
                     }
+
+                    dyn_type *typedTypedType = NULL;
+                    if (status == OK) {
+                        status = dynType_typedPointer_getTypedType(typedType, 
&typedTypedType);
+                    }
+
+                    status = jsonSerializer_serializeJson(typedTypedType, ptr, 
&jsonResult);
+
                     if (status == OK) {
-                        dynType_free(typedType, *out);
+                        dynType_free(typedTypedType, ptr);
                     }
                 } else {
                     LOG_DEBUG("Output ptr is null");

http://git-wip-us.apache.org/repos/asf/celix/blob/746b30e8/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 50b50f5..8616f0c 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
@@ -289,6 +289,10 @@ static void importRegistration_proxyFunc(void *userData, 
void *args[], void *ret
 celix_status_t importRegistration_ungetService(import_registration_pt import, 
bundle_pt bundle, service_registration_pt registration, void **out) {
     celix_status_t  status = CELIX_SUCCESS;
 
+    return status;
+
+    /* TODO, FIXME ungetService can happen after importRegistration destroy 
leading to segfaults
+
     assert(import != NULL);
     assert(import->proxies != NULL);
 
@@ -310,6 +314,7 @@ celix_status_t 
importRegistration_ungetService(import_registration_pt import, bu
     pthread_mutex_lock(&import->proxiesMutex);
 
     return status;
+     */
 }
 
 static void importRegistration_destroyProxy(struct service_proxy *proxy) {

http://git-wip-us.apache.org/repos/asf/celix/blob/746b30e8/remote_services/remote_service_admin_dfi/rsa_tst/rsa_client_server_tests.cpp
----------------------------------------------------------------------
diff --git 
a/remote_services/remote_service_admin_dfi/rsa_tst/rsa_client_server_tests.cpp 
b/remote_services/remote_service_admin_dfi/rsa_tst/rsa_client_server_tests.cpp
index 836e4ed..86b4f89 100644
--- 
a/remote_services/remote_service_admin_dfi/rsa_tst/rsa_client_server_tests.cpp
+++ 
b/remote_services/remote_service_admin_dfi/rsa_tst/rsa_client_server_tests.cpp
@@ -64,9 +64,8 @@ extern "C" {
         celixLauncher_destroy(serverFramework);
 
         celixLauncher_stop(clientFramework);
-        //TODO, FIXME, hangs on second wait for shutdown.. investigate
-        // celixLauncher_waitForShutdown(clientFramework);
-        //celixLauncher_destroy(clientFramework);
+        celixLauncher_waitForShutdown(clientFramework);
+        celixLauncher_destroy(clientFramework);
 
         serverContext = NULL;
         serverFramework = NULL;

Reply via email to