Commit a3a6a95a authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

net_Read: remove no longer used waitall parameter

It was always either true or unused. Note that when the buffer length
is 1 byte, waitall had no effects.

net_Read() and net_Write() are now symmetric.
parent 5681eec0
......@@ -147,8 +147,8 @@ struct virtual_socket_t
int (*pf_send) ( void *, const void *, size_t );
};
VLC_API ssize_t net_Read( vlc_object_t *p_this, int fd, void *p_data, size_t i_data, bool b_retry );
#define net_Read(a,b,c,d,e) net_Read(VLC_OBJECT(a),b,c,d,e)
VLC_API ssize_t net_Read( vlc_object_t *p_this, int fd, void *p_data, size_t i_data );
#define net_Read(a,b,c,d) net_Read(VLC_OBJECT(a),b,c,d)
VLC_API ssize_t net_Write( vlc_object_t *p_this, int fd, const void *p_data, size_t i_data );
#define net_Write(a,b,c,d) net_Write(VLC_OBJECT(a),b,c,d)
VLC_API char * net_Gets( vlc_object_t *p_this, int fd );
......
......@@ -932,7 +932,7 @@ static int GetPacket( access_t * p_access, chunk_t *p_ck )
* (4 bytes), decode and then read up to 8 additional bytes to get the
* entire header.
*/
if( net_Read( p_access, p_sys->fd, p_sys->buffer, 4, true ) < 4 )
if( net_Read( p_access, p_sys->fd, p_sys->buffer, 4 ) < 4 )
{
msg_Err( p_access, "cannot read data 2" );
return VLC_EGENERIC;
......@@ -945,7 +945,7 @@ static int GetPacket( access_t * p_access, chunk_t *p_ck )
if( restsize > 8 )
restsize = 8;
if( net_Read( p_access, p_sys->fd, p_sys->buffer + 4, restsize, true ) < restsize )
if( net_Read( p_access, p_sys->fd, p_sys->buffer + 4, restsize ) < restsize )
{
msg_Err( p_access, "cannot read data 3" );
return VLC_EGENERIC;
......@@ -997,7 +997,7 @@ static int GetPacket( access_t * p_access, chunk_t *p_ck )
if( (p_ck->i_data > 0) &&
(net_Read( p_access, p_sys->fd, &p_sys->buffer[12],
p_ck->i_data, true ) < p_ck->i_data) )
p_ck->i_data ) < p_ck->i_data) )
{
msg_Err( p_access, "cannot read data 4" );
return VLC_EGENERIC;
......
......@@ -106,7 +106,7 @@ static int RtspRead( void *p_userdata, uint8_t *p_buffer, int i_buffer )
access_t *p_access = (access_t *)p_userdata;
access_sys_t *p_sys = p_access->p_sys;
return net_Read( p_access, p_sys->fd, p_buffer, i_buffer, true );
return net_Read( p_access, p_sys->fd, p_buffer, i_buffer );
}
static int RtspReadLine( void *p_userdata, uint8_t *p_buffer, int i_buffer )
......
......@@ -1864,7 +1864,6 @@ bool ReadCommand( intf_thread_t *p_intf, char *p_buffer, int *pi_size )
}
#endif
while( *pi_size < MAX_LINE_LENGTH )
{
if( p_intf->p_sys->i_socket == -1 )
......@@ -1880,7 +1879,7 @@ bool ReadCommand( intf_thread_t *p_intf, char *p_buffer, int *pi_size )
else
{ /* Connection closed */
if( net_Read( p_intf, p_intf->p_sys->i_socket, p_buffer + *pi_size,
1, false ) <= 0 )
1 ) <= 0 )
{
net_Close( p_intf->p_sys->i_socket );
p_intf->p_sys->i_socket = -1;
......
......@@ -63,7 +63,7 @@ ssize_t Socket::read(vlc_object_t *stream, void *p_buffer, size_t len)
ssize_t size;
do
{
size = net_Read(stream, netfd, p_buffer, len, true);
size = net_Read(stream, netfd, p_buffer, len);
} while (size < 0 && (errno == EINTR || errno==EAGAIN) );
return size;
}
......
......@@ -383,7 +383,7 @@ static bool read_exact( filter_t *p_filter,
char* p_readbuf,
int i_bytes )
{
return i_bytes == net_Read( p_filter, i_socket, p_readbuf, i_bytes, true );
return i_bytes == net_Read( p_filter, i_socket, p_readbuf, i_bytes );
}
......
......@@ -248,18 +248,15 @@ int *net_Listen (vlc_object_t *p_this, const char *psz_host,
return sockv;
}
#undef net_Read
/*****************************************************************************
* net_Read:
*****************************************************************************
* Reads from a network socket. Cancellation point.
* If waitall is true, then we repeat until we have read the right amount of
* data; in that case, a short count means EOF has been reached or the VLC
* object has been signaled.
* We repeat until we have read the right amount of data;
* a short count means EOF has been reached or an error.
*****************************************************************************/
ssize_t
net_Read (vlc_object_t *restrict p_this, int fd,
void *restrict p_buf, size_t i_buflen, bool waitall)
ssize_t (net_Read)(vlc_object_t *restrict p_this, int fd,
void *restrict p_buf, size_t i_buflen)
{
struct pollfd ufd[2];
......@@ -304,7 +301,7 @@ net_Read (vlc_object_t *restrict p_this, int fd,
p_buf = (char *)p_buf + n;
i_buflen -= n;
if (!waitall || i_buflen == 0)
if (i_buflen == 0)
break;
}
else /* n == 0 */
......@@ -449,7 +446,7 @@ char *net_Gets(vlc_object_t *obj, int fd)
bufsize += 1024;
}
ssize_t val = net_Read(obj, fd, buf + buflen, 1, false);
ssize_t val = net_Read(obj, fd, buf + buflen, 1);
if (val < 1)
goto error;
......
......@@ -347,7 +347,7 @@ static int SocksNegotiate( vlc_object_t *p_obj,
if( net_Write( p_obj, fd, buffer, i_len ) != i_len )
return VLC_EGENERIC;
if( net_Read( p_obj, fd, buffer, 2, true ) != 2 )
if( net_Read( p_obj, fd, buffer, 2) != 2 )
return VLC_EGENERIC;
msg_Dbg( p_obj, "socks: v=%d method=%x", buffer[0], buffer[1] );
......@@ -374,7 +374,7 @@ static int SocksNegotiate( vlc_object_t *p_obj,
if( net_Write( p_obj, fd, buffer, i_len ) != i_len )
return VLC_EGENERIC;
if( net_Read( p_obj, fd, buffer, 2, true ) != 2 )
if( net_Read( p_obj, fd, buffer, 2 ) != 2 )
return VLC_EGENERIC;
msg_Dbg( p_obj, "socks: v=%d status=%x", buffer[0], buffer[1] );
......@@ -446,7 +446,7 @@ static int SocksHandshakeTCP( vlc_object_t *p_obj,
if( net_Write( p_obj, fd, buffer, 9 ) != 9 )
return VLC_EGENERIC;
if( net_Read( p_obj, fd, buffer, 8, true ) != 8 )
if( net_Read( p_obj, fd, buffer, 8 ) != 8 )
return VLC_EGENERIC;
msg_Dbg( p_obj, "socks: v=%d cd=%d",
......@@ -476,7 +476,7 @@ static int SocksHandshakeTCP( vlc_object_t *p_obj,
return VLC_EGENERIC;
/* Read the header */
if( net_Read( p_obj, fd, buffer, 5, true ) != 5 )
if( net_Read( p_obj, fd, buffer, 5 ) != 5 )
return VLC_EGENERIC;
msg_Dbg( p_obj, "socks: v=%d rep=%d atyp=%d",
......@@ -498,7 +498,7 @@ static int SocksHandshakeTCP( vlc_object_t *p_obj,
else
return VLC_EGENERIC;
if( net_Read( p_obj, fd, buffer, i_len, true ) != i_len )
if( net_Read( p_obj, fd, buffer, i_len ) != i_len )
return VLC_EGENERIC;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment