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

Loop starvation #255

Open
mildsunrise opened this issue Feb 14, 2020 · 2 comments
Open

Loop starvation #255

mildsunrise opened this issue Feb 14, 2020 · 2 comments

Comments

@mildsunrise
Copy link
Contributor

If I'm not mistaken, this module could starve the loop, because it enters an infinite loop until there's no packets:

node_pcap/pcap_session.cc

Lines 120 to 126 in fb9dfc9

do {
packet_count = pcap_dispatch(session->pcap_handle, 1, PacketReady, (u_char *)session);
if (packet_count == -2) {
FinalizeClose(session);
}
} while (packet_count > 0);

So if packets arrive very fast (or the processing of each one takes a long time), this could block for an arbitrary amount of time. This would be fixed by setting a maximum of packets to read (libuv sets 32) and deferring the next read with a setTimeout if needed.

@jvdassen
Copy link

@mildsunrise
Hello, have you been able to get around this issue?
I'm running into this consistently when using a specific PCAP file and creating an offline session.

@mildsunrise
Copy link
Contributor Author

I see... I only reported this issue because I knew it could theoretically happen.
I'd say this isn't very hard to fix, but unfortunately I have no time to dedicate to this project right now :( Sorry

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

2 participants