Review Board 1.7.16


Fix bridge/channel AMI event ordering issues

Review Request #2677 - Created July 15, 2013 and submitted

David Lee
/trunk
ASTERISK-22038
Reviewers
asterisk-dev
Asterisk
The stasis_cache_update messages are somewhat cumbersome to handle
with the stasis_message_router. Since all updates have the same
message type, they are normally handled with the same route.

Since caching itself is a first class component of stasis-core, it
makes sense for the router to handle the cache update messages itself.
This patch adds stasis_message_router_add_cache_update() and
stasis_message_router_remove_cache_update() to handle the routing of
stasis_cache_update messages.

This patch also corrects an issue with manager_{bridging,channels}.c,
where events might be reordered. The reordering occurs because the
components use different message routers, which they needed because
they both needed to route cache update messages. They now both use
manager's router, and add cache routes for just the cache updates they
are interested in.
Unit tests! 

Note that https://reviewboard.asterisk.org/r/2675/ is required to fix
assertions during the test.
/trunk/include/asterisk/stasis_message_router.h
Revision 394397 New Change
[20] 92 lines
[+20] [+] void stasis_message_router_unsubscribe_and_join(
93
int stasis_message_router_is_done(struct stasis_message_router *router);
93
int stasis_message_router_is_done(struct stasis_message_router *router);
94

    
   
94

   
95
/*!
95
/*!
96
 * \brief Add a route to a message router.
96
 * \brief Add a route to a message router.
97
 *
97
 *

    
   
98
 * A particular \a message_type may have at most one route per \a router. If

    
   
99
 * you route \ref stasis_cache_update messages, the callback will only receive

    
   
100
 * updates for types not handled by routes added with

    
   
101
 * stasis_message_router_add_cache_update().

    
   
102
 *
98
 * \param router Router to add the route to.
103
 * \param router Router to add the route to.
99
 * \param message_type Type of message to route.
104
 * \param message_type Type of message to route.
100
 * \param callback Callback to forard messages of \a message_type to.
105
 * \param callback Callback to forard messages of \a message_type to.
101
 * \param data Data pointer to pass to \a callback.
106
 * \param data Data pointer to pass to \a callback.
102
 *
107
 *
103
 * \retval 0 on success
108
 * \retval 0 on success
104
 * \retval -1 on failure
109
 * \retval -1 on failure
105
 *
110
 *
106
 * \since 12
111
 * \since 12
107
 */
112
 */
108
int stasis_message_router_add(struct stasis_message_router *router,
113
int stasis_message_router_add(struct stasis_message_router *router,
109
			      struct stasis_message_type *message_type,
114
	struct stasis_message_type *message_type,
110
			      stasis_subscription_cb callback,
115
	stasis_subscription_cb callback, void *data);
111
			      void *data);
116

   

    
   
117
/*!

    
   
118
 * \brief Add a route for \ref stasis_cache_update messages to a message router.

    
   
119
 *

    
   
120
 * A particular \a message_type may have at most one cache route per \a router.

    
   
121
 * These are distinct from regular routes, so one could have both a regular

    
   
122
 * route and a cache route for the same \a message_type.

    
   
123
 *

    
   
124
 * \param router Router to add the route to.

    
   
125
 * \param message_type Subtype of cache update to route.

    
   
126
 * \param callback Callback to forard messages of \a message_type to.

    
   
127
 * \param data Data pointer to pass to \a callback.

    
   
128
 *

    
   
129
 * \retval 0 on success

    
   
130
 * \retval -1 on failure

    
   
131
 *

    
   
132
 * \since 12

    
   
133
 */

    
   
134
int stasis_message_router_add_cache_update(struct stasis_message_router *router,

    
   
135
	struct stasis_message_type *message_type,

    
   
136
	stasis_subscription_cb callback, void *data);
112

    
   
137

   
113
/*!
138
/*!
114
 * \brief Remove a route from a message router.
139
 * \brief Remove a route from a message router.
115
 *
140
 *
116
 * \param router Router to remove the route from.
141
 * \param router Router to remove the route from.
117
 * \param message_type Type of message to route.
142
 * \param message_type Type of message to route.
118
 *
143
 *
119
 * \since 12
144
 * \since 12
120
 */
145
 */
121
void stasis_message_router_remove(struct stasis_message_router *router,
146
void stasis_message_router_remove(struct stasis_message_router *router,
122
			      struct stasis_message_type *message_type);
147
	struct stasis_message_type *message_type);
123

    
   
148

   
124
/*!
149
/*!

    
   
150
 * \brief Remove a cache route from a message router.

    
   
151
 *

    
   
152
 * \param router Router to remove the route from.

    
   
153
 * \param message_type Type of message to route.

    
   
154
 *

    
   
155
 * \since 12

    
   
156
 */

    
   
157
void stasis_message_router_remove_cache_update(

    
   
158
	struct stasis_message_router *router,

    
   
159
	struct stasis_message_type *message_type);

    
   
160

   

    
   
161
/*!
125
 * \brief Sets the default route of a router.
162
 * \brief Sets the default route of a router.
126
 *
163
 *
127
 * \param router Router to set the default route of.
164
 * \param router Router to set the default route of.
128
 * \param callback Callback to forard messages which otherwise have no home.
165
 * \param callback Callback to forard messages which otherwise have no home.
129
 * \param data Data pointer to pass to \a callback.
166
 * \param data Data pointer to pass to \a callback.
[+20] [20] 11 lines
/trunk/main/cdr.c
Revision 394397 New Change
 
/trunk/main/manager_bridging.c
Revision 394397 New Change
 
/trunk/main/manager_channels.c
Revision 394397 New Change
 
/trunk/main/stasis_message_router.c
Revision 394397 New Change
 
/trunk/tests/test_stasis.c
Revision 394397 New Change
 
  1. /trunk/include/asterisk/stasis_message_router.h: Loading...
  2. /trunk/main/cdr.c: Loading...
  3. /trunk/main/manager_bridging.c: Loading...
  4. /trunk/main/manager_channels.c: Loading...
  5. /trunk/main/stasis_message_router.c: Loading...
  6. /trunk/tests/test_stasis.c: Loading...

https://reviewboard.asterisk.org/ runs on a server provided by Digium, Inc. and uses bandwidth donated to the open source Asterisk community by API Digital Communications in Huntsville, AL USA.
Please report problems with this site to asteriskteam@digium.com.