diff --git a/code/controllers/subsystem/dbcore.dm b/code/controllers/subsystem/dbcore.dm index b4db83d988d..5902d7f02d4 100644 --- a/code/controllers/subsystem/dbcore.dm +++ b/code/controllers/subsystem/dbcore.dm @@ -74,12 +74,12 @@ SUBSYSTEM_DEF(dbcore) queries_current = queries_active.Copy() processing_queries = all_queries.Copy() - for(var/I in processing_queries) - var/datum/db_query/Q = I - if(world.time - Q.last_activity_time > (5 MINUTES)) + while(length(processing_queries)) + var/datum/db_query/query = popleft(processing_queries) + if(world.time - query.last_activity_time > (5 MINUTES)) message_admins("Found undeleted query, please check the server logs and notify coders.") - log_sql("Undeleted query: \"[Q.sql]\" LA: [Q.last_activity] LAT: [Q.last_activity_time]") - qdel(Q) + log_sql("Undeleted query: \"[query.sql]\" LA: [query.last_activity] LAT: [query.last_activity_time]") + qdel(query) if(MC_TICK_CHECK) return diff --git a/code/modules/tgui_panel/telemetry.dm b/code/modules/tgui_panel/telemetry.dm index 63d175b06ce..30019f720aa 100644 --- a/code/modules/tgui_panel/telemetry.dm +++ b/code/modules/tgui_panel/telemetry.dm @@ -76,7 +76,7 @@ var/list/found - var/list/insert_queries = list() + var/list/query_data = list() for(var/i in 1 to len) if(QDELETED(client)) @@ -89,28 +89,10 @@ return if (!isnull(GLOB.round_id)) - insert_queries += SSdbcore.NewQuery({" - INSERT INTO [format_table_name("telemetry_connections")] ( - ckey, - telemetry_ckey, - address, - computer_id, - first_round_id, - latest_round_id - ) VALUES( - :ckey, - :telemetry_ckey, - INET_ATON(:address), - :computer_id, - :round_id, - :round_id - ) ON DUPLICATE KEY UPDATE latest_round_id = :round_id - "}, list( - "ckey" = ckey, + query_data += list(list( "telemetry_ckey" = row["ckey"], "address" = row["address"], "computer_id" = row["computer_id"], - "round_id" = GLOB.round_id, )) if (row["ckey"] in our_known_alts) @@ -130,7 +112,29 @@ log_suspicious_login(msg, access_log_mirror = FALSE) // Only log them all at the end, since it's not as important as reporting an evader - for (var/datum/db_query/insert_query as anything in insert_queries) - insert_query.Execute() - - QDEL_LIST(insert_queries) + for (var/one_query as anything in query_data) + var/datum/db_query/query = SSdbcore.NewQuery({" + INSERT INTO [format_table_name("telemetry_connections")] ( + ckey, + telemetry_ckey, + address, + computer_id, + first_round_id, + latest_round_id + ) VALUES( + :ckey, + :telemetry_ckey, + INET_ATON(:address), + :computer_id, + :round_id, + :round_id + ) ON DUPLICATE KEY UPDATE latest_round_id = :round_id + "}, list( + "ckey" = ckey, + "telemetry_ckey" = query_data["telemetry_ckey"], + "address" = query_data["address"], + "computer_id" = query_data["computer_id"], + "round_id" = GLOB.round_id, + )) + query.Execute() + qdel(query)