chore(xen-api/signals): not disconnected when connecting

This commit is contained in:
Julien Fontanet 2019-03-29 15:27:37 +01:00
parent d9e42c6625
commit d57fa4375d

View File

@ -234,6 +234,9 @@ export class Xapi extends EventEmitter {
const auth = this._auth const auth = this._auth
this._sessionId = CONNECTING this._sessionId = CONNECTING
this._disconnected = new Promise(resolve => {
this._resolveDisconnected = resolve
})
try { try {
const [methods, sessionId] = await Promise.all([ const [methods, sessionId] = await Promise.all([
@ -260,9 +263,6 @@ export class Xapi extends EventEmitter {
this._pool = (await this.getAllRecords('pool'))[0] this._pool = (await this.getAllRecords('pool'))[0]
debug('%s: connected', this._humanId) debug('%s: connected', this._humanId)
this._disconnected = new Promise(resolve => {
this._resolveDisconnected = resolve
})
this._resolveConnected() this._resolveConnected()
this._resolveConnected = undefined this._resolveConnected = undefined
this.emit(CONNECTED) this.emit(CONNECTED)
@ -284,9 +284,6 @@ export class Xapi extends EventEmitter {
this._connected = new Promise(resolve => { this._connected = new Promise(resolve => {
this._resolveConnected = resolve this._resolveConnected = resolve
}) })
this._resolveDisconnected()
this._resolveDisconnected = undefined
} else { } else {
assert(status === CONNECTING) assert(status === CONNECTING)
} }
@ -300,6 +297,8 @@ export class Xapi extends EventEmitter {
debug('%s: disconnected', this._humanId) debug('%s: disconnected', this._humanId)
this.emit(DISCONNECTED) this.emit(DISCONNECTED)
this._resolveDisconnected()
this._resolveDisconnected = undefined
} }
// =========================================================================== // ===========================================================================