This repository has been archived by the owner on Mar 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 114
Fix 100% CPU usage, use non-blocking IO to exit gracefully (remove side-effects) #46
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MadLittleMods
force-pushed
the
mergeable-pr-21-fix-linux-blocking
branch
3 times, most recently
from
November 10, 2017 00:07
4de8ff5
to
78e3948
Compare
MadLittleMods
added a commit
that referenced
this pull request
Nov 10, 2017
MadLittleMods
changed the title
Fix 100% CPU usage, use non-blocking IO, accurate exit
Fix 100% CPU usage, use non-blocking IO
Nov 10, 2017
MadLittleMods
commented
Nov 10, 2017
src/detection_mac.cpp
Outdated
uv_close((uv_handle_t *) &async_handler, NULL); | ||
uv_cond_destroy(¬ifyDeviceHandled); | ||
uv_mutex_destroy(¬ify_mutex); | ||
CFRunLoopStop(CFRunLoopGetCurrent()); |
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 not confident in this CFRunLoopStop
call here (kinda guessing on whether it is necessary)
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.
Should be CFRunLoopStop(gRunLoop);
MadLittleMods
added a commit
that referenced
this pull request
Nov 12, 2017
MadLittleMods
force-pushed
the
mergeable-pr-21-fix-linux-blocking
branch
from
November 12, 2017 06:38
ea3fe00
to
6685359
Compare
MadLittleMods
added a commit
that referenced
this pull request
Nov 12, 2017
Port #21 on top of the latest `master` > - Migration from `pthread` to `libuv`. > - Fix 100% CPU usage (using `poll()`): > source > > ``` c > /** > * udev_monitor_receive_device: > * @udev_monitor: udev monitor > ... > * The monitor socket is by default set to NONBLOCK. A variant of poll() on > * the file descriptor returned by udev_monitor_get_fd() should to be used to > * wake up when new devices arrive, or alternatively the file descriptor > * switched into blocking mode. > ... > **/ > ``` > - Out of the loop when receives SIGINT or SIGTERM signals for accurate completion of the program > - Fix some ome memory leaks > > ``` c > udev_monitor_unref(mon); > udev_unref(udev); > ``` > - For local functions and variables using the keyword `static` > > #21 (comment)
MadLittleMods
force-pushed
the
mergeable-pr-21-fix-linux-blocking
branch
2 times, most recently
from
February 4, 2018 23:18
2f3efad
to
7ff88c5
Compare
MadLittleMods
commented
Feb 5, 2018
isRunning = false; | ||
|
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.
Might need to delete threadHandle
🤔
MadLittleMods
force-pushed
the
mergeable-pr-21-fix-linux-blocking
branch
from
February 5, 2018 03:28
7ff88c5
to
438a5bb
Compare
MadLittleMods
force-pushed
the
mergeable-pr-21-fix-linux-blocking
branch
from
February 5, 2018 03:42
438a5bb
to
2ef3fb7
Compare
MadLittleMods
force-pushed
the
mergeable-pr-21-fix-linux-blocking
branch
3 times, most recently
from
February 5, 2018 08:02
476f1e5
to
aa63ea8
Compare
MadLittleMods
force-pushed
the
mergeable-pr-21-fix-linux-blocking
branch
from
February 5, 2018 08:23
aa63ea8
to
a48f0c6
Compare
MadLittleMods
changed the title
Fix 100% CPU usage, use non-blocking IO
Fix 100% CPU usage, use non-blocking IO to exit gracefully (remove side-effects)
Feb 7, 2018
Merged
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Mergeable version of #21 from @sarakusha
Todo:
detection_linux.cpp
app flow todetection_mac.cpp
npm test
, go through the manual steps and it just hangs. If you unplug a USB device again, it will throw a segmentation fault.usbDetect.stopMonitoring()
has no effectTesting
Reference
Test Ubuntu on Windows 10 with Hyper-V enabled
For reference, here is how I tested this PR on Windows 10 with Hyper-V in a Ubuntu 16.04.3 VM.
VirtualBox will BSOD your PC if you have Hyper-V enabled. Otherwise, we could use their slick USB device sharing.
Hyper-V Manager
program (already installed after you enable Hyper-V)ssh eric@192.168.1.130
on your host (you can find the IP from within the VM,ifconfig
)