summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorpaulo <paul@bayleaf.org.uk>2009-12-18 14:37:29 +0000
committerpaulo <paul@bayleaf.org.uk>2009-12-18 14:37:29 +0000
commitbb48a82760858f94e7d2ce767ee61d98be2ee071 (patch)
tree5e49b11cfcbddb6c045da7b6c13942237f2c26fd /lib
parent44fcadae86fa822ee40d08772584879acab73208 (diff)
downloadquagga-bb48a82760858f94e7d2ce767ee61d98be2ee071.tar.bz2
quagga-bb48a82760858f94e7d2ce767ee61d98be2ee071.tar.xz
Changes to mqueue interface to support revoke.
Diffstat (limited to 'lib')
-rw-r--r--lib/command_queue.c19
-rw-r--r--lib/mqueue.c13
-rw-r--r--lib/mqueue.h80
-rw-r--r--lib/qpnexus.c2
4 files changed, 40 insertions, 74 deletions
diff --git a/lib/command_queue.c b/lib/command_queue.c
index 9ca32e19..81ccebe5 100644
--- a/lib/command_queue.c
+++ b/lib/command_queue.c
@@ -27,7 +27,7 @@
#include "command_queue.h"
/* Prototypes */
-static void cq_action(mqueue_block mqb);
+static void cq_action(mqueue_block mqb, mqb_flag_t flag);
/* We have too many parameters for a message queue block so have to marshal */
struct marshal
@@ -56,24 +56,27 @@ cq_enqueue(struct cmd_element *matched_element, struct vty *vty,
}
mqb = mqb_init_new(mqb, cq_action, 0) ;
- mqb_set_arg0_p(mqb, wyatt);
+ mqb->arg0 = wyatt;
mqueue_enqueue(bgp_nexus->queue, mqb, 0) ;
}
/* dispatch a command from the message queue block */
static void
-cq_action(mqueue_block mqb)
+cq_action(mqueue_block mqb, mqb_flag_t flag)
{
int result;
int i;
- struct marshal *wyatt = mqb_get_arg0_p(mqb);
+ struct marshal *wyatt = mqb;
- /* Execute matched command. */
- result = (*wyatt->matched_element->func)
+ if (flag == mqb_action)
+ {
+ /* Execute matched command. */
+ result = (*wyatt->matched_element->func)
(wyatt->matched_element, wyatt->vty, wyatt->argc, (const char **)wyatt->argv);
- /* report */
- vty_queued_result(wyatt->vty, result);
+ /* report */
+ vty_queued_result(wyatt->vty, result);
+ }
/* clean up */
for (i = 0; i< wyatt->argc; ++i)
diff --git a/lib/mqueue.c b/lib/mqueue.c
index 055086ed..5afe902a 100644
--- a/lib/mqueue.c
+++ b/lib/mqueue.c
@@ -71,10 +71,9 @@
* Messages take the form of a small block of information which contains:
*
* * flags -- used by the message handler
- * * context -- identifies the context of the message (see revoke)
- *
+ *
* * action -- void action(mqueue_block) message dispatch
- * * arg0 -- *void/uintptr_t/intptr_t ) standard arguments
+ * * arg0 -- *void ) standard arguments
* * arg1 -- *void/uintptr_t/intptr_t )
*
* There are set/get functions for action/arg0/arg1 -- users should not poke
@@ -83,6 +82,8 @@
* To send a message, first allocate a message block (see mqb_init_new),
* then fill in the arguments and enqueue it.
*
+ * For specific revoke, arg0 is assumed to identify the messages to be
+ * revoked.
*
*/
@@ -181,10 +182,10 @@ static mqueue_block mqb_free_list = NULL ;
static mqueue_block mqueue_block_new_lot(void) ;
-/* Initialise message block (allocate if required) and set action and context.
+/* Initialise message block (allocate if required) and set action and arg0.
*/
mqueue_block
-mqb_init_new(mqueue_block mqb, mqueue_action action, mqb_context_t context)
+mqb_init_new(mqueue_block mqb, mqueue_action action, void* arg0)
{
if (mqb == NULL)
{
@@ -202,7 +203,7 @@ mqb_init_new(mqueue_block mqb, mqueue_action action, mqb_context_t context)
memset(mqb, 0, sizeof(struct mqueue_block)) ;
mqb->action = action ;
- mqb->context = context ;
+ mqb->arg0 = arg0 ;
return mqb ;
} ;
diff --git a/lib/mqueue.h b/lib/mqueue.h
index 6fb519d4..7d649efe 100644
--- a/lib/mqueue.h
+++ b/lib/mqueue.h
@@ -48,7 +48,15 @@ typedef union
mqb_uint_t u ;
} mqb_arg_t ;
-typedef void mqueue_action(mqueue_block mqb) ;
+enum mqb_flag
+{
+ mqb_revoke = 0,
+ mqb_action = 1
+} ;
+
+typedef enum mqb_flag mqb_flag_t ;
+
+typedef void mqueue_action(mqueue_block mqb, mqb_flag_t flag) ;
struct mqueue_block
{
@@ -58,9 +66,7 @@ struct mqueue_block
mqb_flags_t flags ; /* for message handler */
- mqb_context_t context ; /* for message revoke */
-
- mqb_arg_t arg0 ; /* may be pointer or integer */
+ void* arg0 ; /* NB: used for specific revoke */
mqb_arg_t arg1 ; /* may be pointer or integer */
} ;
@@ -133,9 +139,7 @@ mqueue_thread_signal
mqueue_thread_signal_init(mqueue_thread_signal mqt, qpt_thread_t thread,
int signum) ;
mqueue_block
-mqb_init_new(mqueue_block mqb, mqueue_action action, mqb_context_t context) ;
-
-#define mqb_new(action, context) mqb_init_new(NULL, action, context)
+mqb_init_new(mqueue_block mqb, mqueue_action action, void* arg0) ;
void
mqb_free(mqueue_block mqb) ;
@@ -156,21 +160,15 @@ mqueue_done_waiting(mqueue_queue mq, mqueue_thread_signal mtsig) ;
*/
Inline void mqb_set_action(mqueue_block mqb, mqueue_action action) ;
-Inline void mqb_set_context(mqueue_block mqb, mqb_context_t context) ;
-Inline void mqb_set_arg0_p(mqueue_block mqb, mqb_ptr_t p) ;
-Inline void mqb_set_arg0_i(mqueue_block mqb, mqb_int_t i) ;
-Inline void mqb_set_arg0_u(mqueue_block mqb, mqb_uint_t u) ;
+Inline void mqb_set_arg0(mqueue_block mqb, void* p) ;
Inline void mqb_set_arg1_p(mqueue_block mqb, mqb_ptr_t p) ;
Inline void mqb_set_arg1_i(mqueue_block mqb, mqb_int_t i) ;
Inline void mqb_set_arg1_u(mqueue_block mqb, mqb_uint_t u) ;
-Inline void mqb_dispatch(mqueue_block mqb) ;
-Inline mqb_context_t mqb_qet_context(mqueue_block mqb) ;
+Inline void mqb_dispatch(mqueue_block mqb, mqb_flag_t flag) ;
-Inline mqb_ptr_t mqb_get_arg0_p(mqueue_block mqb) ;
-Inline mqb_int_t mqb_get_arg0_i(mqueue_block mqb) ;
-Inline mqb_uint_t mqb_get_arg0_u(mqueue_block mqb) ;
+Inline void* mqb_get_arg0(mqueue_block mqb) ;
Inline mqb_ptr_t mqb_get_arg1_p(mqueue_block mqb) ;
Inline mqb_int_t mqb_get_arg1_i(mqueue_block mqb) ;
Inline mqb_uint_t mqb_get_arg1_u(mqueue_block mqb) ;
@@ -188,27 +186,9 @@ mqb_set_action(mqueue_block mqb, mqueue_action action)
} ;
Inline void
-mqb_set_context(mqueue_block mqb, mqb_context_t context)
-{
- mqb->context = context ;
-} ;
-
-Inline void
-mqb_set_arg0_p(mqueue_block mqb, mqb_ptr_t p)
-{
- mqb->arg0.p = p ;
-} ;
-
-Inline void
-mqb_set_arg0_i(mqueue_block mqb, mqb_int_t i)
-{
- mqb->arg0.i = i ;
-} ;
-
-Inline void
-mqb_set_arg0_u(mqueue_block mqb, mqb_uint_t u)
+mqb_set_arg0(mqueue_block mqb, void* arg0)
{
- mqb->arg0.u = u ;
+ mqb->arg0 = arg0 ;
} ;
Inline void
@@ -232,33 +212,15 @@ mqb_set_arg1_u(mqueue_block mqb, mqb_uint_t u)
/* Get operations */
Inline void
-mqb_dispatch(mqueue_block mqb)
-{
- mqb->action(mqb) ;
-} ;
-
-Inline mqb_context_t
-mqb_qet_context(mqueue_block mqb)
+mqb_dispatch(mqueue_block mqb, mqb_flag_t flag)
{
- return mqb->context ;
+ mqb->action(mqb, flag) ;
} ;
-Inline mqb_ptr_t
-mqb_get_arg0_p(mqueue_block mqb)
-{
- return mqb->arg0.p ;
-} ;
-
-Inline mqb_int_t
-mqb_get_arg0_i(mqueue_block mqb)
-{
- return mqb->arg0.i ;
-} ;
-
-Inline mqb_uint_t
-mqb_get_arg0_u(mqueue_block mqb)
+Inline void*
+mqb_get_arg0(mqueue_block mqb)
{
- return mqb->arg0.u ;
+ return mqb->arg0 ;
} ;
Inline mqb_ptr_t
diff --git a/lib/qpnexus.c b/lib/qpnexus.c
index fa500e36..a12a760b 100644
--- a/lib/qpnexus.c
+++ b/lib/qpnexus.c
@@ -219,7 +219,7 @@ qpn_start_bgp(void* arg)
if (mqb == NULL)
break;
- mqb_dispatch(mqb);
+ mqb_dispatch(mqb, mqb_action);
}
/* TODO: use qpselect stuff */