示例#1
0
        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;
            }
        }
示例#2
0
            /// <summary>
            /// Second step: initiate async shutdown if needed, otherwise go to next step
            /// </summary>
            public void DoShutdownIfNeeded()
            {
                if (SocketShutdownSend == false || Self._socket.IsClosed)
                {
                    DoDisconnectIfNeeded();
                    return;
                }

                var shutdownReq = new UvShutdownReq(Self._log);

                shutdownReq.Init(Self._thread.Loop);
                shutdownReq.Shutdown(Self._socket, (_shutdownReq, status, state) =>
                {
                    _shutdownReq.Dispose();
                    var _this = (WriteContext)state;
                    _this.ShutdownSendStatus = status;

                    Self._log.ConnectionWroteFin(Self._connectionId, status);

                    DoDisconnectIfNeeded();
                }, this);
            }
示例#3
0
            /// <summary>
            /// Second step: initiate async shutdown if needed, otherwise go to next step
            /// </summary>
            public void DoShutdownIfNeeded()
            {
                if (SocketShutdownSend == false || Self._socket.IsClosed)
                {
                    DoDisconnectIfNeeded();
                    return;
                }

                //Self._log.ConnectionWriteFin(Self._connectionId);

                var shutdownReq = new UvShutdownReq();

                shutdownReq.Init(Self._thread.Loop);
                shutdownReq.Shutdown(Self._socket, (req, status, state) =>
                {
                    req.Dispose();

                    var writeContext = (WriteContext)state;
                    //writeContext.Self._log.ConnectionWroteFin(writeContext.Self._connectionId, status);
                    writeContext.DoDisconnectIfNeeded();
                }, this);
            }