Browse Source

graceful destroy

v4
David Mark Clements 5 years ago
committed by Mathias Buus
parent
commit
eb2c7e0a8d
  1. 1
      index.js
  2. 1
      lib/io.js

1
index.js

@ -171,6 +171,7 @@ class DHT extends EventEmitter {
} }
destroy () { destroy () {
if (this.destroyed) return
this.destroyed = true this.destroyed = true
this._io.destroy() this._io.destroy()
clearInterval(this._tickInterval) clearInterval(this._tickInterval)

1
lib/io.js

@ -201,6 +201,7 @@ class IO {
} }
send (buffer, peer) { send (buffer, peer) {
if (this._ctx.destroyed) return
this.socket.send(buffer, 0, buffer.length, peer.port, peer.host) this.socket.send(buffer, 0, buffer.length, peer.port, peer.host)
} }

Loading…
Cancel
Save