qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acon...@apache.org
Subject [3/4] qpid-dispatch git commit: DISPATCH-390: Move declarations from server_private.h to server.c
Date Thu, 19 Jan 2017 21:17:45 GMT
DISPATCH-390: Move declarations from server_private.h to server.c

Move unnecessarily public declarations from server_private.h to server.c


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

Branch: refs/heads/master
Commit: f82944b3019685d283b785bc9df78308fa3bdc8b
Parents: 1ea0219
Author: Alan Conway <aconway@redhat.com>
Authored: Thu Jan 19 13:51:43 2017 -0500
Committer: Alan Conway <aconway@redhat.com>
Committed: Thu Jan 19 15:33:02 2017 -0500

----------------------------------------------------------------------
 src/policy.c         | 18 ++++++-------
 src/server.c         | 64 +++++++++++++++++++++++++++++++++++++++++++++
 src/server_private.h | 66 +++--------------------------------------------
 3 files changed, 76 insertions(+), 72 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/f82944b3/src/policy.c
----------------------------------------------------------------------
diff --git a/src/policy.c b/src/policy.c
index cea0216..182fc61 100644
--- a/src/policy.c
+++ b/src/policy.c
@@ -400,7 +400,7 @@ bool qd_policy_approve_amqp_session(pn_session_t *ssn, qd_connection_t
*qd_conn)
         }
     }
     pn_connection_t *conn = qd_connection_pn(qd_conn);
-    qd_dispatch_t *qd = qd_conn->server->qd;
+    qd_dispatch_t *qd = qd_server_dispatch(qd_conn->server);
     qd_policy_t *policy = qd->policy;
     const char *hostip = qd_connection_hostip(qd_conn);
     const char *vhost = pn_connection_remote_hostname(conn);
@@ -580,7 +580,7 @@ bool qd_policy_approve_amqp_sender_link(pn_link_t *pn_link, qd_connection_t
*qd_
     if (qd_conn->policy_settings->maxSenders) {
         if (qd_conn->n_senders == qd_conn->policy_settings->maxSenders) {
             // Max sender limit specified and violated.
-            qd_log(qd_conn->server->qd->policy->log_source, QD_LOG_INFO,
+            qd_log(qd_server_dispatch(qd_conn->server)->policy->log_source, QD_LOG_INFO,
                 "DENY AMQP Attach sender for user '%s', rhost '%s', vhost '%s' based on maxSenders
limit",
                 qd_conn->user_id, hostip, vhost);
             _qd_policy_deny_amqp_sender_link(pn_link, qd_conn);
@@ -598,7 +598,7 @@ bool qd_policy_approve_amqp_sender_link(pn_link_t *pn_link, qd_connection_t
*qd_
         // a target is specified
         lookup = _qd_policy_approve_link_name(qd_conn->user_id, qd_conn->policy_settings->targets,
target);
 
-        qd_log(qd_conn->server->qd->policy->log_source, (lookup ? QD_LOG_TRACE
: QD_LOG_INFO),
+        qd_log(qd_server_dispatch(qd_conn->server)->policy->log_source, (lookup
? QD_LOG_TRACE : QD_LOG_INFO),
             "%s AMQP Attach sender link '%s' for user '%s', rhost '%s', vhost '%s' based
on link target name",
             (lookup ? "ALLOW" : "DENY"), target, qd_conn->user_id, hostip, vhost);
 
@@ -610,7 +610,7 @@ bool qd_policy_approve_amqp_sender_link(pn_link_t *pn_link, qd_connection_t
*qd_
         // A sender with no remote target.
         // This happens all the time with anonymous relay
         lookup = qd_conn->policy_settings->allowAnonymousSender;
-        qd_log(qd_conn->server->qd->policy->log_source, (lookup ? QD_LOG_TRACE
: QD_LOG_INFO),
+        qd_log(qd_server_dispatch(qd_conn->server)->policy->log_source, (lookup
? QD_LOG_TRACE : QD_LOG_INFO),
             "%s AMQP Attach anonymous sender for user '%s', rhost '%s', vhost '%s'",
             (lookup ? "ALLOW" : "DENY"), qd_conn->user_id, hostip, vhost);
         if (!lookup) {
@@ -631,7 +631,7 @@ bool qd_policy_approve_amqp_receiver_link(pn_link_t *pn_link, qd_connection_t
*q
     if (qd_conn->policy_settings->maxReceivers) {
         if (qd_conn->n_receivers == qd_conn->policy_settings->maxReceivers) {
             // Max sender limit specified and violated.
-            qd_log(qd_conn->server->qd->policy->log_source, QD_LOG_INFO,
+            qd_log(qd_server_dispatch(qd_conn->server)->policy->log_source, QD_LOG_INFO,
                 "DENY AMQP Attach receiver for user '%s', rhost '%s', vhost '%s' based on
maxReceivers limit",
                 qd_conn->user_id, hostip, vhost);
             _qd_policy_deny_amqp_receiver_link(pn_link, qd_conn);
@@ -646,7 +646,7 @@ bool qd_policy_approve_amqp_receiver_link(pn_link_t *pn_link, qd_connection_t
*q
     bool dynamic_src = pn_terminus_is_dynamic(pn_link_remote_source(pn_link));
     if (dynamic_src) {
         bool lookup = qd_conn->policy_settings->allowDynamicSource;
-        qd_log(qd_conn->server->qd->policy->log_source, (lookup ? QD_LOG_TRACE
: QD_LOG_INFO),
+        qd_log(qd_server_dispatch(qd_conn->server)->policy->log_source, (lookup
? QD_LOG_TRACE : QD_LOG_INFO),
             "%s AMQP Attach receiver dynamic source for user '%s', rhost '%s', vhost '%s',",
             (lookup ? "ALLOW" : "DENY"), qd_conn->user_id, hostip, vhost);
         // Dynamic source policy rendered the decision
@@ -660,7 +660,7 @@ bool qd_policy_approve_amqp_receiver_link(pn_link_t *pn_link, qd_connection_t
*q
         // a source is specified
         bool lookup = _qd_policy_approve_link_name(qd_conn->user_id, qd_conn->policy_settings->sources,
source);
 
-        qd_log(qd_conn->server->qd->policy->log_source, (lookup ? QD_LOG_TRACE
: QD_LOG_INFO),
+        qd_log(qd_server_dispatch(qd_conn->server)->policy->log_source, (lookup
? QD_LOG_TRACE : QD_LOG_INFO),
             "%s AMQP Attach receiver link '%s' for user '%s', rhost '%s', vhost '%s' based
on link source name",
             (lookup ? "ALLOW" : "DENY"), source, qd_conn->user_id, hostip, vhost);
 
@@ -670,7 +670,7 @@ bool qd_policy_approve_amqp_receiver_link(pn_link_t *pn_link, qd_connection_t
*q
         }
     } else {
         // A receiver with no remote source.
-        qd_log(qd_conn->server->qd->policy->log_source, QD_LOG_TRACE,
+        qd_log(qd_server_dispatch(qd_conn->server)->policy->log_source, QD_LOG_TRACE,
                "DENY AMQP Attach receiver link '' for user '%s', rhost '%s', vhost '%s'",
                qd_conn->user_id, hostip, vhost);
         _qd_policy_deny_amqp_receiver_link(pn_link, qd_conn);
@@ -688,7 +688,7 @@ void qd_policy_amqp_open(void *context, bool discard)
     qd_connection_t *qd_conn = (qd_connection_t *)context;
     if (!discard) {
         pn_connection_t *conn = qd_connection_pn(qd_conn);
-        qd_dispatch_t *qd = qd_conn->server->qd;
+        qd_dispatch_t *qd = qd_server_dispatch(qd_conn->server);
         qd_policy_t *policy = qd->policy;
         bool connection_allowed = true;
 

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/f82944b3/src/server.c
----------------------------------------------------------------------
diff --git a/src/server.c b/src/server.c
index a86500a..7da9f23 100644
--- a/src/server.c
+++ b/src/server.c
@@ -38,6 +38,60 @@
 #include <errno.h>
 #include <inttypes.h>
 
+typedef struct qd_thread_t {
+    qd_server_t  *qd_server;
+    int           thread_id;
+    volatile int  running;
+    volatile int  canceled;
+    int           using_thread;
+    sys_thread_t *thread;
+} qd_thread_t;
+
+
+typedef struct qd_work_item_t {
+    DEQ_LINKS(struct qd_work_item_t);
+    qdpn_connector_t *cxtr;
+} qd_work_item_t;
+
+DEQ_DECLARE(qd_work_item_t, qd_work_list_t);
+
+
+struct qd_server_t {
+    qd_dispatch_t            *qd;
+    int                       thread_count;
+    const char               *container_name;
+    const char               *sasl_config_path;
+    const char               *sasl_config_name;
+    qdpn_driver_t            *driver;
+    qd_log_source_t          *log_source;
+    qd_thread_start_cb_t      start_handler;
+    qd_conn_handler_cb_t      conn_handler;
+    qd_pn_event_handler_cb_t  pn_event_handler;
+    qd_pn_event_complete_cb_t pn_event_complete_handler;
+    void                     *start_context;
+    void                     *conn_handler_context;
+    sys_cond_t               *cond;
+    sys_mutex_t              *lock;
+    qd_thread_t             **threads;
+    qd_work_list_t            work_queue;
+    qd_timer_list_t           pending_timers;
+    bool                      a_thread_is_waiting;
+    int                       threads_active;
+    int                       pause_requests;
+    int                       threads_paused;
+    int                       pause_next_sequence;
+    int                       pause_now_serving;
+    qd_signal_handler_cb_t    signal_handler;
+    bool                      signal_handler_running;
+    void                     *signal_context;
+    int                       pending_signal;
+    qd_connection_list_t      connections;
+    qd_timer_t               *heartbeat_timer;
+    uint64_t                 next_connection_id;
+    void                     *py_displayname_obj;
+    qd_http_server_t         *http;
+};
+
 static __thread qd_server_t *thread_server = 0;
 
 #define HEARTBEAT_INTERVAL 1000
@@ -1645,3 +1699,13 @@ void qd_server_timer_cancel_LH(qd_timer_t *timer)
 {
     DEQ_REMOVE(timer->server->pending_timers, timer);
 }
+
+qd_dispatch_t* qd_server_dispatch(qd_server_t *server) { return server->qd; }
+
+const char* qd_connection_name(const qd_connection_t *c) {
+    return qdpn_connector_name(c->pn_cxtr);
+}
+
+const char* qd_connection_hostip(const qd_connection_t *c) {
+    return qdpn_connector_hostip(c->pn_cxtr);
+}

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/f82944b3/src/server_private.h
----------------------------------------------------------------------
diff --git a/src/server_private.h b/src/server_private.h
index 3bec063..896128d 100644
--- a/src/server_private.h
+++ b/src/server_private.h
@@ -34,6 +34,9 @@
 
 void qd_server_timer_pending_LH(qd_timer_t *timer);
 void qd_server_timer_cancel_LH(qd_timer_t *timer);
+struct qd_dispatch_t* qd_server_dispatch(qd_server_t *server);
+const char* qd_connection_name(const qd_connection_t *c);
+const char* qd_connection_hostip(const qd_connection_t *c);
 
 #define CONTEXT_NO_OWNER -1
 #define CONTEXT_UNSPECIFIED_OWNER -2
@@ -128,71 +131,8 @@ struct qd_connection_t {
     qd_pn_free_link_session_list_t  free_link_session_list;
 };
 
-static inline const char* qd_connection_name(const qd_connection_t *c) {
-    return qdpn_connector_name(c->pn_cxtr);
-}
-
-static inline const char* qd_connection_hostip(const qd_connection_t *c) {
-    return qdpn_connector_hostip(c->pn_cxtr);
-}
-
 DEQ_DECLARE(qd_connection_t, qd_connection_list_t);
 
-typedef struct qd_thread_t {
-    qd_server_t  *qd_server;
-    int           thread_id;
-    volatile int  running;
-    volatile int  canceled;
-    int           using_thread;
-    sys_thread_t *thread;
-} qd_thread_t;
-
-
-typedef struct qd_work_item_t {
-    DEQ_LINKS(struct qd_work_item_t);
-    qdpn_connector_t *cxtr;
-} qd_work_item_t;
-
-DEQ_DECLARE(qd_work_item_t, qd_work_list_t);
-
-
-struct qd_server_t {
-    qd_dispatch_t            *qd;
-    int                       thread_count;
-    const char               *container_name;
-    const char               *sasl_config_path;
-    const char               *sasl_config_name;
-    qdpn_driver_t            *driver;
-    qd_log_source_t          *log_source;
-    qd_thread_start_cb_t      start_handler;
-    qd_conn_handler_cb_t      conn_handler;
-    qd_pn_event_handler_cb_t  pn_event_handler;
-    qd_pn_event_complete_cb_t pn_event_complete_handler;
-    void                     *start_context;
-    void                     *conn_handler_context;
-    sys_cond_t               *cond;
-    sys_mutex_t              *lock;
-    qd_thread_t             **threads;
-    qd_work_list_t            work_queue;
-    qd_timer_list_t           pending_timers;
-    bool                      a_thread_is_waiting;
-    int                       threads_active;
-    int                       pause_requests;
-    int                       threads_paused;
-    int                       pause_next_sequence;
-    int                       pause_now_serving;
-    qd_signal_handler_cb_t    signal_handler;
-    bool                      signal_handler_running;
-    void                     *signal_context;
-    int                       pending_signal;
-    qd_connection_list_t      connections;
-    qd_timer_t               *heartbeat_timer;
-    uint64_t                 next_connection_id;
-    void                     *py_displayname_obj;
-    qd_http_server_t         *http;
-};
-
-ALLOC_DECLARE(qd_work_item_t);
 ALLOC_DECLARE(qd_listener_t);
 ALLOC_DECLARE(qd_deferred_call_t);
 ALLOC_DECLARE(qd_connector_t);


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


Mime
View raw message