GNOME Bugzilla – Bug 705308
Changing the fd property of fdsink is not threadsafe
Last modified: 2013-08-07 15:47:44 UTC
Created attachment 250648 [details] [review] Patch - fdsink: Make changing fd property on fdsink thread-safe Changing the fd property of fdsink is not threadsafe. This means that you cannot change the fd from any thread apart from the stream thread if the stream is currently running. I've attached a patch that adds the guarantee that when `g_object_set("fd", x, NULL)` returns the old fd will no longer be in use and may be closed, etc. Because a lock is being held across a call to `write` this patch may cause setting the fd to block for longer than previously unless the fd was opened with O_NONBLOCK. This applies to all fds on windows as I guess it doesn't have an implementation of g_poll. This doesn't seem so bad as due to the previous lack of synchronisation aroud `fd` these programs would have been relying on undefined behaviour anyway but it doesn't make me entirely happy. I'll see if I can also come up with a test that exacerbates this issue.
This is not really a supported use case for fdsink and also not one we would want to support as it adds many new problems and questions (should it resend any streamheaders when the caps change for example?). You should be able to just use multifdsink for this or alternatively just an appsink that writes to different fds.