Permalink
Browse files

Stop the IOWatcher after closing the pcap session.

  • Loading branch information...
rgulewich committed Jun 6, 2011
1 parent 318162b commit 6c3ff3470a59f9c5e79e132ce8ced4fdb43170a3
Showing with 7 additions and 2 deletions.
  1. +6 −0 pcap.js
  2. +1 −2 pcap_binding.cc
View
@@ -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) {
View
@@ -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();
}
@@ -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);

0 comments on commit 6c3ff34

Please sign in to comment.