celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bpe...@apache.org
Subject svn commit: r1640921 - in /celix/trunk/remote_services/discovery_etcd/private/src: etcd.c etcd_watcher.c
Date Fri, 21 Nov 2014 14:34:32 GMT
Author: bpetri
Date: Fri Nov 21 14:34:31 2014
New Revision: 1640921

URL: http://svn.apache.org/r1640921
Log:
CELIX-187: added expire-handling, index for watch

Modified:
    celix/trunk/remote_services/discovery_etcd/private/src/etcd.c
    celix/trunk/remote_services/discovery_etcd/private/src/etcd_watcher.c

Modified: celix/trunk/remote_services/discovery_etcd/private/src/etcd.c
URL: http://svn.apache.org/viewvc/celix/trunk/remote_services/discovery_etcd/private/src/etcd.c?rev=1640921&r1=1640920&r2=1640921&view=diff
==============================================================================
--- celix/trunk/remote_services/discovery_etcd/private/src/etcd.c (original)
+++ celix/trunk/remote_services/discovery_etcd/private/src/etcd.c Fri Nov 21 14:34:31 2014
@@ -318,8 +318,10 @@ bool etcd_watch(char* key, int index, ch
 		if ((js_prevValue != NULL) && (json_is_string(js_prevValue))) {
 			strncpy(prevValue, json_string_value(js_prevValue), MAX_VALUE_LENGTH);
 		}
-		if ((js_value != NULL) && (js_action != NULL) && (json_is_string(js_value))
&& (json_is_string(js_action))) {
+		if ((js_value != NULL) && (json_is_string(js_value))) {
 			strncpy(value, json_string_value(js_value), MAX_VALUE_LENGTH);
+		}
+		if ((js_action != NULL) && (json_is_string(js_action))) {
 			strncpy(action, json_string_value(js_action), MAX_ACTION_LENGTH);
 
 			retVal = true;

Modified: celix/trunk/remote_services/discovery_etcd/private/src/etcd_watcher.c
URL: http://svn.apache.org/viewvc/celix/trunk/remote_services/discovery_etcd/private/src/etcd_watcher.c?rev=1640921&r1=1640920&r2=1640921&view=diff
==============================================================================
--- celix/trunk/remote_services/discovery_etcd/private/src/etcd_watcher.c (original)
+++ celix/trunk/remote_services/discovery_etcd/private/src/etcd_watcher.c Fri Nov 21 14:34:31
2014
@@ -218,18 +218,19 @@ static void* etcdWatcher_run(void* data)
 		char preValue[MAX_VALUE_LENGTH];
 		char action[MAX_ACTION_LENGTH];
 
-
-		if (etcd_watch(rootPath, 0, &action[0], &preValue[0], &value[0]) == true) {
-
+		if (etcd_watch(rootPath, highestModified+1, &action[0], &preValue[0], &value[0])
== true) {
 			if (strcmp(action, "set") == 0) {
 				endpointDiscoveryPoller_addDiscoveryEndpoint(poller, strdup(&value[0]));
 			} else if (strcmp(action, "delete") == 0) {
 				endpointDiscoveryPoller_removeDiscoveryEndpoint(poller, &preValue[0]);
+			} else if (strcmp(action, "expire") == 0) {
+				endpointDiscoveryPoller_removeDiscoveryEndpoint(poller, &preValue[0]);
 			} else if (strcmp(action, "update") == 0) {
 				// TODO
 			} else {
 				fw_log(logger, OSGI_FRAMEWORK_LOG_INFO, "Unexpected action: %s", action);
 			}
+			highestModified++;
 		}
 
 		// update own framework uuid
@@ -290,7 +291,7 @@ celix_status_t etcdWatcher_create(discov
 		return CELIX_BUNDLE_EXCEPTION;
 	}
 
-	etcdWatcher_addOwnFramework((*watcher));
+	etcdWatcher_addOwnFramework(*watcher);
 
 	if ((status = celixThreadMutex_create(&(*watcher)->watcherLock, NULL)) != CELIX_SUCCESS)
{
 		return status;
@@ -322,12 +323,9 @@ celix_status_t etcdWatcher_destroy(etcd_
 	celixThread_join(watcher->watcherThread, NULL);
 
 	// register own framework
-	if ((status = etcdWatcher_getLocalNodePath(
-			watcher->discovery->context, &localNodePath[0])) != CELIX_SUCCESS) {
-		return status;
-	}
+	status = etcdWatcher_getLocalNodePath(watcher->discovery->context, &localNodePath[0]);
 
-	if (etcd_del(localNodePath) == false)
+	if (status != CELIX_SUCCESS || etcd_del(localNodePath) == false)
 	{
 		fw_log(logger, OSGI_FRAMEWORK_LOG_WARNING, "Cannot remove local discovery registration.");
 	}



Mime
View raw message