celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From griccia...@apache.org
Subject celix git commit: CELIX-373: made endpoint_server number configurable. Default value raised to 15
Date Fri, 26 Aug 2016 15:44:52 GMT
Repository: celix
Updated Branches:
  refs/heads/develop 216032cae -> 2bc39ca92


CELIX-373: made endpoint_server number configurable. Default value raised to 15


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

Branch: refs/heads/develop
Commit: 2bc39ca9246abb8139b400715704723e9e9f4391
Parents: 216032c
Author: gricciardi <gricciardi@apache.org>
Authored: Fri Aug 26 17:44:07 2016 +0200
Committer: gricciardi <gricciardi@apache.org>
Committed: Fri Aug 26 17:44:07 2016 +0200

----------------------------------------------------------------------
 .../discovery/private/include/discovery.h           |  1 +
 .../private/src/endpoint_discovery_server.c         | 16 ++++++++++++++--
 2 files changed, 15 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/2bc39ca9/remote_services/discovery/private/include/discovery.h
----------------------------------------------------------------------
diff --git a/remote_services/discovery/private/include/discovery.h b/remote_services/discovery/private/include/discovery.h
index 9695a3c..ee79caf 100644
--- a/remote_services/discovery/private/include/discovery.h
+++ b/remote_services/discovery/private/include/discovery.h
@@ -38,6 +38,7 @@
 #define DISCOVERY_SERVER_PORT 		"DISCOVERY_CFG_SERVER_PORT"
 #define DISCOVERY_SERVER_PATH 		"DISCOVERY_CFG_SERVER_PATH"
 #define DISCOVERY_POLL_ENDPOINTS 	"DISCOVERY_CFG_POLL_ENDPOINTS"
+#define DISCOVERY_SERVER_MAX_EP	"DISCOVERY_CFG_SERVER_MAX_EP"
 
 typedef struct discovery *discovery_pt;
 

http://git-wip-us.apache.org/repos/asf/celix/blob/2bc39ca9/remote_services/discovery/private/src/endpoint_discovery_server.c
----------------------------------------------------------------------
diff --git a/remote_services/discovery/private/src/endpoint_discovery_server.c b/remote_services/discovery/private/src/endpoint_discovery_server.c
index 6273e6f..f5f82af 100644
--- a/remote_services/discovery/private/src/endpoint_discovery_server.c
+++ b/remote_services/discovery/private/src/endpoint_discovery_server.c
@@ -40,7 +40,7 @@
 #include "endpoint_descriptor_writer.h"
 
 // defines how often the webserver is restarted (with an increased port number)
-#define MAX_NUMBER_OF_RESTARTS 	5
+#define MAX_NUMBER_OF_RESTARTS 	15
 #define DEFAULT_SERVER_THREADS "1"
 
 #define CIVETWEB_REQUEST_NOT_HANDLED 0
@@ -79,6 +79,9 @@ celix_status_t endpointDiscoveryServer_create(discovery_pt discovery, bundle_con
 	const char *ip = NULL;
 	char *detectedIp = NULL;
 	const char *path = NULL;
+	const char *retries = NULL;
+
+	int max_ep_num = MAX_NUMBER_OF_RESTARTS;
 
 	*server = malloc(sizeof(struct endpoint_discovery_server));
 	if (!*server) {
@@ -137,6 +140,15 @@ celix_status_t endpointDiscoveryServer_create(discovery_pt discovery,
bundle_con
 		path = DEFAULT_SERVER_PATH;
 	}
 
+	bundleContext_getProperty(context, DISCOVERY_SERVER_MAX_EP, &retries);
+	if (retries != NULL) {
+		errno=0;
+		max_ep_num = strtol(retries,NULL,10);
+		if(errno!=0 || max_ep_num<=0){
+			max_ep_num=MAX_NUMBER_OF_RESTARTS;
+		}
+	}
+
 	(*server)->path = format_path(path);
 
 	const struct mg_callbacks callbacks = {
@@ -176,7 +188,7 @@ celix_status_t endpointDiscoveryServer_create(discovery_pt discovery,
bundle_con
 
 		}
 
-	} while(((*server)->ctx == NULL) && (port_counter < MAX_NUMBER_OF_RESTARTS));
+	} while(((*server)->ctx == NULL) && (port_counter < max_ep_num));
 
 	(*server)->port = strdup(port);
 


Mime
View raw message