summaryrefslogtreecommitdiffstats
path: root/include/ScopedPthreadMutexLock.h
Commit message (Collapse)AuthorAgeFilesLines
* Make network I/O interruptible.Elliott Hughes2010-08-091-0/+43
Every thread about to block on network I/O registers its thread id and the fd it's going to block on. In close, we scan the list and signal every thread that's blocked on the fd we're closing. They wake up with EINTR, see that their java.io.FileDescriptor has been invalidated (by the close code), and infer that this EINTR is not to be retried: this EINTR implies that they should throw. This patch also fixes a couple of bugs in accept. We were trying (and, obviously, failing) to reset SO_RCVTIMEO on fd -1 if the accept failed, and then throwing an exception relating to that rather than the failed accept(2). We were also not treating timeouts as a special case of failure and throwing the appropriate SocketTimeoutException. (One has to suspect that there's an errno-to-Exception function that we could write that would work for all this native code.) This patch also cleans up connect a little more. I've inlined doConnect into its single caller, I've removed the bogus use of 100ms polling, and I've rewritten the checking for success/failure to be based on the advice in Stevens' "Unix Network Programming". Bug: 2823977 Change-Id: I4f0cbd95be9ba25368be166008855a80c5d30845