From 6cbd21542cf7a751e6f0f38864e7e9eae8fa3b14 Mon Sep 17 00:00:00 2001 From: Dirk Engling Date: Tue, 27 Oct 2026 21:32:24 +0100 Subject: Plug in the new per-thread stats counter, also make sure that the ot_clean sleep does not stall tracker exit --- ot_udp.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'ot_udp.c') diff --git a/ot_udp.c b/ot_udp.c index 19a6c7c..14210c3 100644 --- a/ot_udp.c +++ b/ot_udp.c @@ -77,8 +77,8 @@ int handle_udp6(int64_t serversocket, struct ot_workstruct *ws) { return 0; byte_count = (size_t)result; - stats_issue_event(EVENT_ACCEPT, FLAG_UDP, (uintptr_t)remoteip); - stats_issue_event(EVENT_READ, FLAG_UDP, byte_count); + stats_issue_event(ws, EVENT_ACCEPT, FLAG_UDP, (uintptr_t)remoteip); + stats_issue_event(ws, EVENT_READ, FLAG_UDP, byte_count); /* Minimum udp tracker packet size, also catches error */ if (byte_count < 16) @@ -111,7 +111,7 @@ int handle_udp6(int64_t serversocket, struct ot_workstruct *ws) { outpacket[1] = inpacket[3]; memcpy(&outpacket[2], &err_idmiss[0], s); socket_send(serversocket, ws->outbuf, 8 + s, remoteip, remoteport); - stats_issue_event(EVENT_CONNID_MISSMATCH, FLAG_UDP, 8 + s); + stats_issue_event(ws, EVENT_CONNID_MISSMATCH, FLAG_UDP, 8 + s); return 1; } } @@ -128,7 +128,7 @@ int handle_udp6(int64_t serversocket, struct ot_workstruct *ws) { outpacket[3] = connid[1]; socket_send(serversocket, ws->outbuf, 16, remoteip, remoteport); - stats_issue_event(EVENT_CONNECT, FLAG_UDP, 16); + stats_issue_event(ws, EVENT_CONNECT, FLAG_UDP, 16); break; case 1: /* This is an announce action */ /* Minimum udp announce packet size */ @@ -188,7 +188,7 @@ int handle_udp6(int64_t serversocket, struct ot_workstruct *ws) { } socket_send(serversocket, ws->outbuf, ws->reply_size, remoteip, remoteport); - stats_issue_event(EVENT_ANNOUNCE, FLAG_UDP, ws->reply_size); + stats_issue_event(ws, EVENT_ANNOUNCE, FLAG_UDP, ws->reply_size); break; case 2: /* This is a scrape action */ @@ -199,7 +199,7 @@ int handle_udp6(int64_t serversocket, struct ot_workstruct *ws) { return_udp_scrape_for_torrent(*(ot_hash *)(((char *)inpacket) + 16 + 20 * scrape_count), ((char *)outpacket) + 8 + 12 * scrape_count); socket_send(serversocket, ws->outbuf, 8 + 12 * scrape_count, remoteip, remoteport); - stats_issue_event(EVENT_SCRAPE, FLAG_UDP, scrape_count); + stats_issue_event(ws, EVENT_SCRAPE, FLAG_UDP, scrape_count); break; } return 1; @@ -210,6 +210,7 @@ static void *udp_worker(void *args) { struct ot_workstruct ws; memset(&ws, 0, sizeof(ws)); + stats_counters_register(&ws); ws.inbuf = malloc(G_INBUF_SIZE); ws.outbuf = malloc(G_OUTBUF_SIZE); #ifdef _DEBUG_HTTPERROR @@ -219,6 +220,8 @@ static void *udp_worker(void *args) { while (g_opentracker_running) handle_udp6(sock, &ws); + stats_counters_retire(&ws); + free(ws.inbuf); free(ws.outbuf); #ifdef _DEBUG_HTTPERROR -- cgit v1.3