Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: InstantWebP2P/wspp
base: a07853d113
...
head fork: InstantWebP2P/wspp
compare: 27af9b7a70
  • 5 commits
  • 2 files changed
  • 0 commit comments
  • 4 contributors
Commits on Jan 24, 2013
@jmatthewsr-ms jmatthewsr-ms Fix for retaining large slab buffers in node core f44e826
Commits on Apr 05, 2013
@3rd-Eden 3rd-Eden Emit the close event before destroying the internal _socket
This way we can still read out the bytesRead and bytesSend from the socket when it
closes the connections. This can be useful for metrics collection etc.
077d3de
Commits on Apr 09, 2013
@einaros einaros Merge pull request #176 from 3rd-Eden/master
Emit the close event before destroying the internal _socket
fa6b323
@einaros einaros Merge pull request #153 from jmatthewsr-ms/master
Fix for slab buffer retention, leading to large memory consumption
6a6b4ef
tom zhou sync to ws upstream 27af9b7
Showing with 11 additions and 8 deletions.
  1. +6 −7 lib/WebSocket.js
  2. +5 −1 lib/WebSocketServer.js
View
13 lib/WebSocket.js
@@ -410,7 +410,6 @@ function initAsClient(address, options) {
protocolVersion: protocolVersion,
host: null,
protocol: null,
-
// ssl-related options
pfx: null,
key: null,
@@ -480,7 +479,7 @@ function initAsClient(address, options) {
if (isNodeV4) {
throw new Error('Client side certificates are not supported on Node 0.4.x');
}
-
+
requestOptions.pfx = options.value.pfx;
requestOptions.key = options.value.key;
requestOptions.passphrase = options.value.passphrase;
@@ -488,20 +487,20 @@ function initAsClient(address, options) {
requestOptions.ca = options.value.ca;
requestOptions.ciphers = options.value.ciphers;
requestOptions.rejectUnauthorized = options.value.rejectUnauthorized;
-
+
// global agent ignores client side certificates
agent = new httpObj.Agent(requestOptions);
}
-
+
if (isNodeV4) {
requestOptions.path = (serverUrl.pathname || '/') + (serverUrl.search || '');
}
else requestOptions.path = serverUrl.path || '/';
-
+
if (agent) {
requestOptions.agent = agent;
}
-
+
if (isUnixSocket) {
requestOptions.socketPath = serverUrl.pathname;
}
@@ -678,6 +677,7 @@ function cleanupWebsocketResources(error) {
this.readyState = WebSocket.CLOSED;
clearTimeout(this._closeTimer);
+ if (emitClose) this.emit('close', this._closeCode || 1000, this._closeMessage || '');
if (this._socket) {
removeAllListeners(this._socket);
@@ -701,7 +701,6 @@ function cleanupWebsocketResources(error) {
this._receiver.cleanup();
this._receiver = null;
}
- if (emitClose) this.emit('close', this._closeCode || 1000, this._closeMessage || '');
removeAllListeners(this);
this.on('error', function() {}); // catch all errors after this
delete this._queue;
View
6 lib/WebSocketServer.js
@@ -84,7 +84,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);
});

No commit comments for this range

Something went wrong with that request. Please try again.