Skip to content
Browse files

Fix Redis Store race condition in manager onOpen unsubscribe callback

  • Loading branch information...
1 parent 9bbf17f commit d9aeaa494f901e9a187c72eabec638d16a690686 @mbrevoort mbrevoort committed Apr 23, 2012
Showing with 11 additions and 2 deletions.
  1. +11 −2 lib/manager.js
View
13 lib/manager.js
@@ -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] = [];
+ }
+ }
});
}

0 comments on commit d9aeaa4

Please sign in to comment.
Something went wrong with that request. Please try again.