[Groonga-commit] groonga/express-kotoumi [master] Close socket to receive when the server is stopped

Back to archive index

YUKI Hiroshi null+****@clear*****
Mon Jan 28 18:33:51 JST 2013


YUKI Hiroshi	2013-01-28 18:33:51 +0900 (Mon, 28 Jan 2013)

  New Revision: 7da260f2a3413f684bf781ca1cadebf8e708a36f
  https://github.com/groonga/express-kotoumi/commit/7da260f2a3413f684bf781ca1cadebf8e708a36f

  Log:
    Close socket to receive when the server is stopped

  Modified files:
    lib/backend/receiver.js

  Modified: lib/backend/receiver.js (+10 -2)
===================================================================
--- lib/backend/receiver.js    2013-01-28 18:24:42 +0900 (c5b2f81)
+++ lib/backend/receiver.js    2013-01-28 18:33:51 +0900 (022165f)
@@ -14,8 +14,9 @@ MsgPackReceiver.prototype._init = function() {
 };
 
 MsgPackReceiver.prototype._onConnect = function(socket) {
-  var messageStream = new msgpack.Stream(socket);
-  messageStream.on('msg', this._onMessageReceive.bind(this));
+  this._socket = socket;
+  this._messageStream = new msgpack.Stream(socket);
+  this._messageStream.on('msg', this._onMessageReceive.bind(this));
 };
 
 MsgPackReceiver.prototype._onMessageReceive = function(data) {
@@ -34,6 +35,13 @@ MsgPackReceiver.prototype.listen = function(callback) {
 };
 
 MsgPackReceiver.prototype.close = function() {
+  if (this._messageStream) {
+    this._messageStream = undefined;
+  }
+  if (this._socket) {
+    this._socket.destroy();
+    this._socket = undefined;
+  }
   if (this._server) {
     this._server.close();
     this._server = undefined;
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index