From 63bc5261631dd36c438e65022ba67c30def227e6 Mon Sep 17 00:00:00 2001 From: Your Name Date: Wed, 25 Feb 2026 07:24:17 -0400 Subject: [PATCH] v1.2.47 - Fix build: use getter function for g_connection_count (was static, can't extern) --- src/api.c | 4 ++-- src/main.h | 4 ++-- src/websockets.c | 2 ++ src/websockets.h | 3 +++ 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/api.c b/src/api.c index 8a05bf9..e088cb2 100644 --- a/src/api.c +++ b/src/api.c @@ -13,7 +13,7 @@ extern void log_query_execution(const char* query_type, const char* sub_id, #include #include #include -extern int g_connection_count; +int get_active_connection_count(void); #include #include #include @@ -1293,7 +1293,7 @@ cJSON* query_cpu_metrics(void) { cJSON_AddNumberToObject(cpu_stats, "process_id", (double)pid); // Get active WebSocket connection count - cJSON_AddNumberToObject(cpu_stats, "active_connections", (double)g_connection_count); + cJSON_AddNumberToObject(cpu_stats, "active_connections", (double)get_active_connection_count()); // Get memory usage from /proc/self/status FILE* mem_stat = fopen("/proc/self/status", "r"); diff --git a/src/main.h b/src/main.h index 87ecb97..9276b0d 100644 --- a/src/main.h +++ b/src/main.h @@ -13,8 +13,8 @@ // Using CRELAY_ prefix to avoid conflicts with nostr_core_lib VERSION macros #define CRELAY_VERSION_MAJOR 1 #define CRELAY_VERSION_MINOR 2 -#define CRELAY_VERSION_PATCH 46 -#define CRELAY_VERSION "v1.2.46" +#define CRELAY_VERSION_PATCH 47 +#define CRELAY_VERSION "v1.2.47" // Relay metadata (authoritative source for NIP-11 information) #define RELAY_NAME "C-Relay" diff --git a/src/websockets.c b/src/websockets.c index 26d5d6c..9512771 100644 --- a/src/websockets.c +++ b/src/websockets.c @@ -130,6 +130,8 @@ static tracked_connection_t g_connections[MAX_TRACKED_CONNECTIONS]; static int g_connection_count = 0; static pthread_mutex_t g_connections_lock = PTHREAD_MUTEX_INITIALIZER; +int get_active_connection_count(void) { return g_connection_count; } + static void connection_list_add(struct lws* wsi, struct per_session_data* pss) { pthread_mutex_lock(&g_connections_lock); for (int i = 0; i < MAX_TRACKED_CONNECTIONS; i++) { diff --git a/src/websockets.h b/src/websockets.h index a993b7b..15803f7 100644 --- a/src/websockets.h +++ b/src/websockets.h @@ -96,6 +96,9 @@ struct per_session_data { int is_websocket; // 1 if this is a WebSocket connection, 0 for HTTP }; +// Get current active WebSocket connection count +int get_active_connection_count(void); + // NIP-11 HTTP session data structure for managing buffer lifetime struct nip11_session_data { int type; // 0 for NIP-11