From: Jaroslav Kysela Date: Tue, 6 Jun 2017 08:54:30 +0000 (+0200) Subject: satip client: fix another dead-lock in satip_frontend_wake_other_waiting, fixes ... X-Git-Tag: v4.2.3~45 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=54ad21e9d5beee0b1dce10cd3d391e04c70b5c26;p=thirdparty%2Ftvheadend.git satip client: fix another dead-lock in satip_frontend_wake_other_waiting, fixes #4413 --- diff --git a/src/input/mpegts/satip/satip.c b/src/input/mpegts/satip/satip.c index f468981fe..92d6562be 100644 --- a/src/input/mpegts/satip/satip.c +++ b/src/input/mpegts/satip/satip.c @@ -604,7 +604,6 @@ satip_device_create( satip_device_info_t *info ) sd->sd_sig_scale = 240; sd->sd_dbus_allow = 1; - if (!tvh_hardware_create0((tvh_hardware_t*)sd, &satip_device_class, uuid.hex, conf)) { /* Note: sd is freed in above fcn */ @@ -616,6 +615,8 @@ satip_device_create( satip_device_info_t *info ) TAILQ_INIT(&sd->sd_frontends); TAILQ_INIT(&sd->sd_serialize_queue); + atomic_set(&sd->sd_wake_ref, 0); + /* we may check if uuid matches, but the SHA hash should be enough */ if (sd->sd_info.uuid) free(sd->sd_info.uuid); diff --git a/src/input/mpegts/satip/satip_frontend.c b/src/input/mpegts/satip/satip_frontend.c index a6e162226..fb51008ef 100644 --- a/src/input/mpegts/satip/satip_frontend.c +++ b/src/input/mpegts/satip/satip_frontend.c @@ -1085,6 +1085,9 @@ satip_frontend_wake_other_waiting if (tr == NULL) return; + if (atomic_add(&lfe->sf_device->sd_wake_ref, 1) > 0) + goto end; + hash1 = tr->sf_netposhash; TAILQ_FOREACH(lfe2, &lfe->sf_device->sd_frontends, sf_link) { @@ -1100,6 +1103,9 @@ satip_frontend_wake_other_waiting tvh_write(lfe2->sf_dvr_pipe.wr, "o", 1); pthread_mutex_unlock(&lfe2->sf_dvr_lock); } + +end: + atomic_dec(&lfe->sf_device->sd_wake_ref, 1); } static void diff --git a/src/input/mpegts/satip/satip_private.h b/src/input/mpegts/satip/satip_private.h index 1955c3794..d32f032f1 100644 --- a/src/input/mpegts/satip/satip_private.h +++ b/src/input/mpegts/satip/satip_private.h @@ -96,6 +96,7 @@ struct satip_device int sd_dbus_allow; int sd_skip_ts; int sd_disable_workarounds; + int sd_wake_ref; pthread_mutex_t sd_tune_mutex; TAILQ_HEAD(,satip_frontend)sd_serialize_queue; };