Skip to content

Conversation

@EnriqueRiveiro
Copy link

@EnriqueRiveiro EnriqueRiveiro commented Dec 16, 2025

This pull request refactors and improves the shared memory management for WebSocket statistics in the ngx_http_websocket_stat_module.c file. The main changes involve switching to NGINX's recommended shared memory zone API for storing and initializing counters, ensuring metrics are preserved across reloads, and improving the handling of maximum connection limits. These updates enhance reliability, maintainability, and correctness of the module.

Shared Memory Management Improvements:

  • Replaced the manual shared memory allocation with NGINX's ngx_shared_memory_add API, ensuring that the shared memory zone and metrics are preserved across reloads. Added a new initialization function ngx_http_websocket_stat_shm_init to properly set up or reuse the shared memory zone. [1] [2]
  • Modified the allocate_counters function to accept a configuration pointer and return an error code, integrating it into module initialization for better error handling.

WebSocket Connection Limit Handling:

  • Fixed the logic for checking the maximum number of allowed WebSocket connections by using >= instead of ==, preventing connections from exceeding the configured limit.

@EnriqueRiveiro EnriqueRiveiro changed the title feat: implement shared memory zone for WebSocket metrics persistence … feat: implement shared memory zone for WebSocket metrics persistence across reloads Dec 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants