Permalink
Browse files

Emit an 'empty_read' event on empty read.

This can be useful for detecting when an interface has been unplumbed
out from underneath you, which causes the readWatcher to spin non-stop
(since the fd is constantly reporting data as available).
  • Loading branch information...
1 parent 6c3ff34 commit 3b709ff15703b64f545c635fa86c800fb7ec98c1 @rgulewich committed Jun 6, 2011
Showing with 1 addition and 0 deletions.
  1. +1 −0 pcap.js
View
@@ -58,6 +58,7 @@ Pcap.prototype.open = function (live, device, filter, buffer_size) {
if (packets_read < 1) {
// TODO - figure out what is causing this, and if it is bad.
me.empty_reads += 1;
+ me.emit('empty_read', me.buf);
}
};
this.readWatcher.set(this.fd, true, false);

0 comments on commit 3b709ff

Please sign in to comment.