[vlc-devel] [PATCH 5/5] sap: simplify not using cancellation
Rémi Denis-Courmont
remi at remlab.net
Mon Feb 10 08:49:45 CET 2020
Hi,
No, it's one thread per address/socket, handling one or more sessions.
Le 10 février 2020 09:46:54 GMT+02:00, Steve Lhomme <robux4 at ycbcr.xyz> a écrit :
>On 2020-02-10 8:22, Rémi Denis-Courmont wrote:
>> Hi,
>>
>> Before it would wait to be cancelled when there are no sessions. Now
>it
>> exits on its own.
>
>Ah, I just realized that it's one thread per session. I thought it was
>one for all.
>
>So if you register, unregister, register the same session it was
>already
>closing the first thread and create a new one.
>
>
>
>> Le 10 février 2020 08:54:21 GMT+02:00, Steve Lhomme
><robux4 at ycbcr.xyz> a
>> écrit :
>>
>> On 2020-02-09 14:33, Rémi Denis-Courmont wrote:
>>
>>
>------------------------------------------------------------------------
>> src/stream_output/sap.c | 22 ++++++++--------------
>> 1 file changed, 8 insertions(+), 14 deletions(-)
>>
>> diff --git a/src/stream_output/sap.c
>b/src/stream_output/sap.c
>> index eb85ab7297..481f3e5f20 100644
>> --- a/src/stream_output/sap.c
>> +++ b/src/stream_output/sap.c
>> @@ -27,7 +27,6 @@
>>
>> #include <vlc_common.h>
>>
>> -#include <stdnoreturn.h>
>> #include <stdlib.h> /* free() */
>> #include <stdio.h> /* sprintf() */
>> #include <string.h>
>> @@ -81,7 +80,7 @@ static vlc_mutex_t sap_mutex =
>VLC_STATIC_MUTEX;
>> #define MIN_INTERVAL 2
>> #define MAX_INTERVAL 300
>>
>> -noreturn static void *RunThread (void *);
>> +static void *RunThread (void *);
>>
>> static sap_address_t *AddressCreate (vlc_object_t *obj, const
>> char *group)
>> {
>> @@ -120,14 +119,13 @@ static void AddressDestroy
>(sap_address_t
>> *addr)
>> * \param p_this the SAP Handler object
>> * \return nothing
>> */
>> -noreturn static void *RunThread (void *self)
>> +static void *RunThread (void *self)
>> {
>> sap_address_t *addr = self;
>>
>> vlc_mutex_lock(&sap_mutex);
>> - mutex_cleanup_push(&sap_mutex);
>>
>> - for (;;)
>> + while (!vlc_list_is_empty(&addr->sessions))
>>
>>
>> So when the number of sessions goes down to zero, it exits.
>Before it
>> would wait, in case a new session would come. Is this intended ?
>>
>> {
>> session_descriptor_t *p_session;
>> vlc_tick_t deadline = vlc_tick_now();
>> @@ -144,8 +142,8 @@ noreturn static void *RunThread (void
>*self)
>> }
>> }
>>
>> - vlc_cleanup_pop ();
>> - vlc_assert_unreachable ();
>> + vlc_mutex_unlock(&sap_mutex);
>> + return NULL;
>> }
>>
>> #undef sout_AnnounceRegisterSDP
>> @@ -372,17 +370,13 @@ void sout_AnnounceUnRegister
>(vlc_object_t
>> *obj, session_descriptor_t *session)
>> if (vlc_list_is_empty(&addr->sessions))
>> /* Last session for this address -> unlink the address */
>> vlc_list_remove(&addr->node);
>> - else
>> - {
>> - addr->session_count--;
>> - vlc_cond_signal (&addr->wait);
>> - }
>>
>> - vlc_mutex_unlock (&sap_mutex);
>> + addr->session_count--;
>> + vlc_cond_signal(&addr->wait);
>> + vlc_mutex_unlock(&sap_mutex);
>>
>> if (vlc_list_is_empty(&addr->sessions))
>> {
>> - vlc_cancel(addr->thread);
>> vlc_join(addr->thread, NULL);
>> AddressDestroy(addr);
>> }
>> --
>> 2.25.0
>>
>------------------------------------------------------------------------
>> vlc-devel mailing list
>> To unsubscribe or modify your subscription options:
>> https://mailman.videolan.org/listinfo/vlc-devel
>>
>>
>------------------------------------------------------------------------
>> vlc-devel mailing list
>> To unsubscribe or modify your subscription options:
>> https://mailman.videolan.org/listinfo/vlc-devel
>>
>>
>> --
>> Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez
>excuser
>> ma brièveté.
>>
>> _______________________________________________
>> vlc-devel mailing list
>> To unsubscribe or modify your subscription options:
>> https://mailman.videolan.org/listinfo/vlc-devel
>>
>_______________________________________________
>vlc-devel mailing list
>To unsubscribe or modify your subscription options:
>https://mailman.videolan.org/listinfo/vlc-devel
--
Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20200210/a0643e11/attachment-0001.html>
More information about the vlc-devel
mailing list