epics-base / pvAccessCPP

pvAccessCPP is an EPICS V4 C++ module
https://epics-base.github.io/pvAccessCPP/
Other
10 stars 22 forks source link

RTEMS: race between recvfrom()/accept() and close() results in stuck threads #150

Open mdavidsaver opened 5 years ago

mdavidsaver commented 5 years ago

Running testChannelAccess on RTEMS (for the first time?) leaves worker threads hung in recvfrom() and accept(). On investigation I find that this results if a socket is close()d while concurrent accept() or recvfrom() is in progress.

mdavidsaver commented 5 years ago

The current shutdown sequence:

shutdown(socket, SHUT_RDWR);
close(socket);
thread.exitWait()

The problem with RTEMS can be avoided with:

shutdown(socket, SHUT_RDWR);
thread.exitWait()
close(socket);

However, this presents problems on targets other than Linux and RTEMS where shutdown() doesn't interrupt either accept() or recvfrom().

cf. https://github.com/epics-base/epics-base/pull/30