GNOME Bugzilla – Bug 688852
udpsrc recvfrom() block fix
Last modified: 2013-08-14 11:11:01 UTC
gst/udp/gstudpsrc.c, near line 495: /* If we get here and the readsize is zero, then either select was woken up * by activity that is not a read, or a poll error occurred, or a UDP packet * was received that has no data. Since we cannot identify which case it is, * we handle all of them. This could possibly lead to a UDP packet getting * lost, but since UDP is not reliable, we can accept this. */ if (G_UNLIKELY (!readsize)) { /* try to read a packet (and it will be ignored), * in case a packet with no data arrived */ slen = sizeof (sa); recvfrom (udpsrc->sock.fd, (char *) &slen, 0, 0, &sa.sa, &slen); /* clear any error, in case a poll error occurred */ clear_error (udpsrc); /* poll again */ goto retry; } If a poll error occurs (for example, connection is lost), recvfrom() sometimes blocks on recvfrom() forever. Since LIVE_LOCK() is previously taken, any attempt to set udpsrc state from PLAYING to PAUSED hangs on LIVE_LOCK() then. This prevents from successful destroying of udpsrc when the other end dies at the same time (this deadlock floats, sometimes it happens and sometimes everything's OK). I suggest to add MSG_DONTWAIT to flags, so that in case of errors that would block recvfrom(), it goes on without blocking: recvfrom (udpsrc->sock.fd, (char *) &slen, 0, MSG_DONTWAIT, &sa.sa, &slen)
This has been rewritten in 1.0. I would like to mark this obsolete, there is not going to be any 0.10 release anymore.
Please note that in 1.0 this part was rewritten using g_socket_receive_from() with GCancellable, hope it is fixed now.
It would be great if you could check that and confirm it. I don't see MSG_DONTWAIT in the g_socket_receive_message() code, nor am I sure the socket is made non-blocking anywhere.
Tim, you mean confirm for 1.0 or for 0.10 ? If it's for 0.10, let's just close this.
He is talking about GIO, so 1.0. But let's close it as no feedback was provided in a long time and in theory GSocket should do things properly in that regard.
Sorry guys, I am no longer working on the related project. Looks like it is better to leave this closed.