-
Notifications
You must be signed in to change notification settings - Fork 392
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
iox-#654 stop flooding output if there is an outdated socket #804
iox-#654 stop flooding output if there is an outdated socket #804
Conversation
…socket Signed-off-by: Mathias Kraus <mathias.kraus@apex.ai>
@@ -371,7 +371,7 @@ cxx::expected<IpcChannelError> UnixDomainSocket::initalizeSocket(const IpcChanne | |||
auto connectCall = | |||
posixCall(connect)(m_sockfd, reinterpret_cast<struct sockaddr*>(&m_sockAddr), sizeof(m_sockAddr)) | |||
.failureReturnValue(ERROR_CODE) | |||
.evaluateWithIgnoredErrnos(ENOENT); | |||
.evaluateWithIgnoredErrnos(ENOENT, ECONNREFUSED); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@elfenpiff I have the feeling we need something like evaluateWithSilentErrnos
. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm unsure if I like the idea. Then the decision is not binary anymore and we have three categories: errors, silent errors and ignored errors. In this case it would just mean the check for ECONNREFUSED
is moved from happy path to the sad path, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@elBoberido I think I am slightly against it. But I would support that we get rid of evalluateWithIgnoredErrnos
and replace it with evaluateWithSilentErrnos
I feel that it would make much more sense. Then we could get rid of the errnum in the success case since here it would be always errno = 0
.
Yeah I like it!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mossmaurice it is already the sad path but upgraded to the happy path to prevent logging to the console and then doing the same error handling like in the sad path. I've seen it also in one or two other places
@elfenpiff I think it's valuable to to completely ignore some errnos and handle them also as success but at the same time it is also necessary to not ignore the errno because it it still the error path but to not spam the output because it's an expected error which can easily be recovered from. What do you think of the following
class PosixCallEvaluator
{
public:
PosixCallEvaluator<ReturnType> successReturnValue(...) && noexcept;
PosixCallEvaluator<ReturnType> failureReturnValue(...) && noexcept;
PosixCallEvaluator<ReturnType> ignoredErrno(...) && noexcept;
PosixCallEvaluator<ReturnType> silencedErrno(...) && noexcept;
cxx::expected<PosixCallResult<ReturnType>, PosixCallResult<ReturnType>> evaluate() const&& noexcept;
private:
bool m_isError;
bool m_isSilent;
int m_returnValue;
int m_errnum;
};
With 0 as default value for success return this would look like this
posixCall(foo)().evaluate();
posixCall(bar).failureReturnValue(5).evaluate();
posixCall(baz).silencedErrnos(ENOENT, ECONNREFUSED).evaluate();
This would also make it easier to extend the evaluation in the future if we encounter a weird behavior. What do you think?
Codecov Report
@@ Coverage Diff @@
## master #804 +/- ##
==========================================
- Coverage 74.36% 74.35% -0.02%
==========================================
Files 322 322
Lines 11533 11532 -1
Branches 1956 1956
==========================================
- Hits 8577 8575 -2
- Misses 2193 2194 +1
Partials 763 763
Flags with carried forward coverage won't be shown. Click here to find out more.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, gave it a try and there was no output anymore \o/
@@ -371,7 +371,7 @@ cxx::expected<IpcChannelError> UnixDomainSocket::initalizeSocket(const IpcChanne | |||
auto connectCall = | |||
posixCall(connect)(m_sockfd, reinterpret_cast<struct sockaddr*>(&m_sockAddr), sizeof(m_sockAddr)) | |||
.failureReturnValue(ERROR_CODE) | |||
.evaluateWithIgnoredErrnos(ENOENT); | |||
.evaluateWithIgnoredErrnos(ENOENT, ECONNREFUSED); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm unsure if I like the idea. Then the decision is not binary anymore and we have three categories: errors, silent errors and ignored errors. In this case it would just mean the check for ECONNREFUSED
is moved from happy path to the sad path, right?
@@ -371,7 +371,7 @@ cxx::expected<IpcChannelError> UnixDomainSocket::initalizeSocket(const IpcChanne | |||
auto connectCall = | |||
posixCall(connect)(m_sockfd, reinterpret_cast<struct sockaddr*>(&m_sockAddr), sizeof(m_sockAddr)) | |||
.failureReturnValue(ERROR_CODE) | |||
.evaluateWithIgnoredErrnos(ENOENT); | |||
.evaluateWithIgnoredErrnos(ENOENT, ECONNREFUSED); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@elBoberido I think I am slightly against it. But I would support that we get rid of evalluateWithIgnoredErrnos
and replace it with evaluateWithSilentErrnos
I feel that it would make much more sense. Then we could get rid of the errnum in the success case since here it would be always errno = 0
.
Yeah I like it!
Pre-Review Checklist for the PR Author
iox-#123-this-is-a-branch
)iox-#123 commit text
)git commit -s
)task-list-completed
)Notes for Reviewer
Checklist for the PR Reviewer
Post-review Checklist for the PR Author
References