celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pnol...@apache.org
Subject [celix] branch develop updated: Feature/pubsub tcp admin fix (#48)
Date Tue, 10 Sep 2019 19:15:03 GMT
This is an automated email from the ASF dual-hosted git repository.

pnoltes pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/celix.git


The following commit(s) were added to refs/heads/develop by this push:
     new 01956a3  Feature/pubsub tcp admin fix (#48)
01956a3 is described below

commit 01956a3b4fab81e322598a02e194770f52d0dea8
Author: dhbfischer <52166446+dhbfischer@users.noreply.github.com>
AuthorDate: Tue Sep 10 21:14:59 2019 +0200

    Feature/pubsub tcp admin fix (#48)
    
    * Fixed tcp admin port extraction from string
    
    * Added feature to set bind ip address
---
 bundles/pubsub/pubsub_admin_tcp/src/pubsub_tcp_handler.c      | 3 ++-
 bundles/pubsub/pubsub_admin_tcp/src/pubsub_tcp_topic_sender.c | 9 +++++++--
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/bundles/pubsub/pubsub_admin_tcp/src/pubsub_tcp_handler.c b/bundles/pubsub/pubsub_admin_tcp/src/pubsub_tcp_handler.c
index 4316dcd..9457163 100644
--- a/bundles/pubsub/pubsub_admin_tcp/src/pubsub_tcp_handler.c
+++ b/bundles/pubsub/pubsub_admin_tcp/src/pubsub_tcp_handler.c
@@ -451,7 +451,8 @@ void pubsub_tcpHandler_setUrlInfo(char *url, pubsub_tcpHandler_url_t *url_info)
             url_info->hostname = strtok(strdup(hostname), ":");
             if (port) {
                 port += 1;
-                if (isdigit(atoi(port)) == 0) url_info->portnr = atoi(port);
+                unsigned int portDigits = (unsigned) atoi(port);
+                if (portDigits != 0) url_info->portnr = portDigits;
             }
             free(hostname);
         }
diff --git a/bundles/pubsub/pubsub_admin_tcp/src/pubsub_tcp_topic_sender.c b/bundles/pubsub/pubsub_admin_tcp/src/pubsub_tcp_topic_sender.c
index 275fdb6..1f4b5d1 100644
--- a/bundles/pubsub/pubsub_admin_tcp/src/pubsub_tcp_topic_sender.c
+++ b/bundles/pubsub/pubsub_admin_tcp/src/pubsub_tcp_topic_sender.c
@@ -188,9 +188,14 @@ pubsub_tcp_topic_sender_t *pubsub_tcpTopicSender_create(
                 /* Randomized part due to same bundle publishing on different topics */
                 unsigned int port = rand_range(basePort, maxPort);
                 char *url = NULL;
-                asprintf(&url, "tcp://%s:%u", bindIP, port);
                 char *bindUrl = NULL;
-                asprintf(&bindUrl, "tcp://0.0.0.0:%u", port);
+                if(bindIP == NULL) {
+                    asprintf(&bindUrl, "tcp://0.0.0.0:%u", port);
+                } else {
+                    asprintf(&bindUrl, "tcp://%s:%u", bindIP, port);
+                }
+
+                asprintf(&url, "tcp://%s:%u", bindIP, port);
                 int rv = pubsub_tcpHandler_listen(sender->socketHandler, bindUrl);
                 if (rv == -1) {
                     L_WARN("Error for tcp_bind using dynamic bind url '%s'. %s", bindUrl,
strerror(errno));


Mime
View raw message