5
5
extern " C" {
6
6
JNIEXPORT jboolean JNICALL
7
7
Java_network_loki_messenger_libsession_1util_ConfigBase_dirty (JNIEnv *env, jobject thiz) {
8
- std::lock_guard lock{util::util_mutex_};
9
8
auto * configBase = ptrToConfigBase (env, thiz);
10
9
return configBase->is_dirty ();
11
10
}
12
11
13
12
JNIEXPORT jboolean JNICALL
14
13
Java_network_loki_messenger_libsession_1util_ConfigBase_needsPush (JNIEnv *env, jobject thiz) {
15
- std::lock_guard lock{util::util_mutex_};
16
14
auto config = ptrToConfigBase (env, thiz);
17
15
return config->needs_push ();
18
16
}
19
17
20
18
JNIEXPORT jboolean JNICALL
21
19
Java_network_loki_messenger_libsession_1util_ConfigBase_needsDump (JNIEnv *env, jobject thiz) {
22
- std::lock_guard lock{util::util_mutex_};
23
20
auto config = ptrToConfigBase (env, thiz);
24
21
return config->needs_dump ();
25
22
}
26
23
27
24
JNIEXPORT jobject JNICALL
28
25
Java_network_loki_messenger_libsession_1util_ConfigBase_push (JNIEnv *env, jobject thiz) {
29
26
return jni_utils::run_catching_cxx_exception_or_throws<jobject>(env, [=] {
30
- std::lock_guard lock{util::util_mutex_};
31
27
auto config = ptrToConfigBase (env, thiz);
32
28
auto [seq_no, to_push, to_delete] = config->push ();
33
29
@@ -51,7 +47,6 @@ Java_network_loki_messenger_libsession_1util_ConfigBase_free(JNIEnv *env, jobjec
51
47
52
48
JNIEXPORT jbyteArray JNICALL
53
49
Java_network_loki_messenger_libsession_1util_ConfigBase_dump (JNIEnv *env, jobject thiz) {
54
- std::lock_guard lock{util::util_mutex_};
55
50
auto config = ptrToConfigBase (env, thiz);
56
51
auto dumped = config->dump ();
57
52
jbyteArray bytes = util::bytes_from_vector (env, dumped);
@@ -69,16 +64,13 @@ JNIEXPORT void JNICALL
69
64
Java_network_loki_messenger_libsession_1util_ConfigBase_confirmPushed (JNIEnv *env, jobject thiz,
70
65
jlong seq_no,
71
66
jobjectArray hash_list) {
72
- std::lock_guard lock{util::util_mutex_};
73
67
auto conf = ptrToConfigBase (env, thiz);
74
68
auto hash_list_size = env->GetArrayLength (hash_list);
75
69
std::unordered_set<std::string> hashes (hash_list_size);
76
70
77
71
for (int i = 0 ; i < hash_list_size; i++) {
78
- auto hash_jstring = jni_utils::JavaLocalRef (env, (jstring) env->GetObjectArrayElement (hash_list, i));
79
- auto hash = env->GetStringUTFChars (hash_jstring.get (), nullptr );
80
- hashes.insert (hash);
81
- env->ReleaseStringUTFChars (hash_jstring.get (), hash);
72
+ jni_utils::JavaLocalRef hash_jstring (env, (jstring) env->GetObjectArrayElement (hash_list, i));
73
+ hashes.insert (jni_utils::JavaStringRef (env, hash_jstring.get ()).copy ());
82
74
}
83
75
84
76
conf->confirm_pushed (seq_no, hashes);
@@ -90,7 +82,6 @@ JNIEXPORT jobject JNICALL
90
82
Java_network_loki_messenger_libsession_1util_ConfigBase_merge___3Lkotlin_Pair_2 (JNIEnv *env, jobject thiz,
91
83
jobjectArray to_merge) {
92
84
return jni_utils::run_catching_cxx_exception_or_throws<jobject>(env, [=] {
93
- std::lock_guard lock{util::util_mutex_};
94
85
auto conf = ptrToConfigBase (env, thiz);
95
86
size_t number = env->GetArrayLength (to_merge);
96
87
std::vector<std::pair<std::string, std::vector<unsigned char >>> configs = {};
@@ -137,7 +128,6 @@ Java_network_loki_messenger_libsession_1util_ConfigBase_00024Companion_kindFor(J
137
128
extern " C"
138
129
JNIEXPORT jobject JNICALL
139
130
Java_network_loki_messenger_libsession_1util_ConfigBase_activeHashes (JNIEnv *env, jobject thiz) {
140
- std::lock_guard lock{util::util_mutex_};
141
131
auto conf = ptrToConfigBase (env, thiz);
142
132
return jni_utils::jstring_list_from_collection (env, conf->active_hashes ());
143
133
}
0 commit comments