[vlc-commits] RTP out: robustify send error handling
Rémi Denis-Courmont
git at videolan.org
Thu May 12 17:24:56 CEST 2011
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Thu May 12 18:23:20 2011 +0300| [dddfd15d0df73f7002c52eab79b020154ab1527f] | committer: Rémi Denis-Courmont
RTP out: robustify send error handling
For error other than congestion (EAGAIN, EWOULDBLOCK, ENOBUFS, ENOMEM),
check the socket type. If the socket is a datagram, retry. Otherwise,
the socket is connection-oriented and we assume the connection broke,
close it.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=dddfd15d0df73f7002c52eab79b020154ab1527f
---
modules/stream_out/rtp.c | 33 +++++++++++----------------------
1 files changed, 11 insertions(+), 22 deletions(-)
diff --git a/modules/stream_out/rtp.c b/modules/stream_out/rtp.c
index 8c21bad..2dbffd0 100644
--- a/modules/stream_out/rtp.c
+++ b/modules/stream_out/rtp.c
@@ -1425,31 +1425,20 @@ static void* ThreadSend( void *data )
#endif
SendRTCP( id->sinkv[i].rtcp, out );
- if( send( id->sinkv[i].rtp_fd, out->p_buffer, len, 0 ) >= 0 )
- continue;
- switch( net_errno )
+ if( send( id->sinkv[i].rtp_fd, out->p_buffer, len, 0 ) == -1
+ && net_errno != EAGAIN && net_errno != EWOULDBLOCK
+ && net_errno != ENOBUFS && net_errno != ENOMEM )
{
- /* Soft errors (e.g. ICMP): */
- case ECONNREFUSED: /* Port unreachable */
- case ENOPROTOOPT:
-#ifdef EPROTO
- case EPROTO: /* Protocol unreachable */
-#endif
- case EHOSTUNREACH: /* Host unreachable */
- case ENETUNREACH: /* Network unreachable */
- case ENETDOWN: /* Entire network down */
+ int type;
+ getsockopt( id->sinkv[i].rtp_fd, SOL_SOCKET, SO_TYPE,
+ &type, &(socklen_t){ sizeof(type) });
+ if( type == SOCK_DGRAM )
+ /* ICMP soft error: ignore and retry */
send( id->sinkv[i].rtp_fd, out->p_buffer, len, 0 );
- /* Transient congestion: */
- case ENOMEM: /* out of socket buffers */
- case ENOBUFS:
- case EAGAIN:
-#if (EAGAIN != EWOULDBLOCK)
- case EWOULDBLOCK:
-#endif
- continue;
+ else
+ /* Broken connection */
+ deadv[deadc++] = id->sinkv[i].rtp_fd;
}
-
- deadv[deadc++] = id->sinkv[i].rtp_fd;
}
id->i_seq_sent_next = ntohs(((uint16_t *) out->p_buffer)[1]) + 1;
vlc_mutex_unlock( &id->lock_sink );
More information about the vlc-commits
mailing list