Commit 10f105d2 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

vlc_object_waitpipe: cancellation safety

parent 1b20e18a
...@@ -356,6 +356,9 @@ int vlc_object_waitpipe( vlc_object_t *obj ) ...@@ -356,6 +356,9 @@ int vlc_object_waitpipe( vlc_object_t *obj )
/* This can only ever happen if someone killed us without locking: */ /* This can only ever happen if someone killed us without locking: */
assert (internals->pipes[1] == -1); assert (internals->pipes[1] == -1);
/* pipe() is not a cancellation point, but write() is and eventfd() is
* unspecified (not in POSIX). */
int canc = vlc_savecancel ();
#if defined (HAVE_SYS_EVENTFD_H) #if defined (HAVE_SYS_EVENTFD_H)
internals->pipes[0] = internals->pipes[1] = eventfd (0, EFD_CLOEXEC); internals->pipes[0] = internals->pipes[1] = eventfd (0, EFD_CLOEXEC);
if (internals->pipes[0] == -1) if (internals->pipes[0] == -1)
...@@ -370,6 +373,7 @@ int vlc_object_waitpipe( vlc_object_t *obj ) ...@@ -370,6 +373,7 @@ int vlc_object_waitpipe( vlc_object_t *obj )
msg_Dbg (obj, "waitpipe: object already dying"); msg_Dbg (obj, "waitpipe: object already dying");
write (internals->pipes[1], &(uint64_t){ 1 }, sizeof (uint64_t)); write (internals->pipes[1], &(uint64_t){ 1 }, sizeof (uint64_t));
} }
vlc_restorecancel (canc);
} }
vlc_mutex_unlock (&pipe_lock); vlc_mutex_unlock (&pipe_lock);
return internals->pipes[0]; return internals->pipes[0];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment