Module: kamailio Branch: master Commit: 5e66ba23851f115bcb88d7e3f71f78ab33fc1e30 URL: https://github.com/kamailio/kamailio/commit/5e66ba23851f115bcb88d7e3f71f78ab...
Author: Ostap ostap_mal@hotmail.com Committer: GitHub noreply@github.com Date: 2024-04-28T23:15:28+02:00
modules/statsd: ensure statsd failures do not stop execution (#3819)
* modules/statsd: avoid stopping flow when sending statsd metric fails
Currently statsd functions return bool: `true` or `false` depending when the function succeeds or fails respectively.
This value gets implicitly converted to `int`: `true` -> `1`, `false` -> `0`.
For Kamailio `1` means succesfull execution, but `0` means to stop processing messages, which is not what we want as statsd should not impact flow execution. Instead we want to return `-1` which signifies error, but the flow continues.
* modules/statsd: do not fail module initilization when statsd init fails
statsd_init executes `statsd_connect` which tries to connect to statd server.
If connection fails then kamailio fails to start. This is not the desired behaviour as: 1. Kamailio should continue working even if statsd server is down, metrics should not impact runtime. 2. `statsd_connect` is also re-executed each time we try to send the metric https://github.com/salemove/kamailio/blame/master/src/modules/statsd/lib_sta..., so it's initial result is not essential.
Note, that before 5.8 the result of init was already ignored due to implicit conversion of `false` to `0` until after https://github.com/kamailio/kamailio/commit/0186246fce8f0e4bb46b30c05174983c... was introduced (which could be considered a breaking change even if it seemingly fixes a bug in conversion).
---
Modified: src/modules/statsd/statsd.c
---
Diff: https://github.com/kamailio/kamailio/commit/5e66ba23851f115bcb88d7e3f71f78ab... Patch: https://github.com/kamailio/kamailio/commit/5e66ba23851f115bcb88d7e3f71f78ab...