You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by kg...@apache.org on 2018/12/05 21:03:00 UTC

qpid-dispatch git commit: DISPATCH-1194: use void* for callback handles

Repository: qpid-dispatch
Updated Branches:
  refs/heads/master a49750ee4 -> b501cbafa


DISPATCH-1194: use void* for callback handles


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

Branch: refs/heads/master
Commit: b501cbafa3696a0541fbebf32d6370d4041a53f0
Parents: a49750e
Author: Kenneth Giusti <kg...@apache.org>
Authored: Wed Dec 5 16:02:17 2018 -0500
Committer: Kenneth Giusti <kg...@apache.org>
Committed: Wed Dec 5 16:02:17 2018 -0500

----------------------------------------------------------------------
 src/router_core/core_client_api.c               | 20 +++---
 src/router_core/core_client_api.h               | 64 ++++++++++----------
 src/router_core/modules/edge_router/edge_mgmt.c | 42 ++++++-------
 .../modules/test_hooks/core_test_hooks.c        | 36 +++++------
 4 files changed, 81 insertions(+), 81 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/b501cbaf/src/router_core/core_client_api.c
----------------------------------------------------------------------
diff --git a/src/router_core/core_client_api.c b/src/router_core/core_client_api.c
index b5e8bbc..731cd77 100644
--- a/src/router_core/core_client_api.c
+++ b/src/router_core/core_client_api.c
@@ -35,7 +35,7 @@ struct qdrc_client_request_t {
     DEQ_LINKS_N(REPLY, qdrc_client_request_t);
 
     qdrc_client_t      *client;
-    uintptr_t           req_context;
+    void               *req_context;
 
     char                 correlation_id[CORRELATION_ID_LEN];
     qd_iterator_t       *correlation_key;
@@ -77,7 +77,7 @@ struct qdrc_client_t {
     int                         rx_credit;
     int                         tx_credit;
 
-    uintptr_t                   user_context;
+    void                       *user_context;
     qdrc_client_on_state_CT_t   on_state_cb;
     qdrc_client_on_flow_CT_t    on_flow_cb;
 
@@ -142,7 +142,7 @@ qdrc_client_t *qdrc_client_CT(qdr_core_t *core,
                               qdr_connection_t *conn,
                               qdr_terminus_t *target,
                               int credit_window,
-                              uintptr_t user_context,
+                              void *user_context,
                               qdrc_client_on_state_CT_t on_state_cb,
                               qdrc_client_on_flow_CT_t on_flow_cb)
 {
@@ -225,13 +225,13 @@ void qdrc_client_free_CT(qdrc_client_t *client)
 
 
 // send a message
-int qdrc_client_request_CT(qdrc_client_t *client,
-                           uintptr_t  request_context,
-                           qd_composed_field_t *app_properties,
-                           qd_composed_field_t *body,
-                           qdrc_client_on_reply_CT_t on_reply_cb,
-                           qdrc_client_on_ack_CT_t on_ack_cb,
-                           qdrc_client_request_done_CT_t done_cb)
+int qdrc_client_request_CT(qdrc_client_t                 *client,
+                           void                          *request_context,
+                           qd_composed_field_t           *app_properties,
+                           qd_composed_field_t           *body,
+                           qdrc_client_on_reply_CT_t      on_reply_cb,
+                           qdrc_client_on_ack_CT_t        on_ack_cb,
+                           qdrc_client_request_done_CT_t  done_cb)
 {
     qd_log(client->core->log, QD_LOG_TRACE,
            "New core client request created c=%p, rc=%"PRIuPTR")",

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/b501cbaf/src/router_core/core_client_api.h
----------------------------------------------------------------------
diff --git a/src/router_core/core_client_api.h b/src/router_core/core_client_api.h
index 1cf5b20..ff78e72 100644
--- a/src/router_core/core_client_api.h
+++ b/src/router_core/core_client_api.h
@@ -42,10 +42,10 @@ typedef struct qdrc_client_t qdrc_client_t;
  * @param user_context - as passed to qdrc_client_CT()
  * @param active - true if both links are opened, else false
  */
-typedef void (*qdrc_client_on_state_CT_t)(qdr_core_t *core,
+typedef void (*qdrc_client_on_state_CT_t)(qdr_core_t    *core,
                                           qdrc_client_t *client,
-                                          uintptr_t user_context,
-                                          bool active);
+                                          void          *user_context,
+                                          bool           active);
 
 
 /**
@@ -57,11 +57,11 @@ typedef void (*qdrc_client_on_state_CT_t)(qdr_core_t *core,
  * @param available_credit - current credit allocation
  * @param drain - if true client must consume all credit
  */
-typedef void (*qdrc_client_on_flow_CT_t)(qdr_core_t *core,
+typedef void (*qdrc_client_on_flow_CT_t)(qdr_core_t    *core,
                                          qdrc_client_t *client,
-                                         uintptr_t user_context,
-                                         int available_credit,
-                                         bool drain);
+                                         void          *user_context,
+                                         int            available_credit,
+                                         bool           drain);
 
 /**
  * Final disposition received for sent message
@@ -72,11 +72,11 @@ typedef void (*qdrc_client_on_flow_CT_t)(qdr_core_t *core,
  * @param request_context - as passed to qdrc_client_request_CT()
  * @param disposition - for the associated sent message
  */
-typedef void (*qdrc_client_on_ack_CT_t)(qdr_core_t *core,
+typedef void (*qdrc_client_on_ack_CT_t)(qdr_core_t    *core,
                                         qdrc_client_t *client,
-                                        uintptr_t user_context,
-                                        uintptr_t request_context,
-                                        uint64_t disposition);
+                                        void          *user_context,
+                                        void          *request_context,
+                                        uint64_t       disposition);
 
 /**
  * A reply message has arrived for a given request
@@ -91,19 +91,19 @@ typedef void (*qdrc_client_on_ack_CT_t)(qdr_core_t *core,
  *        - user must free the iterator when done.
  * @return final disposition for the received reply message
  */
-typedef uint64_t (*qdrc_client_on_reply_CT_t)(qdr_core_t *core,
+typedef uint64_t (*qdrc_client_on_reply_CT_t)(qdr_core_t    *core,
                                               qdrc_client_t *client,
-                                              uintptr_t user_context,
-                                              uintptr_t request_context,
+                                              void          *user_context,
+                                              void          *request_context,
                                               qd_iterator_t *app_properties,
                                               qd_iterator_t *body);
 
 
-typedef void (*qdrc_client_request_done_CT_t)(qdr_core_t *core,
+typedef void (*qdrc_client_request_done_CT_t)(qdr_core_t    *core,
                                               qdrc_client_t *client,
-                                              uintptr_t user_context,
-                                              uintptr_t request_context,
-                                              const char *error);
+                                              void          *user_context,
+                                              void          *request_context,
+                                              const char    *error);
 
 
 /**
@@ -118,13 +118,13 @@ typedef void (*qdrc_client_request_done_CT_t)(qdr_core_t *core,
  * @param on_flow_cb - callback when sender credit is updated.
  * @return a new core client
  */
-qdrc_client_t *qdrc_client_CT(qdr_core_t *core,
-                              qdr_connection_t *conn,
-                              qdr_terminus_t *target,
-                              int credit_window,
-                              uintptr_t user_context,
-                              qdrc_client_on_state_CT_t on_state_cb,
-                              qdrc_client_on_flow_CT_t  on_flow_cb);
+qdrc_client_t *qdrc_client_CT(qdr_core_t                *core,
+                              qdr_connection_t          *conn,
+                              qdr_terminus_t            *target,
+                              int                        credit_window,
+                              void                      *user_context,
+                              qdrc_client_on_state_CT_t  on_state_cb,
+                              qdrc_client_on_flow_CT_t   on_flow_cb);
 
 
 /**
@@ -154,12 +154,12 @@ void qdrc_client_free_CT(qdrc_client_t *client);
  * @param done_cb - (optional) called once request is done (for cleanup)
  * @return zero on success.
  */
-int qdrc_client_request_CT(qdrc_client_t *client,
-                           uintptr_t  request_context,
-                           qd_composed_field_t *app_properties,
-                           qd_composed_field_t *body,
-                           qdrc_client_on_reply_CT_t on_reply_cb,
-                           qdrc_client_on_ack_CT_t   on_ack_cb,
-                           qdrc_client_request_done_CT_t done_cb);
+int qdrc_client_request_CT(qdrc_client_t                 *client,
+                           void                          *request_context,
+                           qd_composed_field_t           *app_properties,
+                           qd_composed_field_t           *body,
+                           qdrc_client_on_reply_CT_t      on_reply_cb,
+                           qdrc_client_on_ack_CT_t        on_ack_cb,
+                           qdrc_client_request_done_CT_t  done_cb);
 
 #endif // #define qd_router_core_client_api_h 1

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/b501cbaf/src/router_core/modules/edge_router/edge_mgmt.c
----------------------------------------------------------------------
diff --git a/src/router_core/modules/edge_router/edge_mgmt.c b/src/router_core/modules/edge_router/edge_mgmt.c
index f9d713a..1322003 100644
--- a/src/router_core/modules/edge_router/edge_mgmt.c
+++ b/src/router_core/modules/edge_router/edge_mgmt.c
@@ -32,8 +32,8 @@ static qdrc_client_t *_client;              // req/resp client
 static qdrc_event_subscription_t *_event_handle;  // edge conn up/down
 
 
-static void _mgmt_on_state_cb_CT(qdr_core_t *, qdrc_client_t *, uintptr_t, bool);
-static void _mgmt_on_flow_cb_CT(qdr_core_t *, qdrc_client_t *, uintptr_t, int, bool);
+static void _mgmt_on_state_cb_CT(qdr_core_t *, qdrc_client_t *, void *, bool);
+static void _mgmt_on_flow_cb_CT(qdr_core_t *, qdrc_client_t *, void *, int, bool);
 
 
 //
@@ -129,10 +129,10 @@ exit:
 
 
 // mgmt client link state changed
-static void _mgmt_on_state_cb_CT(qdr_core_t *core,
+static void _mgmt_on_state_cb_CT(qdr_core_t    *core,
                                  qdrc_client_t *client,
-                                 uintptr_t user_context,
-                                 bool active)
+                                 void          *user_context,
+                                 bool           active)
 {
     qd_log(core->log, QD_LOG_TRACE,
            "edge mgmt client state change: uc=%"PRIuPTR" %s",
@@ -147,11 +147,11 @@ static void _mgmt_on_state_cb_CT(qdr_core_t *core,
 
 
 // mgmt client credit granted by interior router
-static void _mgmt_on_flow_cb_CT(qdr_core_t *core,
+static void _mgmt_on_flow_cb_CT(qdr_core_t    *core,
                                 qdrc_client_t *client,
-                                uintptr_t user_context,
-                                int available_credit,
-                                bool drain)
+                                void          *user_context,
+                                int            available_credit,
+                                bool           drain)
 {
     qd_log(core->log, QD_LOG_TRACE,
            "edge mgmt client flow: uc=%"PRIuPTR" c=%d d=%s",
@@ -165,11 +165,11 @@ static void _mgmt_on_flow_cb_CT(qdr_core_t *core,
 
 
 // terminal disposition set on sent request
-static void _mgmt_on_ack_cb_CT(qdr_core_t *core,
+static void _mgmt_on_ack_cb_CT(qdr_core_t    *core,
                                qdrc_client_t *client,
-                               uintptr_t user_context,
-                               uintptr_t request_context,
-                               uint64_t disposition)
+                               void          *user_context,
+                               void          *request_context,
+                               uint64_t       disposition)
 {
     qcm_edge_mgmt_request_t *req = (qcm_edge_mgmt_request_t *)request_context;
 
@@ -188,10 +188,10 @@ static void _mgmt_on_ack_cb_CT(qdr_core_t *core,
 
 
 // reply message received
-static uint64_t _mgmt_on_reply_cb_CT(qdr_core_t *core,
+static uint64_t _mgmt_on_reply_cb_CT(qdr_core_t    *core,
                                      qdrc_client_t *client,
-                                     uintptr_t user_context,
-                                     uintptr_t request_context,
+                                     void          *user_context,
+                                     void          *request_context,
                                      qd_iterator_t *app_properties,
                                      qd_iterator_t *body)
 {
@@ -225,11 +225,11 @@ static uint64_t _mgmt_on_reply_cb_CT(qdr_core_t *core,
 
 
 // request completed or aborted due to error
-static void _mgmt_on_done_cb_CT(qdr_core_t *core,
+static void _mgmt_on_done_cb_CT(qdr_core_t    *core,
                                 qdrc_client_t *client,
-                                uintptr_t user_context,
-                                uintptr_t request_context,
-                                const char *error)
+                                void          *user_context,
+                                void          *request_context,
+                                const char    *error)
 {
     qcm_edge_mgmt_request_t *req = (qcm_edge_mgmt_request_t *)request_context;
     qd_log(core->log, QD_LOG_TRACE,
@@ -288,7 +288,7 @@ int qcm_edge_mgmt_request_CT(qdr_core_t           *core,
     qd_compose_end_map(ap_fld);
 
     return qdrc_client_request_CT(_client,
-                                  (uintptr_t)req,   // request context
+                                  req,   // request context
                                   ap_fld,
                                   body,
                                   _mgmt_on_reply_cb_CT,

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/b501cbaf/src/router_core/modules/test_hooks/core_test_hooks.c
----------------------------------------------------------------------
diff --git a/src/router_core/modules/test_hooks/core_test_hooks.c b/src/router_core/modules/test_hooks/core_test_hooks.c
index c968690..32a1ac8 100644
--- a/src/router_core/modules/test_hooks/core_test_hooks.c
+++ b/src/router_core/modules/test_hooks/core_test_hooks.c
@@ -480,13 +480,13 @@ struct test_client_t {
     qdr_connection_t          *conn;
     qdrc_client_t             *core_client;
     int                        credit;
-    int                        counter;
+    int64_t                    counter;
 };
 
-static uint64_t _client_on_reply_cb(qdr_core_t *core,
+static uint64_t _client_on_reply_cb(qdr_core_t    *core,
                                     qdrc_client_t *client,
-                                    uintptr_t user_context,
-                                    uintptr_t request_context,
+                                    void          *user_context,
+                                    void          *request_context,
                                     qd_iterator_t *app_properties,
                                     qd_iterator_t *body)
 {
@@ -499,23 +499,23 @@ static uint64_t _client_on_reply_cb(qdr_core_t *core,
     return PN_ACCEPTED;
 }
 
-static void _client_on_ack_cb(qdr_core_t *core,
+static void _client_on_ack_cb(qdr_core_t    *core,
                               qdrc_client_t *client,
-                              uintptr_t user_context,
-                              uintptr_t request_context,
-                              uint64_t disposition)
+                              void          *user_context,
+                              void          *request_context,
+                              uint64_t       disposition)
 {
     test_client_t *tc = (test_client_t *)user_context;
     qd_log(core->log, QD_LOG_TRACE,
            "client test request ack rc=%"PRIxPTR" d=%"PRIu64,
            request_context, disposition);
-    assert(request_context < tc->counter);
+    assert((int64_t)request_context < tc->counter);
 }
-static void _client_on_done_cb(qdr_core_t *core,
+static void _client_on_done_cb(qdr_core_t    *core,
                                qdrc_client_t *client,
-                               uintptr_t user_context,
-                               uintptr_t request_context,
-                               const char *error)
+                               void          *user_context,
+                               void          *request_context,
+                               const char    *error)
 {
     qd_log(core->log, QD_LOG_TRACE,
            "client test request done rc=%"PRIxPTR" error=%s",
@@ -535,12 +535,12 @@ static void _do_send(test_client_t *tc)
         qd_compose_insert_string(props, "action");
         qd_compose_insert_string(props, "echo");
         qd_compose_insert_string(props, "counter");
-        qd_compose_insert_int(props, tc->counter);
+        qd_compose_insert_long(props, tc->counter);
         qd_compose_end_map(props);
         qd_compose_insert_string(body, "HI THERE");
 
         qdrc_client_request_CT(tc->core_client,
-                               tc->counter,  // request context
+                               (void *)tc->counter,  // request context
                                props,
                                body,
                                _client_on_reply_cb,
@@ -555,7 +555,7 @@ static void _do_send(test_client_t *tc)
 }
 
 static void _client_on_state_cb(qdr_core_t *core, qdrc_client_t *core_client,
-                                uintptr_t user_context, bool active)
+                                void *user_context, bool active)
 {
     test_client_t *tc = (test_client_t *)user_context;
     qd_log(tc->module->core->log, QD_LOG_TRACE,
@@ -563,7 +563,7 @@ static void _client_on_state_cb(qdr_core_t *core, qdrc_client_t *core_client,
 }
 
 static void _client_on_flow_cb(qdr_core_t *core, qdrc_client_t *core_client,
-                               uintptr_t user_context, int available_credit,
+                               void *user_context, int available_credit,
                                bool drain)
 {
     test_client_t *tc = (test_client_t *)user_context;
@@ -605,7 +605,7 @@ static void _on_conn_event(void *context, qdrc_event_t type, qdr_connection_t *c
                                              tc->conn,
                                              target,
                                              10,   // credit window
-                                             (uintptr_t)tc,   // user context
+                                             tc,   // user context
                                              _client_on_state_cb,
                                              _client_on_flow_cb);
             assert(tc->core_client);


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