You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by tr...@apache.org on 2015/11/06 21:01:40 UTC
qpid-dispatch git commit: DISPATCH-179 - Updated the core-API for
connections and links
Repository: qpid-dispatch
Updated Branches:
refs/heads/tross-DISPATCH-179-1 df2bf5de9 -> b3b3d79df
DISPATCH-179 - Updated the core-API for connections and links
Project: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/commit/b3b3d79d
Tree: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/tree/b3b3d79d
Diff: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/diff/b3b3d79d
Branch: refs/heads/tross-DISPATCH-179-1
Commit: b3b3d79df1ac6319c54ff03f2ba55d6daa82d433
Parents: df2bf5d
Author: Ted Ross <tr...@redhat.com>
Authored: Fri Nov 6 15:01:14 2015 -0500
Committer: Ted Ross <tr...@redhat.com>
Committed: Fri Nov 6 15:01:14 2015 -0500
----------------------------------------------------------------------
include/qpid/dispatch/router_core.h | 96 ++++++++++++++++++++++++------
src/router_core/connections.c | 56 ++++++++++++++++-
src/router_core/router_core_private.h | 9 +++
3 files changed, 140 insertions(+), 21 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/b3b3d79d/include/qpid/dispatch/router_core.h
----------------------------------------------------------------------
diff --git a/include/qpid/dispatch/router_core.h b/include/qpid/dispatch/router_core.h
index 5180996..553d0da 100644
--- a/include/qpid/dispatch/router_core.h
+++ b/include/qpid/dispatch/router_core.h
@@ -28,6 +28,8 @@
/**
* All callbacks in this module shall be invoked on a connection thread from the server thread pool.
+ * If the callback needs to perform work on a connection, it will be invoked on a thread that has
+ * exclusive access to that connection.
*/
typedef struct qdr_core_t qdr_core_t;
@@ -86,47 +88,105 @@ void qdr_core_subscribe(qdr_core_t *core, const char *address, char aclass, char
* Connection functions
******************************************************************************
*/
-typedef enum {
- QDR_WORK_FIRST_ATTACH, // Core is initiating a first-attach
- QDR_WORK_SECOND_ATTACH, // Core is sending a second-attach
- QDR_WORK_DETACH, // Core is sending a detach
- QDR_WORK_DELIVERY // Core is updating a delivery for in-thread processing
-} qdr_work_type_t;
-
-typedef struct {
- qdr_work_type_t work_type;
- pn_terminus_t *source; // For FIRST_ATTACH
- pn_terminus_t *target; // For FIRST_ATTACH
- qdr_link_t *link; // For SECOND_ATTACH, DETACH
- qdr_delivery_t *delivery; // For DELIVERY
-} qdr_work_t;
/**
* qdr_connection_opened
*
- * This function must be called once for every
+ * This function must be called once for every connection that is opened in the router.
+ * Once a new connection has been both remotely and locally opened, the core must be notified.
+ *
+ * @param core Pointer to the core object
+ * @param label Optional label provided in the connection's configuration. This is used to
+ * correlate the connection with waypoints and link-route destinations that use the connection.
+ * @return Pointer to a connection object that can be used to refer to this connection over its lifetime.
*/
qdr_connection_t *qdr_connection_opened(qdr_core_t *core, const char *label);
+
+/**
+ * qdr_connection_closed
+ *
+ * This function must be called when a connection is closed, either cleanly by protocol
+ * or uncleanly by lost connectivity. Once this functino is called, the caller must never
+ * again refer to or use the connection pointer.
+ *
+ * @param conn The pointer returned by qdr_connection_opened
+ */
void qdr_connection_closed(qdr_connection_t *conn);
+
+/**
+ * qdr_connection_set_context
+ *
+ * Store an arbitrary void pointer in the connection object.
+ */
void qdr_connection_set_context(qdr_connection_t *conn, void *context);
+
+/**
+ * qdr_connection_get_context
+ *
+ * Retrieve the stored void pointer from the connection object.
+ */
void *qdr_connection_get_context(qdr_connection_t *conn);
-qdr_work_t *qdr_connection_work(qdr_connection_t *conn);
-typedef void (*qdr_connection_activate_t) (void *context, const qdr_connection_t *connection);
-void qdr_connection_activate_handler(qdr_core_t *core, qdr_connection_activate_t handler, void *context);
+/**
+ * qdr_connection_activate_t callback
+ *
+ * Activate a connection for transmission (socket write). This is called whenever
+ * the core has deliveries on links, disposition updates on deliveries, or flow updates
+ * to be sent across the connection.
+ *
+ * @param context The context supplied when the callback was registered
+ * @param conn The connection object to be activated
+ */
+typedef void (*qdr_connection_activate_t) (void *context, qdr_connection_t *conn);
/**
******************************************************************************
* Link functions
******************************************************************************
*/
+
+/**
+ * qdr_link_first_attach
+ *
+ * This function is invoked when a first-attach (not a response to an earlier attach)
+ * arrives for a connection.
+ *
+ * @param conn Connection pointer returned by qdr_connection_opened
+ * @param dir Direction of the new link, incoming or outgoing
+ * @param source Source terminus of the attach
+ * @param target Target terminus of the attach
+ * @return A pointer to a new qdr_link_t object to track the link
+ */
qdr_link_t *qdr_link_first_attach(qdr_connection_t *conn, qd_direction_t dir, pn_terminus_t *source, pn_terminus_t *target);
+
+/**
+ * qdr_link_second_attach
+ *
+ * This function is invoked when a second-attach (a response to an attach we sent)
+ * arrives for a connection.
+ *
+ * @param link The link pointer returned by qdr_link_first_attach or in a FIRST_ATTACH event.
+ * @param source Source terminus of the attach
+ * @param target Target terminus of the attach
+ */
void qdr_link_second_attach(qdr_link_t *link, pn_terminus_t *source, pn_terminus_t *target);
+
+/**
+ * qdr_link_detach
+ *
+ * This function is invoked when a link detach arrives.
+ *
+ * @param link The link pointer returned by qdr_link_first_attach or in a FIRST_ATTACH event.
+ * @param condition The link condition from the detach frame.
+ */
void qdr_link_detach(qdr_link_t *link, pn_condition_t *condition);
qdr_delivery_t *qdr_link_deliver(qdr_link_t *link, pn_delivery_t *delivery, qd_message_t *msg);
qdr_delivery_t *qdr_link_deliver_to(qdr_link_t *link, pn_delivery_t *delivery, qd_message_t *msg, qd_field_iterator_t *addr);
+typedef void (*qdr_link_first_attach_t) (void *context, qdr_connection_t *conn, qd_direction_t dir, pn_terminus_t *source, pn_terminus_t *target);
+typedef void (*qdr_link_second_attach_t) (void *context, qdr_link_t *link, pn_terminus_t *source, pn_terminus_t *target);
+typedef void (*qdr_link_detach_t) (void *context, qdr_link_t *link, pn_condition_t *condition);
/**
******************************************************************************
http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/b3b3d79d/src/router_core/connections.c
----------------------------------------------------------------------
diff --git a/src/router_core/connections.c b/src/router_core/connections.c
index 14e95fd..2d7fdc0 100644
--- a/src/router_core/connections.c
+++ b/src/router_core/connections.c
@@ -21,6 +21,9 @@
static void qdr_connection_opened_CT(qdr_core_t *core, qdr_action_t *action, bool discard);
static void qdr_connection_closed_CT(qdr_core_t *core, qdr_action_t *action, bool discard);
+static void qdr_link_first_attach_CT(qdr_core_t *core, qdr_action_t *action, bool discard);
+static void qdr_link_second_attach_CT(qdr_core_t *core, qdr_action_t *action, bool discard);
+static void qdr_link_detach_CT(qdr_core_t *core, qdr_action_t *action, bool discard);
ALLOC_DEFINE(qdr_connection_t);
@@ -70,14 +73,43 @@ void *qdr_connection_get_context(qdr_connection_t *conn)
}
-qdr_work_t *qdr_connection_work(qdr_connection_t *conn)
+qdr_link_t *qdr_link_first_attach(qdr_connection_t *conn, qd_direction_t dir, pn_terminus_t *source, pn_terminus_t *target)
{
- return 0;
+ qdr_action_t *action = qdr_action(qdr_link_first_attach_CT);
+ qdr_link_t *link = new_qdr_link_t();
+
+ link->core = conn->core;
+ link->conn = conn;
+
+ action->args.connection.conn = conn;
+ action->args.connection.link = link;
+ action->args.connection.dir = dir;
+ action->args.connection.source = source;
+ action->args.connection.target = target;
+ qdr_action_enqueue(conn->core, action);
+
+ return link;
+}
+
+
+void qdr_link_second_attach(qdr_link_t *link, pn_terminus_t *source, pn_terminus_t *target)
+{
+ qdr_action_t *action = qdr_action(qdr_link_second_attach_CT);
+
+ action->args.connection.link = link;
+ action->args.connection.source = source;
+ action->args.connection.target = target;
+ qdr_action_enqueue(link->core, action);
}
-void qdr_connection_activate_handler(qdr_core_t *core, qdr_connection_activate_t handler, void *context)
+void qdr_link_detach(qdr_link_t *link, pn_condition_t *condition)
{
+ qdr_action_t *action = qdr_action(qdr_link_detach_CT);
+
+ action->args.connection.link = link;
+ action->args.connection.condition = condition;
+ qdr_action_enqueue(link->core, action);
}
@@ -119,9 +151,27 @@ static void qdr_connection_closed_CT(qdr_core_t *core, qdr_action_t *action, boo
//
// TODO - Clean up links associated with this connection
+ // This involves the links and the dispositions of deliveries stored
+ // with the links.
//
DEQ_REMOVE(core->open_connections, conn);
free_qdr_connection_t(conn);
}
+
+static void qdr_link_first_attach_CT(qdr_core_t *core, qdr_action_t *action, bool discard)
+{
+}
+
+
+static void qdr_link_second_attach_CT(qdr_core_t *core, qdr_action_t *action, bool discard)
+{
+}
+
+
+static void qdr_link_detach_CT(qdr_core_t *core, qdr_action_t *action, bool discard)
+{
+}
+
+
http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/b3b3d79d/src/router_core/router_core_private.h
----------------------------------------------------------------------
diff --git a/src/router_core/router_core_private.h b/src/router_core/router_core_private.h
index 54ff4cf..69b990a 100644
--- a/src/router_core/router_core_private.h
+++ b/src/router_core/router_core_private.h
@@ -67,6 +67,13 @@ struct qdr_action_t {
//
struct {
qdr_connection_t *conn;
+ qdr_link_t *link;
+ qdr_delivery_t *delivery;
+ qd_message_t *msg;
+ qd_direction_t dir;
+ pn_terminus_t *source;
+ pn_terminus_t *target;
+ pn_condition_t *condition;
} connection;
//
@@ -146,6 +153,8 @@ DEQ_DECLARE(qdr_router_ref_t, qdr_router_ref_list_t);
struct qdr_link_t {
DEQ_LINKS(qdr_link_t);
+ qdr_core_t *core;
+ qdr_connection_t *conn;
int mask_bit; ///< Unique mask bit if this is an inter-router link
qd_link_type_t link_type;
qd_direction_t link_direction;
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org