Permalink
Browse files

Merge pull request #153 from jmatthewsr-ms/master

Fix for slab buffer retention, leading to large memory consumption
  • Loading branch information...
2 parents fa6b323 + f44e826 commit 6a6b4ef4df6ab4459659849820c2f95f23c067d6 @einaros einaros committed Apr 9, 2013
Showing with 5 additions and 1 deletion.
  1. +5 −1 lib/WebSocketServer.js
View
@@ -64,7 +64,11 @@ function WebSocketServer(options, callback) {
self.emit('error', error)
});
this._server.on('upgrade', function(req, socket, upgradeHead) {
- self.handleUpgrade(req, socket, upgradeHead, function(client) {
+ //copy upgradeHead to avoid retention of large slab buffers used in node core
+ var head = new Buffer(upgradeHead.length);
+ upgradeHead.copy(head);
+
+ self.handleUpgrade(req, socket, head, function(client) {
self.emit('connection'+req.url, client);
self.emit('connection', client);
});

0 comments on commit 6a6b4ef

Please sign in to comment.