JSS_throwMsg(env, SOCKET_EXCEPTION,
JSS_throwMsgPrErr(env, SOCKET_EXCEPTION,
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;    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 ) {            JSS_throwMsg(env, SOCKET_EXCEPTION,                "Failed to set option to handshake as client");            goto finish;        }    }    for(;;) {        newFD = PR_Accept(sock->fd, &addr, ivtimeout);        if( newFD != NULL ) {            /* success! */            break;        } else {            switch( PR_GetError() ) {              case PR_PENDING_INTERRUPT_ERROR:              case PR_IO_PENDING_ERROR:                break; /* out of the switch and loop again */              default:                JSS_throwMsg(env, SOCKET_EXCEPTION,                    "Failed to accept new connection");                goto finish;            }        }    }    newSD = JSSL_CreateSocketData(env, newSock, newFD);    newFD = NULL;    if( newSD == NULL ) {        goto finish;    }    /* setup the handshake callback */    status = SSL_HandshakeCallback(newSD->fd, JSSL_HandshakeCallback,                                    newSD);    if( status != SECSuccess ) {        JSS_throwMsg(env, SOCKET_EXCEPTION,            "Unable to install handshake callback");    }    /* 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;}