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

FileDescriptorActivity locking and robustness #309

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

meyerj
Copy link
Member

@meyerj meyerj commented Oct 24, 2019

This PR collects some patches to improve robustness of the FileDescriptorActivity and to avoid locks in trigger() and breakLoop() calls.

  • Remove locks from FileDescriptorActivity::trigger(), FileDescriptorActivity::breakLoop() and FileDescriptorActivity::triggerUpdateSets() (contributed by @MagnaboscoL)
  • Do not rearm the timeout timer if the previous cycle was due to a trigger() call. The previous implementation was waiting for the set timeout period after every interruption, which in theory could lead to the situation that the timeout cycle is never triggered if there is no activity on the file descriptor but the activity is constantly triggered due to operation calls or port callbacks.
  • The bookkeeping of the m_running flag was buggy and isRunning() might have returned false even though the activity was still processing the step() function.

* do not signal the command pipe if the trigger or break flag was already set
* make sure that the IOReady step cannot be executed if the command pipe was the
  only active file descriptor
* fixed return value of hasTimeout(): the function should return true if the current
  execution cycle was triggered due to a select timeout

Signed-off-by: Johannes Meyer <[email protected]>
m_running was reset to false after the first call to step() and before a call to work(...).

Signed-off-by: Johannes Meyer <[email protected]>
@meyerj meyerj added this to the 2.10 milestone Oct 24, 2019
Luca Magnabosco and others added 5 commits October 24, 2019 23:06
…t locks in trigger() call

Signed-off-by: Johannes Meyer <[email protected]>
…tect the set of watched file descriptors

Signed-off-by: Johannes Meyer <[email protected]>
…rrent removal of watched fd and write

Signed-off-by: Johannes Meyer <[email protected]>
@meyerj meyerj force-pushed the master-file-descriptor-activity-locking-and-robustness branch from 96eced7 to cecf831 Compare October 24, 2019 21:07
Comment on lines +329 to +334
if (m_has_timeout || m_has_ioready || m_has_error ||
(timeout.tv_sec == 0 && timeout.tv_usec == 0)) {
static const int USECS_PER_SEC = 1000000;
timeout.tv_sec = m_timeout_us / USECS_PER_SEC;
timeout.tv_usec = m_timeout_us % USECS_PER_SEC;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be good to add a unit test for this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants