Compare commits

...
2 Commits
5 changed files with 15 additions and 10 deletions
+2 -2
View File
@@ -13,6 +13,7 @@ extern void log_query_execution(const char* query_type, const char* sub_id,
#include <pthread.h>
#include <libwebsockets.h>
#include <cjson/cJSON.h>
int get_active_connection_count(void);
#include <sqlite3.h>
#include <time.h>
#include <sys/stat.h>
@@ -1292,8 +1293,7 @@ cJSON* query_cpu_metrics(void) {
cJSON_AddNumberToObject(cpu_stats, "process_id", (double)pid);
// Get active WebSocket connection count
extern int g_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");
File diff suppressed because one or more lines are too long
+2 -2
View File
@@ -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 45
#define CRELAY_VERSION "v1.2.45"
#define CRELAY_VERSION_PATCH 47
#define CRELAY_VERSION "v1.2.47"
// Relay metadata (authoritative source for NIP-11 information)
#define RELAY_NAME "C-Relay"
+2
View File
@@ -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++) {
+3
View File
@@ -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