PRErrorCode err = PR_GetError(); if( err == PR_PENDING_INTERRUPT_ERROR || err == PR_IO_TIMEOUT_ERROR ) {
Java_org_mozilla_jss_ssl_SSLServerSocket_socketAccept    (JNIEnv *env, jobject self, jobject newSock, jint timeout,        jboolean handshakeAsClient){    JSSL_SocketData *sock;    PRNetAddr addr;    PRFileDesc *newFD=NULL;    PRIntervalTime ivtimeout;    JSSL_SocketData *newSD=NULL;    jbyteArray sdArray = NULL;    SECStatus status;    PRThread *me;    if( JSSL_getSockData(env, self, &sock) != PR_SUCCESS) goto finish;    ivtimeout = (timeout > 0) ? PR_MillisecondsToInterval(timeout)                              : PR_INTERVAL_NO_TIMEOUT;    if( handshakeAsClient ) {        status = SSL_OptionSet(sock->fd, SSL_HANDSHAKE_AS_CLIENT, PR_TRUE);        if( status != SECSuccess ) {            JSSL_throwSSLSocketException(env,                "Failed to set option to handshake as client");            goto finish;        }    }    /* Set the current thread doing the accept. */    me = PR_GetCurrentThread();    PR_Lock(sock->lock);    PR_ASSERT(sock->accepter == NULL);    sock->accepter = me;    PR_Unlock(sock->lock);    newFD = PR_Accept(sock->fd, &addr, ivtimeout);    PR_Lock(sock->lock);    PR_ASSERT(sock->accepter == me);    sock->accepter = NULL;    PR_Unlock(sock->lock);    if( newFD == NULL ) {#ifdef WINNT        PRErrorCode err = PR_GetError();        if( err == PR_PENDING_INTERRUPT_ERROR ||            err == PR_IO_TIMEOUT_ERROR ) {            PR_NT_CancelIo(sock->fd);        }#endif        JSSL_throwSSLSocketException(env,            "Failed to accept new connection");        goto finish;    }    newSD = JSSL_CreateSocketData(env, newSock, newFD, NULL /* priv */);    if( newSD == NULL ) {        goto finish;    }    newFD = NULL;    /* setup the handshake callback */    status = SSL_HandshakeCallback(newSD->fd, JSSL_HandshakeCallback,                                    newSD);    if( status != SECSuccess ) {        JSSL_throwSSLSocketException(env,            "Unable to install handshake callback");        goto finish;    }    /* pass the pointer back to Java */    sdArray = JSS_ptrToByteArray(env, (void*) newSD);    if( sdArray == NULL ) {        /* exception was thrown */        goto finish;    }finish:    if( (*env)->ExceptionOccurred(env) != NULL ) {        if( newSD != NULL ) {            JSSL_DestroySocketData(env, newSD);        }        if( newFD != NULL ) {            PR_Close(newFD);        }    }    return sdArray;}