<html><head></head><body>No. The mutex is there to guarantee the uniqueness of listed instance per display and serialise memory use.<br><br><div class="gmail_quote">Le 28 novembre 2019 12:13:09 GMT+02:00, Steve Lhomme <robux4@ycbcr.xyz> a écrit :<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<pre class="k9mail">Isn't the mutex there to protect using the same resource multiple times <br>? So I don't see why it doesn't actually protect the resource creation <br>itself. In the current code the same resource is created twice and <br>destroyed if created twice (with what side effects ?).<br><br>On 2019-11-27 16:57, Rémi Denis-Courmont wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #729fcf; padding-left: 1ex;">Reentrancy is the reason IIRC.<br><br>Le 27 novembre 2019 13:48:14 GMT+02:00, Steve Lhomme <robux4@ycbcr.xyz> <br>a écrit :<br><br>    There's no reason to unlock before creating more than 1 instance and then<br>    destroying the extra ones. No matter what we'll still return only after<br>    an instance has been created (or failed to be created). Concurrent calls<br>    for the same display name will only create one instance.<hr>      modules/hw/vdpau/instance.c | 21 ++++++---------------<br>      1 file changed, 6 insertions(+), 15 deletions(-)<br><br>    diff --git a/modules/hw/vdpau/instance.c b/modules/hw/vdpau/instance.c<br>    index 4a6d27fe5f0..862e63e0e21 100644<br>    --- a/modules/hw/vdpau/instance.c<br>    +++ b/modules/hw/vdpau/instance.c<br>    @@ -129,7 +129,7 @@ static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;<br>      VdpStatus vdp_get_x11(const char *display_name, int snum,<br>                            vdp_t **restrict vdpp, VdpDevice *restrict devicep)<br>      {<br>    -    vdp_instance_t *vi, *vi2;<br>    +    vdp_instance_t *vi;<br>      <br>          if (display_name == NULL)<br>          {<br>    @@ -140,29 +140,20 @@ VdpStatus vdp_get_x11(const char *display_name, int snum,<br>      <br>          pthread_mutex_lock(&lock);<br>          vi = vdp_instance_lookup(display_name, snum);<br>    -    pthread_mutex_unlock(&lock);<br>          if (vi != NULL)<br>              goto found;<br>      <br>          vi = vdp_instance_create(display_name, snum);<br>          if (vi == NULL)<br>    -        return VDP_STATUS_ERROR;<br>    -<br>    -    pthread_mutex_lock(&lock);<br>    -    vi2 = vdp_instance_lookup(display_name, snum);<br>    -    if (unlikely(vi2 != NULL))<br>    -    {   /* Another thread created the instance (race condition corner case) */<br>    -        pthread_mutex_unlock(&lock);<br>    -        vdp_instance_destroy(vi);<br>    -        vi = vi2;<br>    -    }<br>    -    else<br>          {<br>    -        vi->next = list;<br>    -        list = vi;<br>              pthread_mutex_unlock(&lock);<br>    +        return VDP_STATUS_ERROR;<br>          }<br>    +<br>    +    vi->next = list;<br>    +    list = vi;<br>      found:<br>    +    pthread_mutex_unlock(&lock);<br>          *vdpp = vi->vdp;<br>          *devicep = vi->device;<br>          return VDP_STATUS_OK;<br><br><br>-- <br>Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser <br>ma brièveté.<hr>vlc-devel mailing list<br>To unsubscribe or modify your subscription options:<br><a href="https://mailman.videolan.org/listinfo/vlc-devel">https://mailman.videolan.org/listinfo/vlc-devel</a><br><br></blockquote><hr>vlc-devel mailing list<br>To unsubscribe or modify your subscription options:<br><a href="https://mailman.videolan.org/listinfo/vlc-devel">https://mailman.videolan.org/listinfo/vlc-devel</a></pre></blockquote></div><br>-- <br>Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.</body></html>