modules/statsd: ensure statsd failures do not stop execution #3819
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Pre-Submission Checklist
in
doc/
subfolder, the README file is autogenerated)Type Of Change
Checklist:
Description
2 issues:
Issue 1:
Currently statsd functions return bool:
true
orfalse
depending whenthe function succeeds or fails respectively.
This value gets implicitly converted to
int
:true
->1
,false
->0
.For Kamailio
1
means succesfull execution, but0
means to stopprocessing 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 statdserver.
If connection fails then kamailio fails to start.
This is not the desired behaviour as:
metrics should not impact runtime.
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_statsd.c#L76,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
to0
until after
0186246
was introduced (which could be considered a breaking change even if it
seemingly fixes a bug in conversion).