Repository: celix
Updated Branches:
  refs/heads/develop acbfe389b -> 3605d26ac


CELIX-340: fix locking


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

Branch: refs/heads/develop
Commit: 3605d26ac1bb6da2ed467329a3ad01c60cd1cfd5
Parents: acbfe38
Author: Bjoern Petri <[email protected]>
Authored: Wed Jan 13 10:09:28 2016 +0100
Committer: Bjoern Petri <[email protected]>
Committed: Wed Jan 13 10:09:28 2016 +0100

----------------------------------------------------------------------
 .../discovery_etcd/private/src/etcd.c           |  3 +-
 .../discovery_etcd/private/src/etcd_watcher.c   | 43 +++++++++-----------
 2 files changed, 21 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/3605d26a/remote_services/discovery_etcd/private/src/etcd.c
----------------------------------------------------------------------
diff --git a/remote_services/discovery_etcd/private/src/etcd.c 
b/remote_services/discovery_etcd/private/src/etcd.c
index a68dc77..ed06fb7 100644
--- a/remote_services/discovery_etcd/private/src/etcd.c
+++ b/remote_services/discovery_etcd/private/src/etcd.c
@@ -183,11 +183,10 @@ bool etcd_getNodes(char* directory, char** nodeNames, 
int* size) {
                if (js_root != NULL) {
                        js_node = json_object_get(js_root, ETCD_JSON_NODE);
                }
-               if (js_root != NULL) {
+               if (js_node != NULL) {
                        js_nodes = json_object_get(js_node, ETCD_JSON_NODES);
                }
 
-
                if (js_nodes != NULL && json_is_array(js_nodes)) {
                        int i = 0;
                        retVal = true;

http://git-wip-us.apache.org/repos/asf/celix/blob/3605d26a/remote_services/discovery_etcd/private/src/etcd_watcher.c
----------------------------------------------------------------------
diff --git a/remote_services/discovery_etcd/private/src/etcd_watcher.c 
b/remote_services/discovery_etcd/private/src/etcd_watcher.c
index 919aefd..915f420 100644
--- a/remote_services/discovery_etcd/private/src/etcd_watcher.c
+++ b/remote_services/discovery_etcd/private/src/etcd_watcher.c
@@ -349,35 +349,32 @@ celix_status_t etcdWatcher_create(discovery_pt discovery, 
bundle_context_pt cont
                }
        }
 
-       status = etcd_init(etcd_server, etcd_port);
-       if (status != CELIX_SUCCESS)
-       {
-               return status;
-       }
-
-       etcdWatcher_addOwnFramework(*watcher);
-
-       if ((status = celixThreadMutex_create(&(*watcher)->watcherLock, NULL)) 
!= CELIX_SUCCESS) {
-               return status;
-       }
-
-       if ((status = celixThreadMutex_lock(&(*watcher)->watcherLock)) != 
CELIX_SUCCESS) {
-               return status;
-       }
+    status = etcd_init(etcd_server, etcd_port);
 
-       if ((status = celixThread_create(&(*watcher)->watcherThread, NULL, 
etcdWatcher_run, *watcher)) != CELIX_SUCCESS) {
-               return status;
-       }
+    printf(" ININT\n");
+    if (status == CELIX_SUCCESS) {
+        etcdWatcher_addOwnFramework(*watcher);
+        status = celixThreadMutex_create(&(*watcher)->watcherLock, NULL);
+        printf(" 111\n");
+    }
 
-       (*watcher)->running = true;
+    if (status == CELIX_SUCCESS) {
+        if (celixThreadMutex_lock(&(*watcher)->watcherLock) == CELIX_SUCCESS) {
+            status = celixThread_create(&(*watcher)->watcherThread, NULL, 
etcdWatcher_run, *watcher);
+            if (status == CELIX_SUCCESS) {
+                printf(" STARTEDTSTARTED\n");
+                (*watcher)->running = true;
+            }
+            celixThreadMutex_unlock(&(*watcher)->watcherLock);
+        }
+    }
 
-       if ((status = celixThreadMutex_unlock(&(*watcher)->watcherLock)) != 
CELIX_SUCCESS) {
-               return status;
-       }
 
-       return status;
+    printf(" DONEDONE\n");
+    return status;
 }
 
+
 celix_status_t etcdWatcher_destroy(etcd_watcher_pt watcher) {
        celix_status_t status = CELIX_SUCCESS;
        char localNodePath[MAX_LOCALNODE_LENGTH];

Reply via email to