void CAEDRTerminate() { OIC_LOG(DEBUG, TAG, "CAEDRTerminate"); bool isAttached = false; JNIEnv* env; jint res = (*g_jvm)->GetEnv(g_jvm, (void**) &env, JNI_VERSION_1_6); if (JNI_OK != res) { OIC_LOG(DEBUG, TAG, "CAEDRTerminate - Could not get JNIEnv pointer"); res = (*g_jvm)->AttachCurrentThread(g_jvm, &env, NULL); if (JNI_OK != res) { OIC_LOG(ERROR, TAG, "AttachCurrentThread failed"); return; } isAttached = true; } g_stopAccept = true; g_stopMulticast = true; g_stopUnicast = true; if (isAttached) { (*g_jvm)->DetachCurrentThread(g_jvm); } if (g_context) { (*env)->DeleteGlobalRef(env, g_context); } CAEDRNativeSocketCloseToAll(env); // delete mutex CAEDRDestroyMutex(); CAEDRNativeRemoveAllDeviceState(); CAEDRNativeRemoveAllDeviceSocket(env); CAEDRDestroyJniInterface(); }
void CAEDRServerTerminate() { OIC_LOG(DEBUG, TAG, "CAEDRServerTerminate"); if (!g_jvm) { return; } bool isAttached = false; JNIEnv* env = NULL; jint res = (*g_jvm)->GetEnv(g_jvm, (void**) &env, JNI_VERSION_1_6); if (JNI_OK != res) { OIC_LOG(DEBUG, TAG, "Could not get JNIEnv pointer"); res = (*g_jvm)->AttachCurrentThread(g_jvm, &env, NULL); if (JNI_OK != res) { OIC_LOG(ERROR, TAG, "AttachCurrentThread failed"); return; } isAttached = true; } CAEDRNativeSocketCloseToAll(env); if (isAttached) { (*g_jvm)->DetachCurrentThread(g_jvm); } CAEDRNativeRemoveAllDeviceState(); CAEDRNativeRemoveAllDeviceSocket(env); // delete mutex CAEDRServerDestroyMutex(); }
void CAEDRTerminate() { OIC_LOG(DEBUG, TAG, "CAEDRTerminate"); jboolean isAttached = JNI_FALSE; JNIEnv* env; jint res = (*g_jvm)->GetEnv(g_jvm, (void**)&env, JNI_VERSION_1_6); if(res != JNI_OK) { OIC_LOG(DEBUG, TAG, "CAEDRTerminate - Could not get JNIEnv pointer"); res = (*g_jvm)->AttachCurrentThread(g_jvm, &env, NULL); if(res != JNI_OK) { OIC_LOG(DEBUG, TAG, "AttachCurrentThread failed"); return; } isAttached = JNI_TRUE; } g_stopAccept = true; g_stopMulticast = true; g_stopUnicast = true; if(isAttached) (*g_jvm)->DetachCurrentThread(g_jvm); if(g_context) { (*env)->DeleteGlobalRef(env, g_context); } // delete mutex CAEDRDestroyMutex(); CAEDRNativeRemoveAllDeviceState(); CAEDRNativeRemoveAllDeviceSocket(env); }