| 210 | } |
| 211 | |
| 212 | int run_top_route(struct script_route sr, struct sip_msg* msg) |
| 213 | { |
| 214 | static int recursing; |
| 215 | |
| 216 | int bk_action_flags, route_stack_start_bkp = -1, route_stack_size_bkp; |
| 217 | int ret; |
| 218 | context_p ctx = NULL; |
| 219 | const char *trace_file = NULL; |
| 220 | int trace_line = 0; |
| 221 | |
| 222 | bk_action_flags = action_flags; |
| 223 | |
| 224 | action_flags = 0; |
| 225 | init_err_info(); |
| 226 | |
| 227 | if (current_processing_ctx==NULL) { |
| 228 | if ( (ctx=context_alloc(CONTEXT_GLOBAL))==NULL) { |
| 229 | LM_ERR("failed to allocated new global context\n"); |
| 230 | return -1; |
| 231 | } |
| 232 | memset( ctx, 0, context_size(CONTEXT_GLOBAL)); |
| 233 | set_global_context(ctx); |
| 234 | } |
| 235 | |
| 236 | /* the recursion support allows run_top_route() to be freely called from |
| 237 | * other modules (e.g. dialog) in order to provide contextless script |
| 238 | * callbacks using routes, without losing the original route stack */ |
| 239 | if (recursing) { |
| 240 | route_stack_start_bkp = route_stack_start; |
| 241 | route_stack_size_bkp = route_stack_size; |
| 242 | route_stack_start = route_stack_size; |
| 243 | route_stack_size += 1; |
| 244 | } else { |
| 245 | route_stack_start = 0; |
| 246 | route_stack_size = 1; |
| 247 | recursing = 1; |
| 248 | } |
| 249 | |
| 250 | if (route_type & (ERROR_ROUTE|LOCAL_ROUTE|STARTUP_ROUTE) || |
| 251 | (route_type & |
| 252 | (REQUEST_ROUTE|ONREPLY_ROUTE) && !strcmp(sr.name, "0"))) |
| 253 | route_stack[route_stack_start] = NULL; |
| 254 | else |
| 255 | route_stack[route_stack_start] = sr.name; |
| 256 | |
| 257 | if (profiling_enabled(PROFILING_DATA_TYPE_SCRIPT)) { |
| 258 | if (sr.a && sr.a->file) { |
| 259 | trace_file = sr.a->file; |
| 260 | trace_line = sr.a->line; |
| 261 | } |
| 262 | profiling_msg_start(msg, route_type, route_stack[route_stack_start], |
| 263 | route_stack_size - route_stack_start); |
| 264 | profiling_route_enter(msg, route_type, route_stack[route_stack_start], |
| 265 | trace_file, trace_line, route_stack_size - route_stack_start); |
| 266 | } |
| 267 | |
| 268 | run_actions(sr.a, msg); |
| 269 | ret = action_flags; |
no test coverage detected