summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathieu Duponchelle <mathieu.duponchelle@opencreed.com>2017-01-04 19:15:55 (GMT)
committerRobert Swain <robert.swain@ericsson.com>2017-01-05 11:47:20 (GMT)
commitba570daa9a38838ae7a80a01b24e1877f01f6169 (patch)
treefde9ca119c846ab14a6361c63e053f3898d1171f
parentb6a118ae8cfb90c0a7a3807bcf719934e4e82086 (diff)
downloadopenwebrtc-gst-plugins-ba570daa9a38838ae7a80a01b24e1877f01f6169.tar.gz
openwebrtc-gst-plugins-ba570daa9a38838ae7a80a01b24e1877f01f6169.tar.xz
sctpassociation: check usrsctp_finish's return code.
And only call usrsctp_init() again if finish succeeded. There are cases where finish may fail, and calling init again afterwards causes various race conditions. usrsctp's example programs check for the return code (see https://github.com/sctplab/usrsctp/blob/0c44eac/programs/client.c#L273), calling sleep(1) as long as the call didn't succeed. I don't think this an option here, and maybe some more complex logic could be implemented using a timeout, but the goal here is simply not to trigger the error conditions that may arise from calling init again after finish failed. Closes #56.
-rw-r--r--ext/sctp/sctpassociation.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/ext/sctp/sctpassociation.c b/ext/sctp/sctpassociation.c
index 3056989..cfa5ab2 100644
--- a/ext/sctp/sctpassociation.c
+++ b/ext/sctp/sctpassociation.c
@@ -86,6 +86,7 @@ static GParamSpec *properties[NUM_PROPERTIES];
#define DEFAULT_REMOTE_SCTP_PORT 0
static GHashTable *associations = NULL;
+static gboolean initialized = FALSE;
G_LOCK_DEFINE_STATIC(associations_lock);
/* Interface implementations */
@@ -156,8 +157,9 @@ static void gst_sctp_association_class_init (GstSctpAssociationClass *klass)
static void gst_sctp_association_init (GstSctpAssociation *self)
{
/* No need to lock mutex here as long as the function is only called from gst_sctp_association_get */
- if (g_hash_table_size(associations) == 0) {
+ if (!initialized) {
usrsctp_init(0, sctp_packet_out, g_print);
+ initialized = TRUE;
usrsctp_sysctl_set_sctp_blackhole(2);
@@ -191,7 +193,8 @@ static void gst_sctp_association_finalize(GObject *object)
usrsctp_deregister_address((void *) self);
if (g_hash_table_size(associations) == 0) {
- usrsctp_finish();
+ if (usrsctp_finish() == 0)
+ initialized = FALSE;
}
G_UNLOCK(associations_lock);