#### Pre-Submission Checklist <!-- Go over all points below, and after creating the PR, tick all the checkboxes that apply --> <!-- All points should be verified, otherwise, read the CONTRIBUTING guidelines from above--> <!-- If you're unsure about any of these, don't hesitate to ask on sr-dev mailing list --> - [x] Commit message has the format required by CONTRIBUTING guide - [x] Commits are split per component (core, individual modules, libs, utils, ...) - [x] Each component has a single commit (if not, squash them into one commit) - [x] No commits to README files for modules (changes must be done to docbook files in `doc/` subfolder, the README file is autogenerated)
#### Type Of Change - [x] Small bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds new functionality) - [ ] Breaking change (fix or feature that would change existing functionality)
#### Checklist: <!-- Go over all points below, and after creating the PR, tick the checkboxes that apply --> - [ ] PR should be backported to stable branches - [ ] Tested changes locally - [ ] Related to issue #XXXX (replace XXXX with an open issue number)
#### Description <!-- Describe your changes in detail -->
2 issues:
**Issue 1:** 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.
**Issue 2:** 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).
You can view, comment on, or merge this pull request online at:
https://github.com/kamailio/kamailio/pull/3819
-- Commit Summary --
* modules/statsd: avoid stopping flow when sending statsd metric fails * modules/statsd: do not fail module initilization when statsd init fails
-- File Changes --
M src/modules/statsd/statsd.c (51)
-- Patch Links --
https://github.com/kamailio/kamailio/pull/3819.patch https://github.com/kamailio/kamailio/pull/3819.diff