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

Fix socket hang-up detection

parent 3df9e798
...@@ -37,6 +37,12 @@ ...@@ -37,6 +37,12 @@
#include "rtp.h" #include "rtp.h"
#include <srtp.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. * Gets a datagram from the network.
* @param fd datagram file descriptor * @param fd datagram file descriptor
...@@ -54,8 +60,7 @@ static block_t *rtp_dgram_recv (vlc_object_t *obj, int fd) ...@@ -54,8 +60,7 @@ static block_t *rtp_dgram_recv (vlc_object_t *obj, int fd)
block->p_buffer, block->i_buffer, false); block->p_buffer, block->i_buffer, false);
vlc_cleanup_pop (); vlc_cleanup_pop ();
if (((len <= 0) && poll (&(struct pollfd){ .fd = fd, }, 1, 0)) if (((len <= 0) && fd_dead (fd)) || !vlc_object_alive (obj))
|| !vlc_object_alive (obj))
{ /* POLLHUP -> permanent (DCCP) socket error */ { /* POLLHUP -> permanent (DCCP) socket error */
block_Release (block); block_Release (block);
return NULL; return NULL;
......
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