gst-zeromq icon indicating copy to clipboard operation
gst-zeromq copied to clipboard

Trying to stop the pipeline whilst the src is awaiting data results in a hang

Open mangodan2003 opened this issue 2 years ago • 2 comments

Blocked by

https://github.com/mjhowell/gst-zeromq/blob/master/src/zeromq/gstzmqsrc.c#L187

mangodan2003 avatar Nov 18 '22 11:11 mangodan2003

Hi @mangodan2003, I haven't touched this in a long time so it is not fresh in my mind. The code you highlight doesn't seem to have a nice way to be interrupted, so perhaps would be better calling zmq_msg_recv() with a timeout, or using zmq_poll().

Can you give a concrete example that I can use to reproduce your problem? gst-launch-1.0 command lines, etc.

mjhowell avatar Nov 18 '22 23:11 mjhowell

A simple gst-launch like this will suffice:

gst-launch-1.0 -v zmqsrc endpoint=ipc:///tmp/bla-src ! fakesink dump=1

Compare the behavior when pressing Ctrl+C with udpsrc for example. udpsrc is immediate, zmqsrc takes a very long time.

Something along these lines does better in that test case but unfortunately not in a less artificial scenario.

-    rc = zmq_msg_recv (&msg, src->socket, 0);
+    rc = zmq_msg_recv (&msg, src->socket, ZMQ_DONTWAIT);
     if ((rc < 0) && (EAGAIN == errno)) {
       GST_LOG_OBJECT (src, "No message available on socket, errno: %d", errno);
+      g_main_context_iteration (NULL, FALSE);
+      g_usleep (1000);  // sleep for 1 millisecond
       continue;

Frenzie avatar May 23 '24 15:05 Frenzie