Load config earlier in the JNI server entry point

This commit is contained in:
Andrew Bettison 2016-10-20 13:19:59 +10:30
parent 1efe6686fc
commit e2086249ac

View File

@ -61,9 +61,10 @@ static void wokeup()
JNIEXPORT jint JNICALL Java_org_servalproject_servaldna_ServalDCommand_server(
JNIEnv *env, jobject UNUSED(this), jobject callback, jobject keyring_pin, jobjectArray entry_pins)
{
if (!IJniServer){
cf_init();
cf_init();
cf_reload_strict();
if (!IJniServer) {
IJniServer = (*env)->FindClass(env, "org/servalproject/servaldna/IJniServer");
if (IJniServer==NULL)
return jni_throw(env, "java/lang/IllegalStateException", "Unable to locate class org.servalproject.servaldna.IJniServer");
@ -85,11 +86,9 @@ JNIEXPORT jint JNICALL Java_org_servalproject_servaldna_ServalDCommand_server(
int pid = server_pid();
if (pid < 0)
return jni_throw(env, "java/lang/IllegalStateException", "Failed to read server pid");
if (pid>0)
if (pid > 0)
return jni_throw(env, "java/lang/IllegalStateException", "Server already running");
cf_reload_strict();
int ret = -1;
{