Skip to content

Commit

Permalink
patch: fix segfault when siprec recording is cancelled
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaian committed Dec 18, 2023
1 parent 69bb379 commit ab2d6f1
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
36 changes: 36 additions & 0 deletions packaging/debian/patches/002_siprec_recording_cancelled.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
diff --git a/modules/siprec/siprec_logic.c b/modules/siprec/siprec_logic.c
index 84911f005..82793e75f 100644
--- a/modules/siprec/siprec_logic.c
+++ b/modules/siprec/siprec_logic.c
@@ -359,6 +359,9 @@ no_recording:
srec_rtp.copy_delete(ss->rtp, &mod_name, &ss->media);
srec_logic_destroy(ss);

+ /* mark this session as cancelled */
+ ss->flags |= SIPREC_CANCELLED;
+
if (!(ss->flags & SIPREC_DLG_CBS)) {
/* if the dialog has already been engaged, then we need to keep the
* reference until the end of the dialog, where it will be cleaned up */
@@ -637,6 +640,9 @@ void tm_start_recording(struct cell *t, int type, struct tmcb_params *ps)
/* if session has been started, do not start it again */
if (ss->flags & SIPREC_STARTED)
LM_DBG("Session %p (%s) already started!\n", ss, ss->uuid);
+ /* if session has been cancelled, do not start it again */
+ else if (ss->flags & SIPREC_CANCELLED)
+ LM_DBG("Session %p (%s) already cancelled!\n", ss, ss->uuid);
else if (src_start_recording(ps->rpl, ss) < 0)
LM_ERR("cannot start recording!\n");
SIPREC_UNLOCK(ss);
diff --git a/modules/siprec/siprec_sess.h b/modules/siprec/siprec_sess.h
index d8a632263..0df200c75 100644
--- a/modules/siprec/siprec_sess.h
+++ b/modules/siprec/siprec_sess.h
@@ -76,6 +76,7 @@ struct src_part {
#define SIPREC_DLG_CBS (1<<1)
#define SIPREC_PAUSED (1<<2)
#define SIPREC_ONGOING (1<<3)
+#define SIPREC_CANCELLED (1<<4)

#define SIPREC_SRS(_s) (list_entry((_s)->srs.next, struct srs_node, list)->uri)

1 change: 1 addition & 0 deletions packaging/debian/patches/series
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
001_rtp_relay_get_leg_fix.patch
002_siprec_recording_cancelled.patch

0 comments on commit ab2d6f1

Please sign in to comment.