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

100% CPU usage in libnethogs when invoking multiple times in an application. Fix suggested. #253

Open
daniel64 opened this issue Apr 14, 2023 · 0 comments

Comments

@daniel64
Copy link

Hi,
I've written a a small application using libnethogs. It sometimes loops using 100% CPU when invoked multiple times within the same application (that is, leaving the nethogs screen and going back in, within the same program).

I think I've tracked down the problem - when using high CPU, vector pc_loop_fd_list contains duplicate fd's and so also in pc_loop_fd_set, causing select() in procedure wait_for_next_trigger() to immediately return. I assume these duplicates are from a previous invocation of libnethogs.

I've added pc_loop_fd_list.clear() in procedure nethogsmonitor_init() which seems to have fixed the problem. Perhaps you would kind enough to consider adding this fix. Maybe other static variables also need re-initialising in such circumstances.

Also, is there a way to get messages and errors back from libnethogs via an error buffer/call? At the moment it writes to the screen with cout/cerr/stdout/stderr which kind of messes up the ncurses output.

Regards, Daniel

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

No branches or pull requests

1 participant