Skip to content

Commit

Permalink
Trigger event_routes via RPC in worker processes.
Browse files Browse the repository at this point in the history
First revert commit e3d37f4 ("added in script sync/async suport for event_route"), drop the global async/sync mod param and then migrate the async support (via dedicated process) to the RPC support
  • Loading branch information
bogdan-iancu committed Apr 12, 2019
1 parent 03bf9ac commit c9705fd
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 427 deletions.
70 changes: 5 additions & 65 deletions cfg.y
Expand Up @@ -1531,77 +1531,17 @@ timer_route_stm: ROUTE_TIMER LBRACK route_name COMMA NUMBER RBRACK LBRACE actio
| ROUTE_TIMER error { yyerror("invalid timer_route statement"); }
;


event_route_stm: ROUTE_EVENT LBRACK route_name RBRACK LBRACE actions RBRACE {
i_tmp = 1;
while(sroutes->event[i_tmp].a!=0 && i_tmp<EVENT_RT_NO){
if (strcmp($3, sroutes->event[i_tmp].name)
== 0) {
LM_ERR("Script route <%s> redefined\n", $3);
YYABORT;
}
i_tmp++;
}

if (i_tmp == EVENT_RT_NO) {
yyerror("Too many event routes defined\n");
YYABORT;
}

sroutes->event[i_tmp].name = $3;
sroutes->event[i_tmp].mode = EV_ROUTE_SYNC;

i_tmp = get_script_route_idx($3, sroutes->event,
EVENT_RT_NO,1);
if (i_tmp==-1) YYABORT;
push($6, &sroutes->event[i_tmp].a);
}
| ROUTE_EVENT LBRACK route_name COMMA SYNC_TOKEN RBRACK LBRACE actions RBRACE {

i_tmp = 1;
while(sroutes->event[i_tmp].a!=0 && i_tmp<EVENT_RT_NO){
if (strcmp($3, sroutes->event[i_tmp].name)
== 0) {
LM_ERR("Script route <%s> redefined\n", $3);
YYABORT;
}
i_tmp++;
}

if (i_tmp == EVENT_RT_NO) {
yyerror("Too many event routes defined\n");
YYABORT;
}

sroutes->event[i_tmp].name = $3;
sroutes->event[i_tmp].mode = EV_ROUTE_SYNC;

push($8, &sroutes->event[i_tmp].a);
}
| ROUTE_EVENT LBRACK route_name COMMA ASYNC_TOKEN RBRACK LBRACE actions RBRACE {

i_tmp = 1;
while (sroutes->event[i_tmp].a!=0 &&
i_tmp<EVENT_RT_NO) {
if (strcmp($3, sroutes->event[i_tmp].name)
== 0) {
LM_ERR("Script route <%s> redefined\n", $3);
YYABORT;
}
i_tmp++;
}

if (i_tmp == EVENT_RT_NO) {
yyerror("Too many event routes defined\n");
YYABORT;
}

sroutes->event[i_tmp].name = $3;
sroutes->event[i_tmp].mode = EV_ROUTE_ASYNC;

push($8, &sroutes->event[i_tmp].a);
}
| ROUTE_EVENT error { yyerror("invalid event_route statement"); }
| ROUTE_EVENT error { yyerror("invalid timer_route statement"); }
;



exp: exp AND exp { $$=mk_exp(AND_OP, $1, $3); }
| exp OR exp { $$=mk_exp(OR_OP, $1, $3); }
| NOT exp { $$=mk_exp(NOT_OP, $2, 0); }
Expand Down
31 changes: 22 additions & 9 deletions modules/event_route/doc/event_route_admin.xml
Expand Up @@ -7,16 +7,29 @@
<section id="overview" xreflabel="Overview">
<title>Overview</title>
<para>
This module provides a simple way for handling different events,
triggered through the &osips; Event Interface, directly from the &osips;
script. For a specific event, a special route
(<emphasis>event_route</emphasis>) has to be declared in the script, and
should contain the code that handles the event. The route is executed by
the module when the corresponding event is raised by the &osips; Event
Interface.Since version 1.12, the way an event is handlend (sync/async)
should be specified from the configuration script with the desired keyword
following the name of the event (<emphasis>event_route[e, sync]</emphasis>).
This module provides a simple way for capturing and handling
directly in the &osips; script of different events triggered through
the &osips; Event Interface
</para>
<para>
If you want to capture and handle a certian event, you need to
define a dedicated route (<emphasis>event_route</emphasis>) into the
&osips; script, route having as name the name/code of the
desired event. The route is triggered (and executed) by
the module when the corresponding event is raised by the &osips;
</para>
<para>
NOTE that there is the triggered <emphasis>event_route</emphasis> is
run asyncronus (and in a differen process) in regards to the code or
process that generated the actual event.
</para>
<para>
NOTE that inside the <emphasis>event_route</emphasis> you should
NOT rely on anything more than the content provide by the event itself
(see below variable). DO NOT assume to have access to any other
variable or context, not even to a SIP message.
</para>

</section>

<section id="event-route-parameters">
Expand Down

0 comments on commit c9705fd

Please sign in to comment.