mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-03-26 23:00:29 -04:00
Merge from vscode fc10e26ea50f82cdd84e9141491357922e6f5fba (#4639)
This commit is contained in:
@@ -10,7 +10,7 @@ import { deepClone, assign } from 'vs/base/common/objects';
|
||||
import { Emitter, Event } from 'vs/base/common/event';
|
||||
import { createQueuedSender } from 'vs/base/node/processes';
|
||||
import { ChannelServer as IPCServer, ChannelClient as IPCClient, IChannelClient } from 'vs/base/parts/ipc/node/ipc';
|
||||
import { isRemoteConsoleLog, log } from 'vs/base/node/console';
|
||||
import { isRemoteConsoleLog, log } from 'vs/base/common/console';
|
||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
import * as errors from 'vs/base/common/errors';
|
||||
import { IChannel } from 'vs/base/parts/ipc/common/ipc';
|
||||
|
||||
@@ -248,6 +248,7 @@ class ProtocolReader {
|
||||
|
||||
class ProtocolWriter {
|
||||
|
||||
private _isDisposed: boolean;
|
||||
private readonly _socket: Socket;
|
||||
private readonly _logFile: number;
|
||||
private _data: Buffer[];
|
||||
@@ -255,6 +256,7 @@ class ProtocolWriter {
|
||||
public lastWriteTime: number;
|
||||
|
||||
constructor(socket: Socket, logFile: number) {
|
||||
this._isDisposed = false;
|
||||
this._socket = socket;
|
||||
this._logFile = logFile;
|
||||
this._data = [];
|
||||
@@ -264,6 +266,7 @@ class ProtocolWriter {
|
||||
|
||||
public dispose(): void {
|
||||
this.flush();
|
||||
this._isDisposed = true;
|
||||
}
|
||||
|
||||
public flush(): void {
|
||||
@@ -272,6 +275,11 @@ class ProtocolWriter {
|
||||
}
|
||||
|
||||
public write(msg: ProtocolMessage) {
|
||||
if (this._isDisposed) {
|
||||
console.warn(`Cannot write message in a disposed ProtocolWriter`);
|
||||
console.warn(msg);
|
||||
return;
|
||||
}
|
||||
if (this._logFile) {
|
||||
log(this._logFile, `send-${ProtocolMessageTypeToString(msg.type)}-${msg.id}-${msg.ack}-`, msg.data);
|
||||
}
|
||||
@@ -373,12 +381,13 @@ export class Protocol implements IDisposable, IMessagePassingProtocol {
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
this._socketWriter.dispose();
|
||||
this._socketReader.dispose();
|
||||
this._socket.removeListener('close', this._socketCloseListener);
|
||||
}
|
||||
|
||||
end(): void {
|
||||
this._socket.end();
|
||||
getSocket(): Socket {
|
||||
return this._socket;
|
||||
}
|
||||
|
||||
send(buffer: Buffer): void {
|
||||
@@ -427,8 +436,9 @@ export class Client<TContext = string> extends IPCClient<TContext> {
|
||||
|
||||
dispose(): void {
|
||||
super.dispose();
|
||||
this.protocol.end();
|
||||
const socket = this.protocol.getSocket();
|
||||
this.protocol.dispose();
|
||||
socket.end();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -800,10 +810,6 @@ export class PersistentProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
end(): void {
|
||||
this._socket.end();
|
||||
}
|
||||
|
||||
readEntireBuffer(): Buffer {
|
||||
return this._socketReader.readEntireBuffer();
|
||||
}
|
||||
|
||||
@@ -143,7 +143,7 @@ class TestChannel implements IServerChannel {
|
||||
|
||||
constructor(private service: ITestService) { }
|
||||
|
||||
call(_, command: string, arg: any, cancellationToken: CancellationToken): Promise<any> {
|
||||
call(_: unknown, command: string, arg: any, cancellationToken: CancellationToken): Promise<any> {
|
||||
switch (command) {
|
||||
case 'marco': return this.service.marco();
|
||||
case 'error': return this.service.error(arg);
|
||||
@@ -154,7 +154,7 @@ class TestChannel implements IServerChannel {
|
||||
}
|
||||
}
|
||||
|
||||
listen(_, event: string, arg?: any): Event<any> {
|
||||
listen(_: unknown, event: string, arg?: any): Event<any> {
|
||||
switch (event) {
|
||||
case 'pong': return this.service.pong;
|
||||
default: throw new Error('not implemented');
|
||||
|
||||
@@ -41,7 +41,7 @@ export class TestChannel implements IServerChannel {
|
||||
|
||||
constructor(private testService: ITestService) { }
|
||||
|
||||
listen(_, event: string): Event<any> {
|
||||
listen(_: unknown, event: string): Event<any> {
|
||||
switch (event) {
|
||||
case 'marco': return this.testService.onMarco;
|
||||
}
|
||||
@@ -49,7 +49,7 @@ export class TestChannel implements IServerChannel {
|
||||
throw new Error('Event not found');
|
||||
}
|
||||
|
||||
call(_, command: string, ...args: any[]): Promise<any> {
|
||||
call(_: unknown, command: string, ...args: any[]): Promise<any> {
|
||||
switch (command) {
|
||||
case 'pong': return this.testService.pong(args[0]);
|
||||
case 'cancelMe': return this.testService.cancelMe();
|
||||
|
||||
Reference in New Issue
Block a user