You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by gm...@apache.org on 2016/04/19 20:16:32 UTC

qpid-dispatch git commit: DISPATCH-261 - Added a new field called state to qd_config_listener_t so it can be checked before activating listeners

Repository: qpid-dispatch
Updated Branches:
  refs/heads/master b70f22600 -> 94e3c10a7


DISPATCH-261 - Added a new field called state to qd_config_listener_t so it can be checked before activating listeners


Project: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/commit/94e3c10a
Tree: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/tree/94e3c10a
Diff: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/diff/94e3c10a

Branch: refs/heads/master
Commit: 94e3c10a735515e564dfabd1ef1be0653af0e849
Parents: b70f226
Author: Ganesh Murthy <gm...@redhat.com>
Authored: Mon Apr 18 16:10:28 2016 -0400
Committer: Ganesh Murthy <gm...@redhat.com>
Committed: Tue Apr 19 14:15:24 2016 -0400

----------------------------------------------------------------------
 src/connection_manager.c | 16 ++++++++++++----
 src/server_private.h     |  6 ++++++
 2 files changed, 18 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/94e3c10a/src/connection_manager.c
----------------------------------------------------------------------
diff --git a/src/connection_manager.c b/src/connection_manager.c
index 5c338b9..44a22a9 100644
--- a/src/connection_manager.c
+++ b/src/connection_manager.c
@@ -30,10 +30,11 @@
 #include <stdio.h>
 
 struct qd_config_listener_t {
-    bool is_connector;
-    DEQ_LINKS(qd_config_listener_t);
+    bool                is_connector;
+    qd_bind_state_t     state;
     qd_listener_t      *listener;
     qd_server_config_t  configuration;
+    DEQ_LINKS(qd_config_listener_t);
 };
 
 DEQ_DECLARE(qd_config_listener_t, qd_config_listener_list_t);
@@ -202,6 +203,7 @@ qd_config_listener_t *qd_dispatch_configure_listener(qd_dispatch_t *qd, qd_entit
     qd_connection_manager_t *cm = qd->connection_manager;
     qd_config_listener_t *cl = NEW(qd_config_listener_t);
     cl->is_connector = false;
+    cl->state = QD_BIND_NONE;
     cl->listener = 0;
     if (load_server_config(qd, &cl->configuration, entity) != QD_ERROR_NONE) {
         qd_log(cm->log_source, QD_LOG_ERROR, "Unable to create config listener: %s", qd_error_message());
@@ -300,8 +302,14 @@ void qd_connection_manager_start(qd_dispatch_t *qd)
     qd_config_connector_t *cc = DEQ_HEAD(qd->connection_manager->config_connectors);
 
     while (cl) {
-        if (cl->listener == 0)
-            cl->listener = qd_server_listen(qd, &cl->configuration, cl);
+        if (cl->listener == 0 )
+            if (cl->state == QD_BIND_NONE) { //Try to start listening only if we have never tried to listen on that port before
+                cl->listener = qd_server_listen(qd, &cl->configuration, cl);
+                if (cl->listener && cl->listener->pn_listener)
+                    cl->state = QD_BIND_SUCCESSFUL;
+                else
+                    cl->state = QD_BIND_FAILED;
+            }
         cl = DEQ_NEXT(cl);
     }
 

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/94e3c10a/src/server_private.h
----------------------------------------------------------------------
diff --git a/src/server_private.h b/src/server_private.h
index 0a8d701..6a9bb76 100644
--- a/src/server_private.h
+++ b/src/server_private.h
@@ -39,6 +39,12 @@ void qd_server_timer_cancel_LH(qd_timer_t *timer);
 #define CONTEXT_UNSPECIFIED_OWNER -2
 
 typedef enum {
+    QD_BIND_SUCCESSFUL, // Bind to socket was attempted and the bind succeeded
+    QD_BIND_FAILED,     // Bind to socket was attempted and bind failed
+    QD_BIND_NONE,    // Bind to socket not attempted yet
+} qd_bind_state_t;
+
+typedef enum {
     CXTR_STATE_CONNECTING = 0,
     CXTR_STATE_OPEN,
     CXTR_STATE_FAILED


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org