Permalink
Browse files

remove streams from reconnect cache when they close

  • Loading branch information...
1 parent 2c60d04 commit 98aa4ea33bed7e2dbfd55c1b0ec07ff9e9db5ce2 @Raynos committed Aug 11, 2012
Showing with 12 additions and 2 deletions.
  1. +12 −2 browser.js
View
@@ -100,15 +100,25 @@ function reconnecter(uri) {
end: false
})
- metaStreams.push({
+ var index = metaStreams.push({
proxy: proxy
, proxyMdmRead: proxyMdmRead
, proxyMdmWrite: proxyMdmWrite
, meta: meta
, opts: opts
})
- stream.once("end", mdm.end.bind(mdm))
+ mdm.on("end", removeFromCache)
+ stream.once("end", cleanup)
+
+ function cleanup() {
+ mdm.removeListener("end", removeFromCache)
+ mdm.end()
+ }
+
+ function removeFromCache() {
+ metaStreams.splice(index, 1)
+ }
return proxy
}

0 comments on commit 98aa4ea

Please sign in to comment.