[vlc-devel] win32: do not get stuck in poll() with infinite timeout

KO Myung-Hun komh78 at gmail.com
Tue Feb 5 03:36:47 CET 2013


Hi/2.

Rémi Denis-Courmont wrote:
> vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon Feb  4 19:14:33 2013 +0200| [576c05f07f93e47c543c1e1d4946269394d3899b] | committer: Rémi Denis-Courmont
> 
> win32: do not get stuck in poll() with infinite timeout
> 
> This really should be fixed more properly.
> 
>> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=576c05f07f93e47c543c1e1d4946269394d3899b
> ---
> 
>  include/vlc_threads.h |   18 +++++++++++-------
>  1 file changed, 11 insertions(+), 7 deletions(-)
> 
> diff --git a/include/vlc_threads.h b/include/vlc_threads.h
> index 337ded4..1197b55 100644
> --- a/include/vlc_threads.h
> +++ b/include/vlc_threads.h
> @@ -388,18 +388,22 @@ struct vlc_cleanup_t
>  /* poll() with cancellation */
>  static inline int vlc_poll (struct pollfd *fds, unsigned nfds, int timeout)
>  {
> -    vlc_testcancel ();
> +    int val;
>  
> -    while (timeout > 50)
> +    do
>      {
> -        int val = poll (fds, nfds, 50);
> -        if (val != 0)
> -            return val;
> -        timeout -= 50;
> +        int ugly_timeout = 50;
> +        if (timeout >= 50)
> +            timeout -= 50;
> +        else if ((unsigned)timeout < 50u)
> +            ugly_timeout = timeout;
> +
>          vlc_testcancel ();
> +        val = poll (fds, nfds, ugly_timeout);
>      }
> +    while (val == 0 && timeout != 0);
>  
> -    return poll (fds, nfds, timeout);
> +    return val;
>  }
>  # define poll(u,n,t) vlc_poll(u, n, t)
>  
> 

This falls into a infinite loop if timeout is between 0 and 50 exclusive
even if poll() timed out.

-- 
KO Myung-Hun

Using Mozilla SeaMonkey 2.7.2
Under OS/2 Warp 4 for Korean with FixPak #15
In VirtualBox v4.1.22 on Intel Core i7-3615QM 2.30GHz with 8GB RAM

Korean OS/2 User Community : http://www.ecomstation.co.kr




More information about the vlc-devel mailing list