<html><head></head><body>Hi,<br><br>The _endthreadex() is called indirectly by returning from vlc_entry(). The patch makes it called explicitly but it does bot change the semantics as such. I can add a note though.<br><br><div class="gmail_quote">Le 7 septembre 2020 08:45:34 GMT+03: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">I think the title is misleading. It's not just code factoring. A regular <br>thread not calling test_cancel() will now call ExitThread. It's probably <br>right, but it has some side effects that should be mentioned:<br><br>"When this function is called (either explicitly or by returning from a <br>thread procedure), the current thread's stack is deallocated, all <br>pending I/O initiated by the thread is canceled, and the thread <br>terminates. The entry-point function of all attached dynamic-link <br>libraries (DLLs) is invoked with a value indicating that the thread is <br>detaching from the DLL."<br><br>On 2020-09-06 19:12, 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;"><hr>  src/win32/thread.c | 27 ++++++++++++++++-----------<br>  1 file changed, 16 insertions(+), 11 deletions(-)<br><br>diff --git a/src/win32/thread.c b/src/win32/thread.c<br>index 255946913c..cd15828128 100644<br>--- a/src/win32/thread.c<br>+++ b/src/win32/thread.c<br>@@ -35,6 +35,7 @@<br>  #include "libvlc.h"<br>  #include <stdarg.h><br>  #include <stdatomic.h><br>+#include <stdnoreturn.h><br>  #include <assert.h><br>  #include <limits.h><br>  #include <errno.h><br>@@ -345,6 +346,18 @@ static void vlc_thread_destroy(vlc_thread_t th)<br>      free(th);<br>  }<br>  <br>+static noreturn void vlc_thread_exit(vlc_thread_t self)<br>+{<br>+    if (self->id == NULL) /* Detached thread */<br>+        vlc_thread_destroy(self);<br>+<br>+#if VLC_WINSTORE_APP<br>+    ExitThread(0);<br>+#else // !VLC_WINSTORE_APP<br>+    _endthreadex(0);<br>+#endif // !VLC_WINSTORE_APP<br>+}<br>+<br>  static<br>  #if VLC_WINSTORE_APP<br>  DWORD<br>@@ -359,10 +372,7 @@ __stdcall vlc_entry (void *p)<br>      th->killable = true;<br>      th->data = th->entry (th->data);<br>      TlsSetValue(thread_key, NULL);<br>-<br>-    if (th->id == NULL) /* Detached thread */<br>-        vlc_thread_destroy(th);<br>-    return 0;<br>+    vlc_thread_exit(th);<br>  }<br>  <br>  static int vlc_clone_attr (vlc_thread_t *p_handle, bool detached,<br>@@ -524,13 +534,8 @@ void vlc_testcancel (void)<br>          p->proc (p->data);<br>  <br>      th->data = NULL; /* TODO: special value? */<br>-    if (th->id == NULL) /* Detached thread */<br>-        vlc_thread_destroy(th);<br>-#if VLC_WINSTORE_APP<br>-    ExitThread(0);<br>-#else // !VLC_WINSTORE_APP<br>-    _endthreadex(0);<br>-#endif // !VLC_WINSTORE_APP<br>+<br>+    vlc_thread_exit(th);<br>  }<br>  <br>  void vlc_control_cancel (vlc_cleanup_t *cleaner)<br>-- <br>2.28.0<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>