diff --git a/src/topo_node_sqlite.c b/src/topo_node_sqlite.c index 9b6cb8d5..e5b51983 100644 --- a/src/topo_node_sqlite.c +++ b/src/topo_node_sqlite.c @@ -139,9 +139,9 @@ int topo_node_sqlite_node_put(sqlite3* db, struct TOPO_NODEQ* nq) { if (i > 0) pos += snprintf(del_sql + pos, sizeof(del_sql) - (size_t)pos, ","); pos += snprintf(del_sql + pos, sizeof(del_sql) - (size_t)pos, "%d", (int)sock_ids[i]); } - pos += snprintf(del_sql + pos, sizeof(del_sql) - (size_t)pos, ")"); + pos += snprintf(del_sql + pos, sizeof(del_sql) - (size_t)pos, ") AND socket_id != 0"); } else { - snprintf(del_sql, sizeof(del_sql), "DELETE FROM node_addresses WHERE node_id=?"); + snprintf(del_sql, sizeof(del_sql), "DELETE FROM node_addresses WHERE node_id=? AND socket_id != 0"); } sqlite3_stmt* del_stmt = NULL; if (sqlite3_prepare_v2(db, del_sql, -1, &del_stmt, NULL) == SQLITE_OK) { diff --git a/tools/chatgui/transport/chat_core.c b/tools/chatgui/transport/chat_core.c index 4dcedff6..1170d7a7 100644 --- a/tools/chatgui/transport/chat_core.c +++ b/tools/chatgui/transport/chat_core.c @@ -647,11 +647,11 @@ void chat_core_connect_from_invite(struct chat_invite* inv) { DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "%s: [ADDR_SYNC] save_invite_addr node=0x%016llx addr_count=%d", CC_ID, (unsigned long long)node_id, inv->addr_count); sqlite3_stmt* ds = NULL; if (sqlite3_prepare_v2(g_cc.db, - "DELETE FROM node_addresses WHERE node_id=?", -1, &ds, NULL) == SQLITE_OK) { + "DELETE FROM node_addresses WHERE node_id=? AND socket_id=0", -1, &ds, NULL) == SQLITE_OK) { sqlite3_bind_int64(ds, 1, (sqlite3_int64)node_id); sqlite3_step(ds); int deleted = sqlite3_changes(g_cc.db); - DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "%s: [ADDR_SYNC] invite DELETE ALL for node=0x%016llx: %d rows deleted", CC_ID, (unsigned long long)node_id, deleted); + DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "%s: [ADDR_SYNC] invite DELETE socket_id=0 for node=0x%016llx: %d rows deleted", CC_ID, (unsigned long long)node_id, deleted); sqlite3_finalize(ds); } sqlite3_stmt* is = NULL;