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

Rémi Denis-Courmont remi at remlab.net
Wed Feb 3 17:40:57 UTC 2021


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.

Using a VLC-interruptible function here does not seem to make much sense in 
this context.

-- 
雷米‧德尼-库尔蒙
http://www.remlab.net/





More information about the vlc-devel mailing list