Skip to content

Commit

Permalink
Fix Redis Store race condition in manager onOpen unsubscribe callback
Browse files Browse the repository at this point in the history
  • Loading branch information
mbrevoort committed Apr 23, 2012
1 parent 9bbf17f commit d9aeaa4
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions lib/manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -343,12 +343,21 @@ Manager.prototype.onConnect = function (id) {
Manager.prototype.onOpen = function (id) {
this.open[id] = true;

// if we were buffering messages for the client, clear them
if (this.closed[id]) {
var self = this;

this.store.unsubscribe('dispatch:' + id, function () {
delete self.closed[id];
var transport = self.transports[id];
if (self.closed[id] && self.closed[id].length && transport) {

// if we have buffered messages that accumulate between calling
// onOpen an this async callback, send them if the transport is
// still open, otherwise leave them buffered
if (transport.open) {
transport.payload(self.closed[id]);
self.closed[id] = [];
}
}
});
}

Expand Down

0 comments on commit d9aeaa4

Please sign in to comment.