Skip to content

Commit

Permalink
[uac_registrant] avoid code duplicate
Browse files Browse the repository at this point in the history
Use common/shared functions for pushing / poping new processing context
A follow up on 3705209

(cherry picked from commit 44c25db)
  • Loading branch information
bogdan-iancu committed Jun 30, 2023
1 parent 2a3eb1e commit 4b902bc
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions modules/uac_registrant/registrant.c
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,6 @@ int send_register(unsigned int hash_index, reg_record_t *rec, str *auth_hdr)
{
int result, expires_len;
reg_tm_cb_t *cb_param;
context_p old_ctx;
char *p, *expires;

/* Allocate space for tm callback params */
Expand Down Expand Up @@ -812,8 +811,7 @@ int send_register(unsigned int hash_index, reg_record_t *rec, str *auth_hdr)
LM_DBG("extra_hdrs=[%p][%d]->[%.*s]\n",
extra_hdrs.s, extra_hdrs.len, extra_hdrs.len, extra_hdrs.s);

old_ctx = current_processing_ctx;
if ( (current_processing_ctx = context_alloc(CONTEXT_GLOBAL))==NULL ) {
if ( !push_new_global_context() ) {

LM_ERR("failed to alloc new ctx in pkg\n");
result = 0;
Expand All @@ -833,12 +831,9 @@ int send_register(unsigned int hash_index, reg_record_t *rec, str *auth_hdr)
(void *)cb_param, /* callback param */
osips_shm_free); /* function to release the parameter */

clear_global_context();

pop_pushed_global_context();
}

current_processing_ctx = old_ctx; /* restore prev context */

if (result < 1)
shm_free(cb_param);

Expand Down

0 comments on commit 4b902bc

Please sign in to comment.