[FFmpeg-devel] Network IO in FFmpeg (was: abstractable threading api)

LANGLOIS Olivier PIS -EXT olivier.pis.langlois at transport.alstom.com
Tue Apr 8 20:49:38 CEST 2014


> This thread has caught my attention and I went to see how
> pthread_cancel() was used in libavformat/udp.c and I might have spotted a
> race condition in it.
>
> cancellation points are implemented inside glibc not in the kernel. That
> means that once the cancellation point check is done and the thread is
> blocked inside the kernel, cancelling the thread will have no effect.
>
> In order to have the code behave as designed,
>
> pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
>
> should be used. asynchronous cancels are implemented with RT signals.
> For that reason only async cancels can interrupt and cancel a thread that is
> already inside a system call.

My mistake. Ignore this whole post. Half of it is true. The other half is that inside cancellation point functions, async cancel type if flipped on/off around the syscall. ie:

      int oldstate = LIBC_CANCEL_ASYNC ();

      r = INTERNAL_SYSCALL (clock_nanosleep, err, 4, clock_id, flags, req,
                            rem);

      LIBC_CANCEL_RESET (oldstate);


________________________________
CONFIDENTIALITY : This e-mail and any attachments are confidential and may be privileged. If you are not a named recipient, please notify the sender immediately and do not disclose the contents to another person, use it for any purpose or store or copy the information in any medium.


More information about the ffmpeg-devel mailing list