private void Abort(TraceEventType traceEventType, string timeoutErrorString) { lock (this.ThisLock) { if (this.closeState != Microsoft.ServiceBus.Channels.SocketConnection.CloseState.Closed) { this.timeoutErrorString = timeoutErrorString; this.aborted = true; this.closeState = Microsoft.ServiceBus.Channels.SocketConnection.CloseState.Closed; if (!this.asyncReadPending) { this.DisposeReadEventArgs(); } else { this.CancelReceiveTimer(); } if (this.asyncWritePending) { this.CancelSendTimer(); } } else { return; } } this.TraceSocketInfo(this.socket, TraceCode.SocketConnectionAbort, timeoutErrorString); this.socket.Close(0); }
public SocketConnection(Socket socket, int asyncReadBufferSize, EventTraceActivity activity) { if (socket == null) { throw Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("socket"); } this.closeState = Microsoft.ServiceBus.Channels.SocketConnection.CloseState.Open; this.exceptionEventType = TraceEventType.Warning; this.Activity = activity; this.socket = socket; this.readBuffer = Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.Utility.AllocateByteArray(asyncReadBufferSize); Socket socket1 = this.socket; Socket socket2 = this.socket; int num = Math.Max(524288, asyncReadBufferSize); int num1 = num; socket2.SendBufferSize = num; socket1.ReceiveBufferSize = num1; TimeSpan maxValue = TimeSpan.MaxValue; TimeSpan timeSpan = maxValue; this.receiveTimeout = maxValue; this.sendTimeout = timeSpan; this.asyncReadBufferSize = asyncReadBufferSize; this.TraceSocketInfo(socket, TraceCode.SocketConnectionCreate, null); }
private void ContinueClose(TimeSpan timeout) { if (timeout <= TimeSpan.Zero && Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.ShouldTraceWarning) { TraceUtility.TraceEvent(TraceEventType.Warning, TraceCode.SocketConnectionAbortClose, this); } this.socket.Close(Microsoft.ServiceBus.Common.TimeoutHelper.ToMilliseconds(timeout)); lock (this.ThisLock) { if (!this.asyncReadPending && this.closeState != Microsoft.ServiceBus.Channels.SocketConnection.CloseState.Closed && !this.asyncReadPending) { this.DisposeReadEventArgs(); } this.closeState = Microsoft.ServiceBus.Channels.SocketConnection.CloseState.Closed; } }
public void Close(TimeSpan timeout) { lock (this.ThisLock) { if (this.closeState == Microsoft.ServiceBus.Channels.SocketConnection.CloseState.Closing || this.closeState == Microsoft.ServiceBus.Channels.SocketConnection.CloseState.Closed) { return; } else { this.TraceSocketInfo(this.socket, TraceCode.SocketConnectionClose, timeout.ToString()); this.closeState = Microsoft.ServiceBus.Channels.SocketConnection.CloseState.Closing; } } this.closeTimeoutHelper = new Microsoft.ServiceBus.Common.TimeoutHelper(timeout); this.Shutdown(this.closeTimeoutHelper.RemainingTime()); this.CloseSync(); }