Skip to content

Commit

Permalink
Stop the IOWatcher after closing the pcap session.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rob Gulewich committed Jun 6, 2011
1 parent 318162b commit 6c3ff34
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 6 additions & 0 deletions pcap.js
Expand Up @@ -64,6 +64,12 @@ Pcap.prototype.open = function (live, device, filter, buffer_size) {
this.readWatcher.start();
};

Pcap.prototype.close = function () {
this._close();
this.readWatcher.stop();
// TODO - remove listeners so program will exit I guess?
};

exports.Pcap = Pcap;

exports.createSession = function (device, filter, buffer_size) {
Expand Down
3 changes: 1 addition & 2 deletions pcap_binding.cc
Expand Up @@ -344,7 +344,6 @@ Pcap::Close(const Arguments& args)

pcap_close(pcap->pcap_handle);
pcap->opened = false;
// TODO - remove listeners so program will exit I guess?

return Undefined();
}
Expand Down Expand Up @@ -472,7 +471,7 @@ void Pcap::Initialize(Handle<Object> target) {
NODE_SET_PROTOTYPE_METHOD(t, "dispatch", Dispatch);
NODE_SET_PROTOTYPE_METHOD(t, "fileno", FileNo);
NODE_SET_PROTOTYPE_METHOD(t, "link_type", LinkType);
NODE_SET_PROTOTYPE_METHOD(t, "close", Close);
NODE_SET_PROTOTYPE_METHOD(t, "_close", Close);
NODE_SET_PROTOTYPE_METHOD(t, "stats", Stats);
NODE_SET_PROTOTYPE_METHOD(t, "default_device", DefaultDevice);

Expand Down

0 comments on commit 6c3ff34

Please sign in to comment.