Skip to content

Commit

Permalink
HevJNI: Fix missing mutex unlock.
Browse files Browse the repository at this point in the history
  • Loading branch information
heiher committed Aug 18, 2024
1 parent 108ff51 commit a0a13f9
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/hev-jni.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,15 @@ native_start_service (JNIEnv *env, jobject thiz, jstring config_path)

pthread_mutex_lock (&mutex);
if (work_thread)
return;
goto exit;

argv = malloc (sizeof (char *) * 2);
bytes = (const jbyte *)(*env)->GetStringUTFChars (env, config_path, NULL);
argv[1] = strdup ((const char *)bytes);
(*env)->ReleaseStringUTFChars (env, config_path, (const char *)bytes);

pthread_create (&work_thread, NULL, thread_handler, argv);
exit:
pthread_mutex_unlock (&mutex);
}

Expand All @@ -111,11 +112,12 @@ native_stop_service (JNIEnv *env, jobject thiz)
{
pthread_mutex_lock (&mutex);
if (!work_thread)
return;
goto exit;

quit ();
pthread_join (work_thread, NULL);
work_thread = 0;
exit:
pthread_mutex_unlock (&mutex);
}

Expand Down

0 comments on commit a0a13f9

Please sign in to comment.