mirror of https://github.com/M66B/NetGuard.git
Native fixed locking
This commit is contained in:
parent
6b7ecedffe
commit
dc968e449f
|
@ -362,14 +362,8 @@ void *handle_events(void *a) {
|
|||
stopping = 0;
|
||||
signaled = 0;
|
||||
|
||||
if (pthread_mutex_lock(&lock))
|
||||
log_android(ANDROID_LOG_ERROR, "pthread_mutex_lock failed");
|
||||
|
||||
// Loop
|
||||
while (1) {
|
||||
if (pthread_mutex_unlock(&lock))
|
||||
log_android(ANDROID_LOG_ERROR, "pthread_mutex_unlock failed");
|
||||
|
||||
log_android(ANDROID_LOG_DEBUG, "Loop thread %lu", thread_id);
|
||||
|
||||
// Check sessions
|
||||
|
@ -384,9 +378,6 @@ void *handle_events(void *a) {
|
|||
udp_session == NULL && tcp_session == NULL ? NULL : &ts,
|
||||
&emptyset);
|
||||
|
||||
if (pthread_mutex_lock(&lock))
|
||||
log_android(ANDROID_LOG_ERROR, "pthread_mutex_lock failed");
|
||||
|
||||
if (ready < 0) {
|
||||
if (errno == EINTR) {
|
||||
if (stopping && signaled) { ;
|
||||
|
@ -447,12 +438,18 @@ void *handle_events(void *a) {
|
|||
gettimeofday(&start, NULL);
|
||||
#endif
|
||||
|
||||
if (pthread_mutex_lock(&lock))
|
||||
log_android(ANDROID_LOG_ERROR, "pthread_mutex_lock failed");
|
||||
|
||||
// Check UDP downstream
|
||||
check_udp_sockets(args, &rfds, &wfds, &efds);
|
||||
|
||||
// Check TCP downstream
|
||||
check_tcp_sockets(args, &rfds, &wfds, &efds);
|
||||
|
||||
if (pthread_mutex_unlock(&lock))
|
||||
log_android(ANDROID_LOG_ERROR, "pthread_mutex_unlock failed");
|
||||
|
||||
#ifdef PROFILE
|
||||
gettimeofday(&end, NULL);
|
||||
mselapsed = (end.tv_sec - start.tv_sec) * 1000.0 +
|
||||
|
@ -460,12 +457,10 @@ void *handle_events(void *a) {
|
|||
if (mselapsed > 1)
|
||||
log_android(ANDROID_LOG_INFO, "sockets %f", mselapsed);
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (pthread_mutex_unlock(&lock))
|
||||
log_android(ANDROID_LOG_ERROR, "pthread_mutex_unlock failed");
|
||||
|
||||
(*env)->DeleteGlobalRef(env, args->instance);
|
||||
|
||||
// Detach from Java
|
||||
|
|
Loading…
Reference in New Issue