Skip to content

Commit

Permalink
siprec: handle replication case for late sessions
Browse files Browse the repository at this point in the history
When the call is answered by the SRS before the call is actually
answered, the dialog callbacks were no loger registered. This commit
aims to fix this situation.

Depends on 0b19546f8ca66c24f9c795b691488ec65896578a
  • Loading branch information
razvancrainea committed Feb 20, 2024
1 parent 107d837 commit 1bea6e1
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
6 changes: 6 additions & 0 deletions modules/siprec/siprec_logic.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,12 @@ int srec_register_callbacks(struct src_sess *sess)
srec_dlg_write_callback, sess, NULL))
LM_WARN("cannot register callback for session serialization! "
"Will not be able to end siprec session in case of a restart!\n");

if (srec_dlg.register_dlgcb(sess->dlg, DLGCB_PROCESS_VARS,
srec_dlg_read_callback, sess, NULL))
LM_WARN("cannot register callback for session de-serialization! "
"Will not be able to handle in-dialog for replicated sessions!\n");
LM_DBG("registered dialog callbacks for %p\n", sess);
sess->flags |= SIPREC_DLG_CBS;
return 0;
}
Expand Down
16 changes: 14 additions & 2 deletions modules/siprec/siprec_sess.c
Original file line number Diff line number Diff line change
Expand Up @@ -631,9 +631,21 @@ void srec_dlg_write_callback(struct dlg_cell *dlg, int type,
}
}

void srec_dlg_read_callback(struct dlg_cell *dlg, int type,
struct dlg_cb_params *params)
{
/* check if our variable was replicated */
if (params->dlg_data && !str_match((str *)params->dlg_data, &srec_dlg_name))
return;
/* do the same as loaded */
srec_loaded_callback(dlg, type, params);
}

static void src_event_trigger_create(struct src_sess *sess, bin_packet_t *store)
{
if (srec_push_sess(sess, store) < 0)
if (!sess)
LM_DBG("siprec session not replicated yet!\n");
else if (srec_push_sess(sess, store) < 0)
LM_WARN("could not create replicated session!\n");
}

Expand All @@ -659,7 +671,7 @@ static void src_event_receive_create(str *key, bin_packet_t *packet)
/* search for the dialog based on the key */
dlg = srec_dlg.get_dlg_by_callid(key, 0);
if (!dlg) {
LM_ERR("cannot find replicated dialog for callid %.*s\n", key->len, key->s);
LM_DBG("cannot find replicated dialog for callid %.*s\n", key->len, key->s);
return;
}

Expand Down
2 changes: 2 additions & 0 deletions modules/siprec/siprec_sess.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ void srec_loaded_callback(struct dlg_cell *dlg, int type,
struct dlg_cb_params *params);
void srec_dlg_write_callback(struct dlg_cell *dlg, int type,
struct dlg_cb_params *params);
void srec_dlg_read_callback(struct dlg_cell *dlg, int type,
struct dlg_cb_params *params);
void src_event_trigger(enum b2b_entity_type et, str *key,
str *logic_key, void *param, enum b2b_event_type event_type,
bin_packet_t *store, int backend);
Expand Down

0 comments on commit 1bea6e1

Please sign in to comment.