_slave is on _mutex on channel
This commit is contained in:
parent
1387b060a4
commit
e0178e41ed
8
index.js
8
index.js
|
@ -51,7 +51,7 @@ class Channel {
|
||||||
}
|
}
|
||||||
|
|
||||||
async open(handshake) {
|
async open(handshake) {
|
||||||
if (this._slave) {
|
if (this._mux._slave) {
|
||||||
await this._mux.pullLocal();
|
await this._mux.pullLocal();
|
||||||
await this._mux.pullFree();
|
await this._mux.pullFree();
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ class Channel {
|
||||||
this._localId = id + 1;
|
this._localId = id + 1;
|
||||||
this._mux._local[id] = this;
|
this._mux._local[id] = this;
|
||||||
|
|
||||||
if (this._slave) {
|
if (this._mux._slave) {
|
||||||
if (freeLen > 0) {
|
if (freeLen > 0) {
|
||||||
await this._mux.popFree(id);
|
await this._mux.popFree(id);
|
||||||
} else {
|
} else {
|
||||||
|
@ -153,14 +153,14 @@ class Channel {
|
||||||
if (this._remoteId > 0) {
|
if (this._remoteId > 0) {
|
||||||
this._mux._remote[this._remoteId - 1] = null;
|
this._mux._remote[this._remoteId - 1] = null;
|
||||||
this._remoteId = 0;
|
this._remoteId = 0;
|
||||||
if (this._slave) {
|
if (this._mux._slave) {
|
||||||
await this._mux.pullFree();
|
await this._mux.pullFree();
|
||||||
}
|
}
|
||||||
// If remote has acked, we can reuse the local id now
|
// If remote has acked, we can reuse the local id now
|
||||||
// otherwise, we need to wait for the "ack" to arrive
|
// otherwise, we need to wait for the "ack" to arrive
|
||||||
this._mux._free.push(this._localId - 1);
|
this._mux._free.push(this._localId - 1);
|
||||||
|
|
||||||
if (this._slave) {
|
if (this._mux._slave) {
|
||||||
await this._mux.pushFree(this._localId - 1);
|
await this._mux.pushFree(this._localId - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in New Issue