Navigation Menu

Skip to content

Commit

Permalink
siprec: move b2b key in shm
Browse files Browse the repository at this point in the history
  • Loading branch information
razvancrainea committed Nov 22, 2017
1 parent 88d998f commit 2108f12
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
17 changes: 11 additions & 6 deletions modules/siprec/src_logic.c
Expand Up @@ -43,12 +43,12 @@ static void srec_dlg_end(struct dlg_cell *dlg, int type, struct dlg_cb_params *_

memset(&req, 0, sizeof(req));
req.et = B2B_CLIENT;
req.b2b_key = ss->b2b_key;
req.b2b_key = &ss->b2b_key;
req.method = &bye;
req.no_cb = 1; /* do not call callback */

if (srec_b2b.send_request(&req) < 0)
LM_ERR("Cannot end recording session for key %.*s\n",
LM_ERR("Cannot end recording session for key %.*s\n",
req.b2b_key->len, req.b2b_key->s);
/* TODO: remove! */
}
Expand Down Expand Up @@ -77,12 +77,12 @@ static int srec_b2b_notify(struct sip_msg *msg, str *key, int type, void *param)
/* reply received - sending ACK */
memset(&req, 0, sizeof(req));
req.et = B2B_CLIENT;
req.b2b_key = ss->b2b_key;
req.b2b_key = &ss->b2b_key;
req.method = &ack;
req.no_cb = 1; /* do not call callback */

if (srec_b2b.send_request(&req) < 0) {
LM_ERR("Cannot end recording session for key %.*s\n",
LM_ERR("Cannot ack recording session for key %.*s\n",
req.b2b_key->len, req.b2b_key->s);
goto no_recording;
}
Expand Down Expand Up @@ -184,8 +184,13 @@ int src_start_recording(struct sip_msg *msg, struct src_sess *sess)
}

/* store the key in the param */
/* TODO: make sure the session/key is not destroyed before this */
sess->b2b_key = client;
sess->b2b_key.s = shm_malloc(client->len);
if (!sess->b2b_key.s) {
LM_ERR("out of shm memory!\n");
return -1;
}
memcpy(sess->b2b_key.s, client->s, client->len);
sess->b2b_key.len = client->len;

/* release generated body */
pkg_free(body.s);
Expand Down
1 change: 1 addition & 0 deletions modules/siprec/src_sess.c
Expand Up @@ -95,6 +95,7 @@ void src_free_session(struct src_sess *sess)

for (p = 0; p < sess->participants_no; p++)
src_free_participant(&sess->participants[p]);
shm_free(sess->b2b_key.s);
shm_free(sess);
}

Expand Down
2 changes: 1 addition & 1 deletion modules/siprec/src_sess.h
Expand Up @@ -58,7 +58,7 @@ struct src_sess {
struct src_part participants[SRC_MAX_PARTICIPANTS];

/* internal */
str *b2b_key;
str b2b_key;
struct dlg_cell *dlg;
//gen_lock_t lock;
};
Expand Down

0 comments on commit 2108f12

Please sign in to comment.