|
|
|
|
@ -30,6 +30,7 @@
|
|
|
|
|
#include "../jni_bridge/android_jni_bridge.h" |
|
|
|
|
#include "standby.h" |
|
|
|
|
#include "stream_bridge.h" |
|
|
|
|
#include "call/call_video_port.h" |
|
|
|
|
#include <pthread.h> |
|
|
|
|
#include <stdio.h> |
|
|
|
|
#include <string.h> |
|
|
|
|
@ -314,6 +315,7 @@ static void* instance_thread(void* arg) {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* sockets are now created — sync my addresses to DB */ |
|
|
|
|
call_video_port_attach(g_inst); |
|
|
|
|
chat_core_sync_my_addresses(g_inst); |
|
|
|
|
fire_local_sockets_event(); |
|
|
|
|
|
|
|
|
|
@ -357,6 +359,7 @@ static void* instance_thread(void* arg) {
|
|
|
|
|
__atomic_store_n(&g_running, 0, __ATOMIC_RELEASE); |
|
|
|
|
struct UTUN_INSTANCE* old_inst = g_inst; |
|
|
|
|
g_inst = NULL; |
|
|
|
|
call_video_port_detach(old_inst); |
|
|
|
|
android_stream_detach(old_inst); |
|
|
|
|
utun_instance_destroy(old_inst); |
|
|
|
|
my_inst = NULL; |
|
|
|
|
@ -393,6 +396,7 @@ static void* instance_thread(void* arg) {
|
|
|
|
|
IL_LOGE("poll exit: core/chat/stream bridge start failed"); break; |
|
|
|
|
} |
|
|
|
|
chat_core_sync_my_addresses(g_inst); |
|
|
|
|
call_video_port_attach(g_inst); |
|
|
|
|
fire_local_sockets_event(); |
|
|
|
|
if (g_inst->config->global.name[0]) chat_core_update_my_name(g_inst, g_inst->config->global.name); |
|
|
|
|
etcp_router_bind(g_inst, ETCP_RT_ID_CHAT_SYNC, NULL); |
|
|
|
|
@ -415,6 +419,7 @@ static void* instance_thread(void* arg) {
|
|
|
|
|
if (my_inst) { |
|
|
|
|
chat_event_post(my_inst, CHAT_EVT_SERVICE_STOPPED, NULL, 0); |
|
|
|
|
g_inst = NULL; |
|
|
|
|
call_video_port_detach(my_inst); |
|
|
|
|
android_stream_detach(my_inst); |
|
|
|
|
utun_instance_destroy(my_inst); |
|
|
|
|
my_inst = NULL; |
|
|
|
|
@ -435,7 +440,7 @@ static void* instance_thread(void* arg) {
|
|
|
|
|
но собственные объекты этого потока надо закрыть, иначе течёт fd. */ |
|
|
|
|
IL_LOGI("cleanup (stale thread gen=%d vs %d): destroying own inst=%p ua=%p to avoid fd leak", |
|
|
|
|
my_gen, g_generation, (void*)my_inst, (void*)my_ua); |
|
|
|
|
if (my_inst) { android_stream_detach(my_inst); utun_instance_destroy(my_inst); my_inst = NULL; } |
|
|
|
|
if (my_inst) { call_video_port_detach(my_inst); android_stream_detach(my_inst); utun_instance_destroy(my_inst); my_inst = NULL; } |
|
|
|
|
if (my_ua) { udp_log_detach(my_ua); uasync_destroy(my_ua, 0); my_ua = NULL; } |
|
|
|
|
} |
|
|
|
|
__atomic_store_n(&g_thread_running, 0, __ATOMIC_RELEASE); |
|
|
|
|
|