[vlc-devel] [PATCH 3/4] http: test: use interruptable accept()

Zhao Zhili quinkblack at foxmail.com
Wed Feb 3 18:17:10 UTC 2021



> On Feb 4, 2021, at 1:40 AM, Rémi Denis-Courmont <remi at remlab.net> wrote:
> 
> Le keskiviikkona 3. helmikuuta 2021, 19.04.25 EET Zhao Zhili a écrit :
>> From: Zhao Zhili <zhilizhao at tencent.com>
>> 
>> ---
>> modules/access/http/tunnel_test.c | 10 +++++-----
>> 1 file changed, 5 insertions(+), 5 deletions(-)
>> 
>> diff --git a/modules/access/http/tunnel_test.c
>> b/modules/access/http/tunnel_test.c index 223085714e..b53734346b 100644
>> --- a/modules/access/http/tunnel_test.c
>> +++ b/modules/access/http/tunnel_test.c
>> @@ -34,10 +34,6 @@
>> #ifdef HAVE_SYS_SOCKET_H
>> #include <sys/socket.h>
>> #endif
>> -#ifndef SOCK_CLOEXEC
>> -# define SOCK_CLOEXEC 0
>> -# define accept4(a,b,c,d) accept(a,b,c)
>> -#endif
>> #ifdef _WIN32
>> # include <winsock2.h>
>> #else
>> @@ -48,6 +44,7 @@
>> #endif
>> 
>> #include <vlc_common.h>
>> +#include <vlc_interrupt.h>
>> #include <vlc_tls.h>
>> #include "transport.h"
>> 
>> @@ -102,9 +99,12 @@ static void *proxy_thread(void *data)
>> 
>>     for (;;)
>>     {
>> -        int cfd = accept4(*lfd, NULL, NULL, SOCK_CLOEXEC);
>> +        int cfd = vlc_accept_i11e(*lfd, NULL, NULL, false);
>>         if (cfd == -1)
>> +        {
>> +            vlc_testcancel();
>>             continue;
>> +        }
>> 
>>         int canc = vlc_savecancel();
>>         proxy_client_process(cfd);
> 
> All this does is replace blocking accept4() with poll() then blocking 
> accept(). It hinges on working POSIX thread cancellation either way.

vlc_accept_i11e() -> vlc_poll_i11e() -> vlc_poll()

It's the vlc_poll() hack for Android which makes cancel work.

 142 static inline int vlc_poll (struct pollfd *fds, unsigned nfds, int timeout)
 143 {
 144     int val;
 145
 146     do
 147     {
 148         int ugly_timeout = ((unsigned)timeout >= 50) ? 50 : timeout;
 149         if (timeout >= 0)
 150             timeout -= ugly_timeout;
 151
 152         vlc_testcancel ();
 153         val = poll (fds, nfds, ugly_timeout);
 154     }
 155     while (val == 0 && timeout != 0);
 156
 157     return val;
 158 }

> 
> Using a VLC-interruptible function here does not seem to make much sense in 
> this context.
> 
> -- 
> 雷米‧德尼-库尔蒙
> http://www.remlab.net/
> 
> 
> 
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel



More information about the vlc-devel mailing list