shmsrc: client main socket should be non-blocking
Submitted by Aleix Conchillo Flaqué
Link to original bug (#797258)
Description
While testing bug 797203, I have found that client socket is opened without O_NONBLOCK. This might cause some race condition. See the blocking in the send system call below:
Thread 5 (Thread 0x7feb37fff700 (LWP 22116)):
#0 0x00007feb431b19ff in __libc_send (fd=16, buf=buf@entry=0x7feb37ffea70, n=n@entry=24, flags=flags@entry=16384) at ../sysdeps/unix/sysv/linux/x86_64/send.c:26
#1 0x00007feb4195d112 in send_command (area_id=<optimized out>, type=4, cb=0x7feb37ffea70, fd=<optimized out>) at shmpipe.c:481
#2 sp_client_recv_finish (self=0x2622370, buf=<optimized out>) at shmpipe.c:767
#3 0x00007feb4195e6b1 in free_buffer (data=0x2616a10) at gstshmsrc.c:313
#4 0x00007feb4397da39 in default_free (allocator=<optimized out>, mem=0x7feb30006d10) at gstallocator.c:527
#5 0x00007feb439be788 in _gst_memory_free (mem=0x7feb30006d10) at gstmemory.c:97
#6 0x00007feb439885da in gst_memory_unref (memory=<optimized out>) at ../gst/gstmemory.h:345
#7 _gst_buffer_free (buffer=0x7feb30004e30) at gstbuffer.c:749
#8 0x00007feb41b9ed6a in gst_base_sink_chain_unlocked (basesink=basesink@entry=0x2628de0, obj=obj@entry=0x7feb30004e30, is_list=is_list@entry=0, pad=<optimized out>) at gstbasesink.c:3655
#9 0x00007feb41ba025c in gst_base_sink_chain_main (is_list=0, obj=0x7feb30004e30, pad=<optimized out>, basesink=0x2628de0) at gstbasesink.c:3672
#10 gst_base_sink_chain (pad=<optimized out>, parent=0x2628de0, buf=0x7feb30004e30) at gstbasesink.c:3701
#11 0x00007feb439c610b in gst_pad_chain_data_unchecked (data=<optimized out>, type=4112, pad=0x261c790) at gstpad.c:4322
#12 gst_pad_push_data (pad=pad@entry=0x261c540, type=type@entry=4112, data=<optimized out>, data@entry=0x7feb30004e30) at gstpad.c:4578
#13 0x00007feb439cdbb3 in gst_pad_push (pad=pad@entry=0x261c540, buffer=0x7feb30004e30) at gstpad.c:4697
#14 0x00007feb41ba498d in gst_base_src_loop (pad=0x261c540) at gstbasesrc.c:2957
#15 0x00007feb43a005b1 in gst_task_func (task=0x2623170) at gsttask.c:332
#16 0x00007feb4344a1dc in g_thread_pool_thread_proxy (data=<optimized out>) at gthreadpool.c:307
#17 0x00007feb43449ac5 in g_thread_proxy (data=0x2622230) at gthread.c:784
#18 0x00007feb431a86ba in start_thread (arg=0x7feb37fff700) at pthread_create.c:333
#19 0x00007feb42ede41d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109
Thread 4 (Thread 0x7feb3c956700 (LWP 22115)):
#0 syscall () at ../sysdeps/unix/sysv/linux/x86_64/syscall.S:38
#1 0x00007feb4346cfca in g_cond_wait_until (cond=cond@entry=0x2443148, mutex=mutex@entry=0x2443140, end_time=end_time@entry=4152625229152) at gthread-posix.c:1449
#2 0x00007feb433df40b in g_async_queue_pop_intern_unlocked (end_time=4152625229152, wait=1, queue=0x2443140) at gasyncqueue.c:422
#3 g_async_queue_timeout_pop (queue=0x2443140, timeout=timeout@entry=15000000) at gasyncqueue.c:545
#4 0x00007feb4344a2ba in g_thread_pool_wait_for_new_pool () at gthreadpool.c:167
#5 g_thread_pool_thread_proxy (data=<optimized out>) at gthreadpool.c:364
#6 0x00007feb43449ac5 in g_thread_proxy (data=0x2622630) at gthread.c:784
#7 0x00007feb431a86ba in start_thread (arg=0x7feb3c956700) at pthread_create.c:333
#8 0x00007feb42ede41d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109
Thread 3 (Thread 0x7feb3d157700 (LWP 22114)):
#0 0x00007feb431b19ff in __libc_send (fd=17, buf=buf@entry=0x7feb3d156a00, n=n@entry=24, flags=flags@entry=16384) at ../sysdeps/unix/sysv/linux/x86_64/send.c:26
#1 0x00007feb4195ccb0 in send_command (area_id=<optimized out>, type=3, cb=0x7feb3d156a00, fd=<optimized out>) at shmpipe.c:481
#2 sp_writer_send_buf (self=0x2506630, buf=<optimized out>, size=4096, tag=tag@entry=0x7feb30028180) at shmpipe.c:620
#3 0x00007feb4195f798 in gst_shm_sink_render (bsink=0x261f410, buf=0x7feb3006b0d0) at gstshmsink.c:785
#4 0x00007feb41b9ec23 in gst_base_sink_chain_unlocked (basesink=basesink@entry=0x261f410, obj=obj@entry=0x7feb3006b0d0, is_list=is_list@entry=0, pad=<optimized out>) at gstbasesink.c:3546
#5 0x00007feb41ba025c in gst_base_sink_chain_main (is_list=0, obj=0x7feb3006b0d0, pad=<optimized out>, basesink=0x261f410) at gstbasesink.c:3672
#6 gst_base_sink_chain (pad=<optimized out>, parent=0x261f410, buf=0x7feb3006b0d0) at gstbasesink.c:3701
#7 0x00007feb439c610b in gst_pad_chain_data_unchecked (data=<optimized out>, type=4112, pad=0x261c2f0) at gstpad.c:4322
#8 gst_pad_push_data (pad=pad@entry=0x261c0a0, type=type@entry=4112, data=<optimized out>, data@entry=0x7feb3006b0d0) at gstpad.c:4578
#9 0x00007feb439cdbb3 in gst_pad_push (pad=pad@entry=0x261c0a0, buffer=0x7feb3006b0d0) at gstpad.c:4697
#10 0x00007feb41ba498d in gst_base_src_loop (pad=0x261c0a0) at gstbasesrc.c:2957
#11 0x00007feb43a005b1 in gst_task_func (task=0x2623050) at gsttask.c:332
#12 0x00007feb4344a1dc in g_thread_pool_thread_proxy (data=<optimized out>) at gthreadpool.c:307
#13 0x00007feb43449ac5 in g_thread_proxy (data=0x2506720) at gthread.c:784
#14 0x00007feb431a86ba in start_thread (arg=0x7feb3d157700) at pthread_create.c:333
#15 0x00007feb42ede41d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109
Version: 1.14.x