Browse Source

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
topo_upd
Evgeny 3 months ago
parent
commit
0e0ad9316a
  1. 9
      tests/test_chat_sync_stress.c
  2. 2
      tools/chatgui/src/mainwindow.cpp
  3. 2
      tools/chatgui/transport/gui_bridge_impl.cpp

9
tests/test_chat_sync_stress.c

@ -130,11 +130,13 @@ static int insert_record(struct DB_SYNC_INSTANCE* si, struct UTUN_INSTANCE* inst
} }
int main(void) { int main(void) {
g_seed = (unsigned int)time(NULL); g_seed = 1784385257; /* FIXME: debug — restore time(NULL) after fix */
srand(g_seed); srand(g_seed);
debug_config_init(); 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; } if (create_temp_configs() != 0) { fprintf(stderr, "FAIL: config creation\n"); return 1; }
debug_enable_file_output(log_path, 1); debug_enable_file_output(log_path, 1);
@ -241,6 +243,7 @@ cleanup:
int result = (test_phase == 0) ? 0 : 1; int result = (test_phase == 0) ? 0 : 1;
fprintf(stderr, "=== %s seed=%u (log: %s) ===\n", result ? "FAIL" : "PASS", g_seed, log_path); 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; return result;
} }

2
tools/chatgui/src/mainwindow.cpp

@ -102,8 +102,8 @@ MainWindow::MainWindow(QWidget *parent, DbManager* db, const QString& cfgPath,
} }
}); });
setupNode();
setupMessaging(); setupMessaging();
setupNode();
connect(m_channelList, &ChannelList::channelSelected, connect(m_channelList, &ChannelList::channelSelected,
this, [this](const QString& channelId) { this, [this](const QString& channelId) {

2
tools/chatgui/transport/gui_bridge_impl.cpp

@ -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) { 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; QByteArray d;
if (data_len > 0) d = QByteArray((const char*)data, data_len); if (data_len > 0) d = QByteArray((const char*)data, data_len);

Loading…
Cancel
Save