From 32ae444268b7666df7df6214e38dc98a1196fc8a Mon Sep 17 00:00:00 2001 From: Lars The Date: Wed, 2 Dec 2020 15:18:39 +0100 Subject: [PATCH] Fix write_data() when size 0 When working with RTP packets, if you receive a new network packet without payload then the relay loop is exited. This is not a good behaviour, as you can receive such packets at any time. Thus this patch fixes this permiting the write of 0 bytes inside the function. No side effects are detected, so the patch looks good. --- chipmunk/dpkt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/chipmunk/dpkt.c b/chipmunk/dpkt.c index 58f95e0..90bd953 100644 --- a/chipmunk/dpkt.c +++ b/chipmunk/dpkt.c @@ -743,7 +743,7 @@ write_data( const struct dstream_ctx* spc, if( spc->flags & F_SCATTERED ) { n_count = spc->pkt_count; n = writev( fd, spc->pkt, n_count ); - if( n <= 0 ) { + if( n < 0 ) { if( EAGAIN == errno ) { (void)tmfprintf( g_flog, "Write on fd=[%d] timed out\n", fd); error = IO_BLK; @@ -758,7 +758,7 @@ write_data( const struct dstream_ctx* spc, error = n; } - return (n > 0) ? n : error; + return (n >= 0) ? n : error; }