[vlc-devel] Re: timeout on input (select(), read(), poll() timeout?)
Georgi Chorbadzhiyski
gf at unixsol.org
Thu Oct 26 20:00:53 CEST 2006
Rémi Denis-Courmont wrote:
> Le mardi 24 octobre 2006 22:54, Georgi Chorbadzhiyski a écrit :
>> > The problem is that when network connectivity dies, the connection
>> > is not timing out and VLC is not trying to reconnect. It just sits
>> > there awaiting frames.
>> >
>> > This option is not working for me.
>> >
>> > --ipv4-timeout <integer> TCP connection timeout
>> > Default TCP connection timeout (in
>> > milliseconds).
>
> I think that's the timeout for the three-way handshaked, not for the
> established connections. In factn the name is very unfortunate, since
> it's not IPv4-specific, but TCP-specific.
>
>> I've tried to find how to set timeout for select and/or socket read
>> functions. I see that parameter exists but I can't find where the
>> functions are called and if timeout parameter is exposed as command
>> line option somewhere.
>
> net_ReadNonBlock (and net_Select, but I dislike it) have a timeout
> parameter that is set by the calling plugin, at its discretion.
Yes, I've found the code. The problem is that net_Read is used in net_Gets
and net_Gets is used in number of places, see:
modules/access/mms/mmsh.c:412: if( ( psz = net_Gets( VLC_OBJECT(p_access), p_sys->fd, NULL ) ) == NULL )
modules/access/mms/mmsh.c:435: char *psz = net_Gets( p_access, p_sys->fd, NULL );
modules/access/mms/mmsh.c:645: if( ( psz = net_Gets( VLC_OBJECT(p_access), p_sys->fd, NULL ) ) == NULL )
modules/access/mms/mmsh.c:662: char *psz = net_Gets( p_access, p_sys->fd, NULL );
modules/access/rtsp/access.c:123: char *psz = net_Gets( VLC_OBJECT(p_access), p_sys->fd, 0 );
modules/access/ftp.c:617: psz_line = net_Gets( p_access, p_sys->fd_cmd, NULL );
modules/access/ftp.c:637: char *psz_tmp = net_Gets( p_access, p_sys->fd_cmd, NULL );
modules/access/http.c:484: char *psz = net_Gets( VLC_OBJECT(p_access), p_sys->fd, p_sys->p_vs );
modules/access/http.c:551: char *psz = net_Gets( VLC_OBJECT(p_access), p_sys->fd, p_sys->p_vs );
modules/access/http.c:818: psz = net_Gets( VLC_OBJECT(p_access), p_sys->fd, NULL );
modules/access/http.c:838: psz = net_Gets( VLC_OBJECT(p_access), p_sys->fd, NULL );
modules/access/http.c:981: if( ( psz = net_Gets( VLC_OBJECT(p_access), p_sys->fd, pvs ) ) == NULL )
modules/access/http.c:1029: char *psz = net_Gets( VLC_OBJECT(p_access), p_sys->fd, pvs );
It seems that every usage of net_Read (and net_Gets FWIW) is error probably
leading to vlc hanging out and waiting forever for input if network connectivity
is lost.
Proposed ugly patch /15 seconds of course should not be hard coded but it is
reasonable default/.
--- io.c 2006-10-26 20:54:07.000000000 +0300
+++ io-patch.c 2006-10-26 20:54:35.000000000 +0300
@@ -421,7 +421,7 @@ char *__net_Gets( vlc_object_t *p_this,
ptr = psz_line + i_line;
}
- if( net_Read( p_this, fd, p_vs, (uint8_t *)ptr, 1, VLC_TRUE ) != 1 )
+ if( net_ReadNonBlock( p_this, fd, p_vs, (uint8_t *)ptr, 1, 15 * 1000 ) != 1 )
{
if( i_line == 0 )
{
May be these uses of net_Read should also be converted to net_ReadNonBlock.
modules/access/mms/mmsh.c:715: if( net_Read( p_access, p_sys->fd, NULL, p_sys->buffer, 4, VLC_TRUE ) < 4 )
modules/access/mms/mmsh.c:727: if( net_Read( p_access, p_sys->fd, NULL, p_sys->buffer + 4, restsize, VLC_TRUE ) < restsize )
modules/access/mms/mmsh.c:770: (net_Read( p_access, p_sys->fd, NULL, &p_sys->buffer[12],
modules/access/rtsp/access.c:115: return net_Read( p_access, p_sys->fd, 0, p_buffer, i_buffer, VLC_TRUE );
modules/access/ftp.c:478: i_read = net_Read( p_access, p_sys->fd_data, NULL, p_buffer, i_len,
modules/access/tcp.c:144: i_read = net_Read( p_access, p_sys->fd, NULL, p_buffer, i_len,
modules/access/udp.c:299: p_block->i_buffer = net_Read( p_access, p_sys->fd, NULL,
modules/access/http.c:539: i_read = net_Read( p_access, p_sys->fd, p_sys->p_vs, p_buffer, i_len, VLC_FALSE );
modules/access/http.c:607: i_read = net_Read( p_access, p_sys->fd, p_sys->p_vs, &buffer, 1,
modules/access/http.c:618: if( net_Read( p_access, p_sys->fd, p_sys->p_vs,
src/network/tcp.c:482: if( net_Read( p_obj, fd, NULL, buffer, 2, VLC_TRUE ) != 2 )
src/network/tcp.c:509: if( net_Read( p_obj, fd, NULL, buffer, 2, VLC_TRUE ) != 2 )
src/network/tcp.c:577: if( net_Read( p_obj, fd, NULL, buffer, 8, VLC_TRUE ) != 8 )
src/network/tcp.c:607: if( net_Read( p_obj, fd, NULL, buffer, 5, VLC_TRUE ) != 5 )
src/network/tcp.c:629: if( net_Read( p_obj, fd, NULL, buffer, i_len, VLC_TRUE ) != i_len )
--
Georgi Chorbadzhiyski
http://georgi.unixsol.org/
--
This is the vlc-devel mailing-list, see http://www.videolan.org/vlc/
To unsubscribe, please read http://developers.videolan.org/lists.html
More information about the vlc-devel
mailing list