mirror of https://github.com/M66B/NetGuard.git
Native lock tun I/O
This commit is contained in:
parent
0ab9849552
commit
e2b14108fb
|
@ -427,10 +427,14 @@ void *handle_events(void *a) {
|
||||||
gettimeofday(&start, NULL);
|
gettimeofday(&start, NULL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Check upstream
|
if (pthread_mutex_lock(&lock))
|
||||||
if (check_tun(args, &rfds, &wfds, &efds) < 0)
|
log_android(ANDROID_LOG_ERROR, "pthread_mutex_lock failed");
|
||||||
break;
|
|
||||||
|
|
||||||
|
// Check upstream
|
||||||
|
int error;
|
||||||
|
if (check_tun(args, &rfds, &wfds, &efds) < 0)
|
||||||
|
error = 1;
|
||||||
|
else {
|
||||||
#ifdef PROFILE
|
#ifdef PROFILE
|
||||||
gettimeofday(&end, NULL);
|
gettimeofday(&end, NULL);
|
||||||
mselapsed = (end.tv_sec - start.tv_sec) * 1000.0 +
|
mselapsed = (end.tv_sec - start.tv_sec) * 1000.0 +
|
||||||
|
@ -441,18 +445,19 @@ void *handle_events(void *a) {
|
||||||
gettimeofday(&start, NULL);
|
gettimeofday(&start, NULL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (pthread_mutex_lock(&lock))
|
|
||||||
log_android(ANDROID_LOG_ERROR, "pthread_mutex_lock failed");
|
|
||||||
|
|
||||||
// Check UDP downstream
|
// Check UDP downstream
|
||||||
check_udp_sockets(args, &rfds, &wfds, &efds);
|
check_udp_sockets(args, &rfds, &wfds, &efds);
|
||||||
|
|
||||||
// Check TCP downstream
|
// Check TCP downstream
|
||||||
check_tcp_sockets(args, &rfds, &wfds, &efds);
|
check_tcp_sockets(args, &rfds, &wfds, &efds);
|
||||||
|
}
|
||||||
|
|
||||||
if (pthread_mutex_unlock(&lock))
|
if (pthread_mutex_unlock(&lock))
|
||||||
log_android(ANDROID_LOG_ERROR, "pthread_mutex_unlock failed");
|
log_android(ANDROID_LOG_ERROR, "pthread_mutex_unlock failed");
|
||||||
|
|
||||||
|
if (error)
|
||||||
|
break;
|
||||||
|
|
||||||
#ifdef PROFILE
|
#ifdef PROFILE
|
||||||
gettimeofday(&end, NULL);
|
gettimeofday(&end, NULL);
|
||||||
mselapsed = (end.tv_sec - start.tv_sec) * 1000.0 +
|
mselapsed = (end.tv_sec - start.tv_sec) * 1000.0 +
|
||||||
|
@ -460,7 +465,6 @@ void *handle_events(void *a) {
|
||||||
if (mselapsed > 1)
|
if (mselapsed > 1)
|
||||||
log_android(ANDROID_LOG_INFO, "sockets %f", mselapsed);
|
log_android(ANDROID_LOG_INFO, "sockets %f", mselapsed);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue