JSS_throwMsg(env, SOCKET_EXCEPTION, "Operation timed out");
JSS_throwMsgPrErr(env, SOCKET_EXCEPTION, "Operation timed out");
Java_org_mozilla_jss_ssl_SSLSocket_socketWrite(JNIEnv *env, jobject self,     jbyteArray bufBA, jint off, jint len, jint timeout){    JSSL_SocketData *sock;    jbyte *buf = NULL;    jint size;    PRIntervalTime ivtimeout;    if( bufBA == NULL ) {        JSS_throw(env, NULL_POINTER_EXCEPTION);        goto finish;    }    size = (*env)->GetArrayLength(env, bufBA);    if( off < 0 || len < 0 || (off+len) > size ) {        JSS_throw(env, INDEX_OUT_OF_BOUNDS_EXCEPTION);        goto finish;    }    if( JSSL_getSockData(env, self, &sock) != PR_SUCCESS ) {        goto finish;    }    buf = (*env)->GetByteArrayElements(env, bufBA, NULL);    if( buf == NULL ) {        goto finish;    }    ivtimeout = (timeout > 0) ? PR_MillisecondsToInterval(timeout)                              : PR_INTERVAL_NO_TIMEOUT;    for(;;) {        PRInt32 numwrit;        numwrit = PR_Send(sock->fd, buf+off, len, 0 /*flags*/, ivtimeout);        if( numwrit < 0 ) {            PRErrorCode err = PR_GetError();            if( err == PR_PENDING_INTERRUPT_ERROR ||                err == PR_IO_PENDING_ERROR)            {                /* just try again */            } else if( err == PR_IO_TIMEOUT_ERROR ) {                JSS_throwMsg(env, SOCKET_EXCEPTION, "Operation timed out");                goto finish;            } else {                JSS_throwMsg(env, SOCKET_EXCEPTION,                    "Failed to write to socket");                goto finish;            }        } else {            /* PR_Send is supposed to block until it sends everything */            PR_ASSERT(numwrit == len);            break;        }    }finish:    if( buf != NULL ) {        (*env)->ReleaseByteArrayElements(env, bufBA, buf, JNI_ABORT);    }}