You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@qpid.apache.org by GitBox <gi...@apache.org> on 2021/11/16 16:50:02 UTC

[GitHub] [qpid-dispatch] kgiusti commented on a change in pull request #1435: DISPATCH-2267 - IO-thread facility to watch for changes to address reachability

kgiusti commented on a change in pull request #1435:
URL: https://github.com/apache/qpid-dispatch/pull/1435#discussion_r750472044



##########
File path: include/qpid/dispatch/router_core.h
##########
@@ -160,6 +169,64 @@ void qdr_send_to2(qdr_core_t *core, qd_message_t *msg, const char *addr,
                   bool exclude_inprocess, bool control);
 
 
+/**
+ ******************************************************************************
+ * Address watch functions
+ ******************************************************************************
+ */
+
+typedef uint32_t qdr_watch_handle_t;
+
+/**
+ * Handler for updates on watched addresses.  This function shall be invoked on an IO thread.
+ * 
+ * Note:  This function will be invoked when a watched address has a change in reachability.
+ * It is possible that the function may be called when no change occurs, particularly when an
+ * address is removed from the core address table.
+ *
+ * @param context The opaque context supplied in the call to qdr_core_watch_address
+ * @param local_consumers Number of consuming (outgoing) links for this address on this router
+ * @param in_proc_consumers Number of in-process consumers for this address on this router
+ * @param remote_consumers Number of remote routers with consumers for this address
+ * @param local_producers Number of producing (incoming) links for this address on this router
+ */
+typedef void (*qdr_address_watch_update_t)(void     *context,
+                                           uint32_t  local_consumers,
+                                           uint32_t  in_proc_consumers,
+                                           uint32_t  remote_consumers,
+                                           uint32_t  local_producers);
+
+/**
+ * qdr_core_watch_address
+ *
+ * Subscribe to watch for changes in the reachability for an address.  It is safe to invoke this
+ * function from an IO thread.
+ * 
+ * @param core Pointer to the core module
+ * @param address The address to be watched
+ * @param aclass Address class character
+ * @param phase Address phase character ('0' .. '9')
+ * @param on_watch The handler function
+ * @param context The opaque context sent to the handler on all invocations
+ * @return Watch handle to be used when canceling the watch
+ */
+qdr_watch_handle_t qdr_core_watch_address(qdr_core_t                 *core,
+                                          const char                 *address,
+                                          char                        aclass,
+                                          char                        phase,
+                                          qdr_address_watch_update_t  on_watch,
+                                          void                       *context);
+
+/**
+ * qdr_core_unwatch_address
+ * 
+ * Cancel an address watch subscription.  It is safe to invoke this function from an IO thread.

Review comment:
       It is possible for the update handler to be invoked during or after this call on another I/O thread. That brings up a possible race:  whatever the context pointer addresses has to remain valid until we're sure that the handler will no longer be invoked, which isn't possible to tell from the caller's point of view.
   




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@qpid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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