roster-server 3.0.1 → 3.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +1 -1
- package/lib/isolated-site.js +4 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -985,7 +985,7 @@ class Roster {
|
|
|
985
985
|
socket.setTimeout(0);
|
|
986
986
|
const site = servername && this._isolatedSiteFor(routes, servername);
|
|
987
987
|
if (site) {
|
|
988
|
-
site.handoff(port, head, socket);
|
|
988
|
+
site.handoff(port, head, socket, () => this._sockets.delete(socket));
|
|
989
989
|
return;
|
|
990
990
|
}
|
|
991
991
|
socket.unshift(head);
|
package/lib/isolated-site.js
CHANGED
|
@@ -108,8 +108,10 @@ class IsolatedSite {
|
|
|
108
108
|
|
|
109
109
|
/**
|
|
110
110
|
* Pass an accepted client socket, with the bytes already read from it, to the site process.
|
|
111
|
+
* `onHandedOff` runs once the site process owns the connection; the main process never
|
|
112
|
+
* sees a 'close' event for it.
|
|
111
113
|
*/
|
|
112
|
-
handoff(port, head, socket) {
|
|
114
|
+
handoff(port, head, socket, onHandedOff) {
|
|
113
115
|
const child = this.child;
|
|
114
116
|
if (!this.ready || this.pending >= this.isolation.backlog) {
|
|
115
117
|
socket.destroy();
|
|
@@ -119,6 +121,7 @@ class IsolatedSite {
|
|
|
119
121
|
child.send({ type: 'connection', port, head: head.toString('base64') }, socket, error => {
|
|
120
122
|
if (this.child === child) this.pending--;
|
|
121
123
|
if (error) socket.destroy();
|
|
124
|
+
else onHandedOff();
|
|
122
125
|
});
|
|
123
126
|
}
|
|
124
127
|
|