[Xenomai] occasional EBADF in select() in notifier.c

Philippe Gerum rpm at xenomai.org
Tue Apr 22 09:32:51 CEST 2014

On 04/21/2014 11:24 PM, Matthias Schneider wrote:
> Still working on thread suspension in forge/mercury, I occasionally get a EBADF
> of the select() call in notifier.c. I suspect that this is due to accessing a
> copy of the file descriptor list notifier_rset while one of the file descriptors
> is being closed. This seems to be due to concurrent access on the notifier_rset
> from notifier_sighandler() and notifier_destroy(). "notifier_lock" is held in
> notifier_lock(), but not when copying and invoking select in notifier_sighandler().
> The EBADF leads to a "spurious notification" reporting and process termination -
>   obviously, the thread suspension was not triggered.
> I can think of several ways of addressing this issue but I am not sure about
> side effects:
> a) hold the "notifier_lock" mutex between copying the descriptor list and calling select

Not an option, we would need a threaded handler for grabbing the 
mutex-based lock, which would defeat the purpose of using a directed 
signal for forcing the recipient thread to stop execution until released.

> b) repeating the select() call in the case of EBADF

EBADF should be ignored. This just means that we won't find the notifier 
block in the scanned list anyway, which is a possible and correct outcome.

> Any ideas?
> Anyway, why is the select call necessary, isnt the file descriptor signaled via
> siginfo->si_fd, too?

Yes it is. This select() loop is a left-over.

> Regards,
> Matthias
> _______________________________________________
> Xenomai mailing list
> Xenomai at xenomai.org
> http://www.xenomai.org/mailman/listinfo/xenomai


More information about the Xenomai mailing list