Skip to content
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

Conversation

elBoberido
Copy link
Member

@elBoberido elBoberido commented May 20, 2021

Pre-Review Checklist for the PR Author

  1. Code follows the coding style of CONTRIBUTING.md
  2. Tests follow the best practice for testing
  3. Branch follows the naming format (iox-#123-this-is-a-branch)
  4. Commits messages are according to this guideline
    • Commit messages have the issue ID (iox-#123 commit text)
    • Commit messages are signed (git commit -s)
    • Commit author matches Eclipse Contributor Agreement (and ECA is signed)
  5. Update the PR title
    • Follow the same conventions as for commit messages
    • Link to the relevant issue
  6. Relevant issues are linked
  7. Add sensible notes for the reviewer
  8. All checks have passed (except task-list-completed)
  9. Assign PR to reviewer

Notes for Reviewer

Checklist for the PR Reviewer

  • Commits are properly organized and messages are according to the guideline
  • Code according to our coding style and naming conventions
  • Unit tests have been written for new behavior
  • Public API changes are documented via doxygen
  • Copyright owner are updated in the changed files
  • PR title describes the changes

Post-review Checklist for the PR Author

  1. All open points are addressed and tracked via issues

References

…socket

Signed-off-by: Mathias Kraus <mathias.kraus@apex.ai>
@elBoberido elBoberido added the bugfix Solves a bug label May 20, 2021
@elBoberido elBoberido self-assigned this May 20, 2021
@@ -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);
Copy link
Member Author

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?

Copy link
Contributor

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?

Copy link
Contributor

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!

Copy link
Member Author

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
Copy link

codecov bot commented May 20, 2021

Codecov Report

Merging #804 (0f14478) into master (d3f697f) will decrease coverage by 0.01%.
The diff coverage is 50.00%.

Impacted file tree graph

@@            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              
Flag Coverage Δ
unittests 73.17% <50.00%> (-0.05%) ⬇️
unittests_timing 30.77% <50.00%> (-0.15%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
..._hoofs/source/posix_wrapper/unix_domain_socket.cpp 59.05% <50.00%> (-2.33%) ⬇️
iceoryx_hoofs/source/posix_wrapper/timer.cpp 62.33% <0.00%> (+1.73%) ⬆️

Copy link
Contributor

@mossmaurice mossmaurice left a 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);
Copy link
Contributor

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);
Copy link
Contributor

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!

@elBoberido elBoberido merged commit 2414145 into eclipse-iceoryx:master May 20, 2021
@elBoberido elBoberido deleted the iox-#654-stop-flooding-output-if-there-is-an-outdated-socket branch May 20, 2021 20:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix Solves a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Starting an application after RouDi was terminated floods the cmd line with error messages
3 participants