static jdwpTransportError JNICALL shmemAttach(jdwpTransportEnv* env, const char *address, jlong attachTimeout, jlong handshakeTimeout) { jint rc; if (connection != NULL) { RETURN_ERROR(JDWPTRANSPORT_ERROR_ILLEGAL_STATE, "already connected"); } rc = shmemBase_attach(address, (long)attachTimeout, &connection); if (rc != SYS_OK) { if (rc == SYS_NOMEM) { RETURN_ERROR(JDWPTRANSPORT_ERROR_OUT_OF_MEMORY, "out of memory"); } if (rc == SYS_TIMEOUT) { RETURN_ERROR(JDWPTRANSPORT_ERROR_TIMEOUT, "Timed out waiting to attach"); } RETURN_IO_ERROR("failed to attach to shared memory connection"); } rc = handshake(); if (rc != JDWPTRANSPORT_ERROR_NONE) { shmemBase_closeConnection(connection); connection = NULL; } return rc; }
/* * Class: com_sun_tools_jdi_SharedMemoryTransport * Method: attach0 * Signature: (Ljava/lang/String;)J */ JNIEXPORT jlong JNICALL Java_com_sun_tools_jdi_SharedMemoryTransportService_attach0 (JNIEnv *env, jobject thisObject, jstring address, jlong timeout) { SharedMemoryConnection *connection = NULL; jint rc; const char *addrChars; addrChars = (*env)->GetStringUTFChars(env, address, NULL); if ((*env)->ExceptionOccurred(env)) { return CONNECTION_TO_ID(connection); } else if (addrChars == NULL) { throwException(env, "java/lang/InternalError", "GetStringUTFChars failed"); return CONNECTION_TO_ID(connection); } rc = shmemBase_attach(addrChars, (long)timeout, &connection); if (rc != SYS_OK) { throwShmemException(env, "shmemBase_attach failed", rc); } (*env)->ReleaseStringUTFChars(env, address, addrChars); return CONNECTION_TO_ID(connection); }