[vlc-devel] commit: Fix socket hang-up detection ( Rémi Denis-Courmont )

git version control git at videolan.org
Tue Dec 2 20:00:53 CET 2008


vlc | branch: master | Rémi Denis-Courmont <rdenis at simphalempin.com> | Tue Dec  2 21:00:39 2008 +0200| [0545e3f0b70ef2e9f8370a9cd01a08ab5b7c3f77] | committer: Rémi Denis-Courmont 

Fix socket hang-up detection

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=0545e3f0b70ef2e9f8370a9cd01a08ab5b7c3f77
---

 modules/access/rtp/input.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/modules/access/rtp/input.c b/modules/access/rtp/input.c
index 73b37b8..622e914 100644
--- a/modules/access/rtp/input.c
+++ b/modules/access/rtp/input.c
@@ -37,6 +37,12 @@
 #include "rtp.h"
 #include <srtp.h>
 
+static bool fd_dead (int fd)
+{
+    struct pollfd ufd = { .fd = fd, };
+    return (poll (&ufd, 1, 0) > 0) && (ufd.revents & POLLHUP);
+}
+
 /**
  * Gets a datagram from the network.
  * @param fd datagram file descriptor
@@ -54,8 +60,7 @@ static block_t *rtp_dgram_recv (vlc_object_t *obj, int fd)
                         block->p_buffer, block->i_buffer, false);
         vlc_cleanup_pop ();
 
-        if (((len <= 0) && poll (&(struct pollfd){ .fd = fd, }, 1, 0))
-         || !vlc_object_alive (obj))
+        if (((len <= 0) && fd_dead (fd)) || !vlc_object_alive (obj))
         {   /* POLLHUP -> permanent (DCCP) socket error */
             block_Release (block);
             return NULL;




More information about the vlc-devel mailing list