353 char lock_debug_info[BUFFER_SIZE_MEDIUM] = {0};
357 uint64_t total_acquired = 0, total_released = 0;
358 uint32_t currently_held = 0;
362 "Historical Mutex/RWLock Statistics:\n"
363 " Total locks acquired: %llu\n"
364 " Total locks released: %llu\n"
365 " Currently held: %u\n"
366 " Net locks (acquired - released): %lld",
367 (
unsigned long long)total_acquired, (
unsigned long long)total_released, currently_held,
368 (
long long)total_acquired - (
long long)total_released);
380 int active_clients = 0;
381 int clients_with_audio = 0;
382 int clients_with_video = 0;
383 char client_details[BUFFER_SIZE_XLARGE] = {0};
384 int client_details_len = 0;
386 for (
int i = 0; i < MAX_CLIENTS; i++) {
390 clients_with_audio++;
393 clients_with_video++;
399 for (
int i = 0; i < MAX_CLIENTS; i++) {
401 bool is_active = atomic_load(&client->active);
402 uint32_t client_id_snapshot = atomic_load(&client->client_id);
404 if (is_active && client_id_snapshot != 0) {
406 if (client->audio_queue) {
407 uint64_t enqueued, dequeued, dropped;
409 if (enqueued > 0 || dequeued > 0 || dropped > 0) {
411 safe_snprintf(client_details + client_details_len,
sizeof(client_details) - client_details_len,
412 " Client %u audio queue: %llu enqueued, %llu dequeued, %llu dropped", client_id_snapshot,
413 (
unsigned long long)enqueued, (
unsigned long long)dequeued, (
unsigned long long)dropped);
414 if (len > 0 && client_details_len + len < (
int)
sizeof(client_details)) {
415 client_details_len += len;
420 if (client->outgoing_video_buffer) {
421 video_frame_stats_t stats;
423 if (stats.total_frames > 0) {
424 int len =
safe_snprintf(client_details + client_details_len,
sizeof(client_details) - client_details_len,
425 " Client %u video buffer: %llu frames, %llu dropped (%.1f%% drop rate)",
426 client_id_snapshot, (
unsigned long long)stats.total_frames,
427 (
unsigned long long)stats.dropped_frames, stats.drop_rate * 100.0f);
428 if (len > 0 && client_details_len + len < (
int)
sizeof(client_details)) {
429 client_details_len += len;
438 if (client_details_len > 0) {
439 log_info(
"Stats: Clients: %d, Audio: %d, Video: %d\n%s", active_clients, clients_with_audio, clients_with_video,
484 uint64_t total_frames_sent = 0;
485 uint64_t total_frames_dropped = 0;
490 for (
int i = 0; i < MAX_CLIENTS; i++) {
492 if (atomic_load(&client->client_id) != 0 && atomic_load(&client->active)) {
494 total_frames_sent += client->frames_sent;
497 if (client->outgoing_video_buffer) {
498 video_frame_stats_t stats;
500 total_frames_dropped += stats.dropped_frames;
514 if (total_frames_sent > 0 || total_frames_dropped > 0) {
atomic_bool g_server_should_exit
Global atomic shutdown flag shared across all threads.
ascii-chat Server Mode Entry Point Header
int safe_snprintf(char *buffer, size_t buffer_size, const char *format,...)
Safe formatted string printing to buffer.