I have an application that consists of two processes (let them be called A and B) connected to each other via Unix domain sockets. In most cases, it works fine, but some users report the following:
- A sends a request to B. This works. A now begins to read the answer from B.
- B sends the response A. The corresponding call to write () returns an EPIPE error and, as a result, B close () the socket. However, A did not close () the socket and did not crash.
- The read () call returns 0 indicating the end of the file. A believes that B prematurely closed the connection.
Users also reported changes to this behavior, for example:
- A sends a request to B. This works partially, but before sending the entire request. The write () call returns EPIPE and, as a result, A close () the socket. However, B did not close () the socket and did not crash.
- B reads a partial request and then receives an EOF.
The problem is that I cannot reproduce this behavior locally at all. I tried OS X and Linux. Users are on different systems, mainly OS X and Linux.
Things I've already tried and reviewed:
- Errors Double close () (close () is called twice in the same file descriptor): perhaps this is not the case with EBADF errors, but I have not seen them.
- Increase the maximum file descriptor limit. One user said that it worked for him, the rest said that it wasn’t.
? , A, B close() , , , A B . - .