void IConnectionControl.End(ProduceEndType endType) { lock (_stateLock) { switch (endType) { case ProduceEndType.ConnectionKeepAlive: if (_connectionState != ConnectionState.Open) { return; } Log.ConnectionKeepAlive(ConnectionId); break; case ProduceEndType.SocketShutdown: case ProduceEndType.SocketDisconnect: if (_connectionState == ConnectionState.Disconnecting || _connectionState == ConnectionState.SocketClosed) { return; } _connectionState = ConnectionState.Disconnecting; Log.ConnectionDisconnect(ConnectionId); _rawSocketOutput.End(endType); break; } } }
void IConnectionControl.End(ProduceEndType endType) { lock (_stateLock) { switch (endType) { case ProduceEndType.SocketShutdownSend: if (_connectionState != ConnectionState.Open) { return; } _connectionState = ConnectionState.Shutdown; KestrelTrace.Log.ConnectionWriteFin(_connectionId, 0); Thread.Post( x => { KestrelTrace.Log.ConnectionWriteFin(_connectionId, 1); var self = (Connection)x; var shutdown = new UvShutdownReq(); shutdown.Init(self.Thread.Loop); shutdown.Shutdown(self._socket, (req, status, state) => { KestrelTrace.Log.ConnectionWriteFin(_connectionId, 1); req.Dispose(); }, null); }, this); break; case ProduceEndType.ConnectionKeepAlive: if (_connectionState != ConnectionState.Open) { return; } KestrelTrace.Log.ConnectionKeepAlive(_connectionId); _frame = new Frame(this); Thread.Post( x => ((Frame)x).Consume(), _frame); break; case ProduceEndType.SocketDisconnect: if (_connectionState == ConnectionState.Disconnected) { return; } _connectionState = ConnectionState.Disconnected; KestrelTrace.Log.ConnectionDisconnect(_connectionId); Thread.Post( x => { KestrelTrace.Log.ConnectionStop(_connectionId); ((UvHandle)x).Dispose(); }, _socket); break; } } }
private void ProduceEnd(ProduceEndType endType) { Action drained = () => { switch (endType) { case ProduceEndType.SocketShutdownSend: _socket.Shutdown(SocketShutdown.Send); break; case ProduceEndType.ConnectionKeepAlive: ThreadPool.QueueUserWorkItem(_ => Go(true, null)); break; case ProduceEndType.SocketDisconnect: _services.Trace.Event(TraceEventType.Stop, TraceMessage.Connection); _baton.Free(); var receiveSocketEvent = Interlocked.Exchange(ref _receiveSocketEvent, null); // this has a race condition if (receiveSocketEvent.Completed == null) { _services.Memory.FreeSocketEvent(receiveSocketEvent); } else { receiveSocketEvent.Completed = () => _services.Memory.FreeSocketEvent(receiveSocketEvent); } _socket.Shutdown(SocketShutdown.Receive); var e = new SocketAsyncEventArgs(); Action cleanup = () => { e.Dispose(); _disconnected(_socket); }; e.Completed += (_, __) => cleanup(); if (!_socket.DisconnectAsync(e)) { cleanup(); } break; } }; if (!_socketSender.Flush(drained)) { drained.Invoke(); } }
void IConnectionControl.End(ProduceEndType endType) { switch (endType) { case ProduceEndType.ConnectionKeepAlive: Log.ConnectionKeepAlive(ConnectionId); break; case ProduceEndType.SocketShutdown: case ProduceEndType.SocketDisconnect: Log.ConnectionDisconnect(ConnectionId); ((SocketOutput)SocketOutput).End(endType); break; } }
void ISocketOutput.End(ProduceEndType endType) { switch (endType) { case ProduceEndType.SocketShutdownSend: Write(default(ArraySegment<byte>), (error, state, calledInline) => { }, null, immediate: true, socketShutdownSend: true, socketDisconnect: false); break; case ProduceEndType.SocketDisconnect: Write(default(ArraySegment<byte>), (error, state, calledInline) => { }, null, immediate: true, socketShutdownSend: false, socketDisconnect: true); break; } }
void ISocketOutput.End(ProduceEndType endType) { switch (endType) { case ProduceEndType.SocketShutdownSend: Write(default(ArraySegment <byte>), (error, state, calledInline) => { }, null, immediate: true, socketShutdownSend: true, socketDisconnect: false); break; case ProduceEndType.SocketDisconnect: Write(default(ArraySegment <byte>), (error, state, calledInline) => { }, null, immediate: true, socketShutdownSend: false, socketDisconnect: true); break; } }
public void End(ProduceEndType endType) { switch (endType) { case ProduceEndType.SocketShutdownSend: WriteAsync(default(ArraySegment <byte>), immediate: true, socketShutdownSend: true, socketDisconnect: false); break; case ProduceEndType.SocketDisconnect: WriteAsync(default(ArraySegment <byte>), immediate: true, socketShutdownSend: false, socketDisconnect: true); break; } }
void IConnectionControl.End(ProduceEndType endType) { switch (endType) { case ProduceEndType.SocketShutdownSend: KestrelTrace.Log.ConnectionWriteFin(_connectionId, 0); Thread.Post( x => { KestrelTrace.Log.ConnectionWriteFin(_connectionId, 1); var self = (Connection)x; var shutdown = new UvShutdownReq(); shutdown.Init(self.Thread.Loop); shutdown.Shutdown(self._socket, (req, status, state) => { KestrelTrace.Log.ConnectionWriteFin(_connectionId, 1); req.Dispose(); }, null); }, this); break; case ProduceEndType.ConnectionKeepAlive: KestrelTrace.Log.ConnectionKeepAlive(_connectionId); _frame = new Frame(this); Thread.Post( x => ((Frame)x).Consume(), _frame); break; case ProduceEndType.SocketDisconnect: KestrelTrace.Log.ConnectionDisconnect(_connectionId); Thread.Post( x => { KestrelTrace.Log.ConnectionStop(_connectionId); ((UvHandle)x).Dispose(); }, _socket); break; } }
public void End(ProduceEndType produceEndType) { if (produceEndType == ProduceEndType.SocketShutdownSend) { ShutdownSend = true; } else { Ended = true; } if (produceEndType == ProduceEndType.ConnectionKeepAlive) { KeepAlive = true; } else if (produceEndType == ProduceEndType.SocketDisconnect) { KeepAlive = false; } }
public void End(ProduceEndType endType) { switch (endType) { case ProduceEndType.SocketShutdown: WriteAsync(default(ArraySegment <byte>), default(CancellationToken), socketShutdownSend: true, socketDisconnect: true, isSync: true); break; case ProduceEndType.SocketDisconnect: WriteAsync(default(ArraySegment <byte>), default(CancellationToken), socketShutdownSend: false, socketDisconnect: true, isSync: true); break; } }
void IConnectionControl.End(ProduceEndType endType) { lock (_stateLock) { switch (endType) { case ProduceEndType.SocketShutdownSend: if (_connectionState != ConnectionState.Open) { return; } _connectionState = ConnectionState.Shutdown; Log.ConnectionWriteFin(_connectionId); SocketOutput.End(endType); break; case ProduceEndType.ConnectionKeepAlive: if (_connectionState != ConnectionState.Open) { return; } Log.ConnectionKeepAlive(_connectionId); break; case ProduceEndType.SocketDisconnect: if (_connectionState == ConnectionState.Disconnected) { return; } _connectionState = ConnectionState.Disconnected; Log.ConnectionDisconnect(_connectionId); SocketOutput.End(endType); break; } } }
public void End(ProduceEndType endType) { }
public void End(ProduceEndType endType) { switch (endType) { case ProduceEndType.SocketShutdownSend: WriteAsync(default(ArraySegment<byte>), immediate: true, socketShutdownSend: true, socketDisconnect: false); break; case ProduceEndType.SocketDisconnect: WriteAsync(default(ArraySegment<byte>), immediate: true, socketShutdownSend: false, socketDisconnect: true); break; } }