From: <dg...@su...> - 2009-01-24 18:15:14
|
Author: Graham Cobb Date: Sat Jan 24 19:13:57 2009 New Revision: 5228 URL: http://www.opensync.org/changeset/5228 Log: Done: 3) Add references for cross-linked pointers between queues and remove linkages (and unref) when queue disconnected All tests passed This leaves: 4) Handle timeout before reply queue set up by generating an error message on the command queue 6) Implement a mechanism to protect the queue itself: i.e. is the receiver still reading the queue? Modified: branches/timeout/ChangeLog branches/timeout/opensync/ipc/opensync_queue.c branches/timeout/opensync/ipc/opensync_queue_internals.h Modified: branches/timeout/ChangeLog ============================================================================== --- branches/timeout/ChangeLog Sat Jan 24 01:29:49 2009 (r5227) +++ branches/timeout/ChangeLog Sat Jan 24 19:13:57 2009 (r5228) @@ -1,3 +1,11 @@ +2009-01-24 Graham Cobb <g+...@co...> + + * opensync/ipc/opensync_queue.c (osync_queue_remove_cross_link): Add + osync_queue_remove_cross_link + (osync_queue_disconnect): Call osync_queue_remove_cross_link + + * opensync/ipc/opensync_queue_internals.h: Add osync_queue_remove_cross_link + 2009-01-23 Graham Cobb <g+...@co...> * opensync/client/opensync_client.c (osync_client_set_incoming_queue): Call Modified: branches/timeout/opensync/ipc/opensync_queue.c ============================================================================== --- branches/timeout/opensync/ipc/opensync_queue.c Sat Jan 24 01:29:49 2009 (r5227) +++ branches/timeout/opensync/ipc/opensync_queue.c Sat Jan 24 19:13:57 2009 (r5228) @@ -1000,6 +1000,8 @@ osync_trace(TRACE_ENTRY, "%s(%p, %p)", __func__, queue, error); osync_assert(queue); + osync_queue_remove_cross_link(queue); + g_mutex_lock(queue->disconnectLock); if (queue->thread) { osync_thread_stop(queue->thread); @@ -1068,11 +1070,31 @@ osync_assert(reply_queue->type == OSYNC_QUEUE_SENDER); cmd_queue->reply_queue = reply_queue; + osync_queue_ref(reply_queue); reply_queue->cmd_queue = cmd_queue; + osync_queue_ref(cmd_queue); osync_trace(TRACE_EXIT, "%s", __func__); } +void osync_queue_remove_cross_link(OSyncQueue *queue) +{ + /* Remove the cross links from this queue and all queues linked + from it, recursively */ + if (queue->cmd_queue) { + OSyncQueue *linked_queue = queue->cmd_queue; + queue->cmd_queue = NULL; + osync_queue_remove_cross_link(linked_queue); + osync_queue_unref(linked_queue); + } + if (queue->reply_queue) { + OSyncQueue *linked_queue = queue->reply_queue; + queue->reply_queue = NULL; + osync_queue_remove_cross_link(linked_queue); + osync_queue_unref(linked_queue); + } +} + void osync_queue_set_pending_limit(OSyncQueue *queue, unsigned int limit) { /* The pending limit is used on queues which receive commands and run timeouts. Modified: branches/timeout/opensync/ipc/opensync_queue_internals.h ============================================================================== --- branches/timeout/opensync/ipc/opensync_queue_internals.h Sat Jan 24 01:29:49 2009 (r5227) +++ branches/timeout/opensync/ipc/opensync_queue_internals.h Sat Jan 24 19:13:57 2009 (r5228) @@ -99,6 +99,17 @@ OSYNC_TEST_EXPORT void osync_queue_cross_link(OSyncQueue *cmd_queue, OSyncQueue *reply_queue); /** + * @brief Remove cross links between command queues and reply queues + * + * Removes the cross-links from this queue and all queues linked + * from it, recursively + * + * @param queue The queue to unlink + * + */ +OSYNC_TEST_EXPORT void osync_queue_remove_cross_link(OSyncQueue *queue); + +/** * @brief Set pending limit on queue * * This should be used on queues used to receive incoming commands to |