Fix potential memory leaks on realtime client disconnect not clean up server properly

This commit is contained in:
Wu Cheng-Han 2016-07-13 10:41:49 +08:00
parent cb75424f8e
commit b3ba512cea

View file

@ -478,6 +478,7 @@ function disconnect(socket) {
if (note.server.isDirty) { if (note.server.isDirty) {
updateNote(note, function (err, _note) { updateNote(note, function (err, _note) {
if (err) return logger.error('disconnect note failed: ' + err); if (err) return logger.error('disconnect note failed: ' + err);
delete note.server;
delete notes[noteId]; delete notes[noteId];
if (config.debug) { if (config.debug) {
//logger.info(notes); //logger.info(notes);
@ -487,6 +488,7 @@ function disconnect(socket) {
} }
}); });
} else { } else {
delete note.server;
delete notes[noteId]; delete notes[noteId];
} }
} }