@@ -243,24 +243,10 @@ static void delete_cell( struct cell *p_cell, int unlock )
243
243
244
244
static void fake_reply (struct cell * t , int branch , int code )
245
245
{
246
- static context_p my_ctx = NULL ;
247
- context_p old_ctx ;
248
246
branch_bm_t cancel_bitmap ;
249
247
short do_cancel_branch ;
250
248
enum rps reply_status ;
251
249
252
- /* as this processing is outside the scope of other messages (it is
253
- trigger from timer), a processing context must be attached to it */
254
- old_ctx = current_processing_ctx ;
255
- if (my_ctx == NULL ) {
256
- my_ctx = context_alloc (CONTEXT_GLOBAL );
257
- if (my_ctx == NULL ) {
258
- LM_ERR ("failed to alloc new ctx in pkg\n" );
259
- }
260
- }
261
- memset ( my_ctx , 0 , context_size (CONTEXT_GLOBAL ) );
262
- current_processing_ctx = my_ctx ;
263
-
264
250
do_cancel_branch = is_invite (t ) && should_cancel_branch (t , branch );
265
251
266
252
cancel_bitmap = do_cancel_branch ? 1 <<branch : 0 ;
@@ -274,14 +260,6 @@ static void fake_reply(struct cell *t, int branch, int code )
274
260
reply_status = relay_reply ( t , FAKED_REPLY , branch , code ,
275
261
& cancel_bitmap );
276
262
}
277
-
278
- if (current_processing_ctx == NULL )
279
- my_ctx = NULL ;
280
- else
281
- context_destroy (CONTEXT_GLOBAL , my_ctx );
282
-
283
- /* switch back to the old context */
284
- current_processing_ctx = old_ctx ;
285
263
}
286
264
287
265
@@ -341,6 +319,8 @@ inline static void final_response_handler( struct timer_link *fr_tl )
341
319
#define CANCEL_REASON_SIP_480 \
342
320
"Reason: SIP;cause=480;text=\"NO_ANSWER\"" CRLF
343
321
322
+ static context_p my_ctx = NULL ;
323
+ context_p old_ctx ;
344
324
struct retr_buf * r_buf ;
345
325
struct cell * t ;
346
326
@@ -385,6 +365,20 @@ inline static void final_response_handler( struct timer_link *fr_tl )
385
365
return ;
386
366
};
387
367
368
+ /* as this processing is outside the scope of other messages (it is
369
+ trigger from timer), a processing context must be attached to it */
370
+ old_ctx = current_processing_ctx ;
371
+ if (my_ctx == NULL ) {
372
+ my_ctx = context_alloc (CONTEXT_GLOBAL );
373
+ if (my_ctx == NULL ) {
374
+ LM_ERR ("failed to alloc new ctx in pkg\n" );
375
+ }
376
+ }
377
+ memset ( my_ctx , 0 , context_size (CONTEXT_GLOBAL ) );
378
+ current_processing_ctx = my_ctx ;
379
+ /* set the T context too */
380
+ set_t ( t );
381
+
388
382
/* out-of-lock do the cancel I/O */
389
383
if (is_invite (t ) && should_cancel_branch (t , r_buf -> branch ) ) {
390
384
set_cancel_extra_hdrs ( CANCEL_REASON_SIP_480 , sizeof (CANCEL_REASON_SIP_480 )- 1 );
@@ -396,6 +390,16 @@ inline static void final_response_handler( struct timer_link *fr_tl )
396
390
LM_DBG ("Cancel sent out, sending 408 (%p)\n" , t );
397
391
fake_reply (t , r_buf -> branch , 408 );
398
392
393
+ /* flush the context */
394
+ if (current_processing_ctx == NULL )
395
+ my_ctx = NULL ;
396
+ else
397
+ context_destroy (CONTEXT_GLOBAL , my_ctx );
398
+ /* switch back to the old context */
399
+ current_processing_ctx = old_ctx ;
400
+ /* reset the T context */
401
+ init_t ();
402
+
399
403
LM_DBG ("done\n" );
400
404
}
401
405
0 commit comments