• Elliott Hughes's avatar
    Make network I/O interruptible. · 9f2b1b1c
    Elliott Hughes authored
    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 10...
    9f2b1b1c
ScopedPthreadMutexLock.h 1.27 KB