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

udp: avoid alloc/free on I/O error

parent 0fde3bea
...@@ -252,30 +252,27 @@ static void* ThreadRead( void *data ) ...@@ -252,30 +252,27 @@ static void* ThreadRead( void *data )
for( ;; ) for( ;; )
{ {
block_t *pkt; block_t *pkt = block_Alloc(MTU);
ssize_t len; if (unlikely(pkt == NULL))
block_FifoPace( sys->fifo, SIZE_MAX, sys->fifo_size );
pkt = block_Alloc( MTU );
if( unlikely( pkt == NULL ) )
break; break;
block_cleanup_push( pkt ); ssize_t len;
len = net_Read( access, sys->fd, NULL, pkt->p_buffer, MTU, false );
block_cleanup_push(pkt);
do
len = net_Read(access, sys->fd, NULL, pkt->p_buffer, MTU, false);
while (len == -1 && errno != EINTR);
vlc_cleanup_pop(); vlc_cleanup_pop();
if( len == -1 ) if (len == -1)
{ {
block_Release( pkt ); block_Release(pkt);
break;
if( errno == EINTR )
break;
continue;
} }
pkt->i_buffer = len; pkt->i_buffer = len;
block_FifoPut( sys->fifo, pkt ); block_FifoPace(sys->fifo, SIZE_MAX, sys->fifo_size - len);
block_FifoPut(sys->fifo, pkt);
} }
block_FifoWake( sys->fifo ); block_FifoWake( sys->fifo );
......
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