Fix socket disconnect might interrupt loop issue

This commit is contained in:
Wu Cheng-Han 2016-10-14 17:36:04 +08:00
parent 211d25253e
commit 1418b7a801

View file

@ -97,7 +97,9 @@ var updater = setInterval(function () {
for (var i = 0, l = note.socks.length; i < l; i++) {
var sock = note.socks[i];
if (typeof sock !== 'undefined' && sock) {
setTimeout(function () {
sock.disconnect(true);
}, 0);
}
}
return callback(err, null);
@ -787,7 +789,9 @@ function connection(socket) {
sock.emit('info', {
code: 403
});
return sock.disconnect(true);
setTimeout(function () {
sock.disconnect(true);
}, 0);
}
}
}
@ -818,7 +822,9 @@ function connection(socket) {
var sock = note.socks[i];
if (typeof sock !== 'undefined' && sock) {
sock.emit('delete');
return sock.disconnect(true);
setTimeout(function () {
sock.disconnect(true);
}, 0);
}
}
}).catch(function (err) {