fix race condition: DB_READY lost when utun thread starts before gui_bridge_init
- mainwindow.cpp: swap setupMessaging() before setupNode() so g_receiver is created first - gui_bridge_impl.cpp: add DEBUG_WARN when gui_bridge_post drops event due to NULL g_receiver
This commit is contained in:
1 parent
f9e38f5695
commit
279bc68bca
3 files changed
+8
-5
No files matched your search
@@ -130,11 +130,13 @@ static int insert_record(struct DB_SYNC_INSTANCE* si, struct UTUN_INSTANCE* inst
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
g_seed = (unsigned int)time(NULL);
|
||||
g_seed = 1784385257; /* FIXME: debug — restore time(NULL) after fix */
|
||||
srand(g_seed);
|
||||
|
||||
debug_config_init();
|
||||
debug_set_category_level(DEBUG_CATEGORY_DEBUG, DEBUG_LEVEL_WARN);
|
||||
debug_set_category_level(DEBUG_CATEGORY_DEBUG, DEBUG_LEVEL_TRACE);
|
||||
debug_set_category_level(DEBUG_CATEGORY_DB_SYNC, DEBUG_LEVEL_TRACE);
|
||||
debug_set_category_level(DEBUG_CATEGORY_ETCP, DEBUG_LEVEL_TRACE);
|
||||
|
||||
if (create_temp_configs() != 0) { fprintf(stderr, "FAIL: config creation\n"); return 1; }
|
||||
debug_enable_file_output(log_path, 1);
|
||||
@@ -241,6 +243,7 @@ cleanup:
|
||||
|
||||
int result = (test_phase == 0) ? 0 : 1;
|
||||
fprintf(stderr, "=== %s seed=%u (log: %s) ===\n", result ? "FAIL" : "PASS", g_seed, log_path);
|
||||
cleanup_temp_configs();
|
||||
/* FIXME: debug — restore cleanup_temp_configs() after fix */
|
||||
/* cleanup_temp_configs(); */
|
||||
return result;
|
||||
}
|
||||
@@ -102,8 +102,8 @@ MainWindow::MainWindow(QWidget *parent, DbManager* db, const QString& cfgPath,
|
||||
}
|
||||
});
|
||||
|
||||
setupNode();
|
||||
setupMessaging();
|
||||
setupNode();
|
||||
|
||||
connect(m_channelList, &ChannelList::channelSelected,
|
||||
this, [this](const QString& channelId) {
|
||||
|
||||
@@ -151,7 +151,7 @@ void gui_bridge_set_uasync(struct UASYNC* ua) {
|
||||
}
|
||||
|
||||
void gui_bridge_post(int event_type, const uint8_t* data, int data_len) {
|
||||
if (!g_receiver) return;
|
||||
if (!g_receiver) { DEBUG_WARN(DEBUG_CATEGORY_DEBUG, "gui_bridge_post: g_receiver=NULL, dropping event %d", event_type); return; }
|
||||
|
||||
QByteArray d;
|
||||
if (data_len > 0) d = QByteArray((const char*)data, data_len);
|
||||
|
||||
Reference in new issue
Block a user