epics-base / pvAccessCPP

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

Connection closed with RX socket error 9 #149

Open mdavidsaver opened 5 years ago

mdavidsaver commented 5 years ago

@hhslepicka reports a side-effect of #144 in the form of Connection closed with RX socket error 9. Error 9 is EBADF, which previously was treated the same as normal connection end. So it looks like there is a race during TCP connection shutdown. This has potentially nasty consequences as FDs can be reused quickly.

https://github.com/epics-base/pvAccessCPP/blob/3a8a24deb3c09ba732ed9b001edd1613f7c2dbc3/src/remote/codec.cpp#L1343-L1346

mdavidsaver commented 4 years ago

The results of https://github.com/epics-base/epics-base/pull/30 suggest that an interrupted recv() should return 0. However, given that a interrupted recvfrom() can return EBADF it isn't certain that there is an actual race here.

mdavidsaver commented 4 years ago

While not a fix, a22f866211c298754f57224c28d0279cd912b7ed should hide this message if it occurs during connection shutdown. It appears that some interrupted calls on OSX return EBADF (which I guess is true after close()).