コード例 #1
0
ファイル: Connection.cs プロジェクト: Bhanditz/xsp
        public void EndRequest(ushort requestID, int appStatus,
                               ProtocolStatus protocolStatus)
        {
            EndRequestBody body = new EndRequestBody(appStatus,
                                                     protocolStatus);

            if (IsConnected)
            {
                new Record(1, RecordType.EndRequest, requestID,
                           body.GetData()).Send(socket);
            }

            int index = GetRequestIndex(requestID);

            if (index >= 0)
            {
                lock (request_lock) {
                    requests.RemoveAt(index);
                }
            }

            if (requests.Count == 0 && (!keep_alive || stop))
            {
                socket.Close();
                server.EndConnection(this);
                server.ReleaseBuffers(receive_buffer,
                                      send_buffer);
            }
        }
コード例 #2
0
        public void EndRequest(ushort requestID, int appStatus,
                               ProtocolStatus protocolStatus)
        {
            var body = new EndRequestBody(appStatus, protocolStatus);

            try {
                if (IsConnected)
                {
                    byte[] bodyData = body.GetData();
                    CompatArraySegment <byte> bodyBuffer = send_buffers.EnforceBodyLength(bodyData.Length);
                    Array.Copy(bodyData, 0, bodyBuffer.Array, bodyBuffer.Offset, bodyData.Length);
                    var record = new NRecord(1, RecordType.EndRequest, requestID, bodyData.Length, send_buffers);
                    record.Send(socket);
                }
            } catch (System.Net.Sockets.SocketException) {
            }

            RemoveRequest(requestID);

            lock (connection_teardown_lock) {
                if (requests.Count == 0 && (!keep_alive || stop))
                {
                    CloseSocket();

                    if (!stop)
                    {
                        server.EndConnection(this);
                    }

                    receive_buffers.Return();
                    send_buffers.Return();
                }
            }
        }
コード例 #3
0
        public void EndRequest(ushort requestID, int appStatus,
                               ProtocolStatus protocolStatus)
        {
            EndRequestBody body = new EndRequestBody(appStatus,
                                                     protocolStatus);

            try {
                if (IsConnected)
                {
                    new Record(1, RecordType.EndRequest, requestID,
                               body.GetData()).Send(socket);
                }
            } catch (System.Net.Sockets.SocketException) {
            }


            int index = GetRequestIndex(requestID);

            if (index >= 0)
            {
                lock (request_lock) {
                    requests.RemoveAt(index);
                }
            }

            lock (connection_teardown_lock) {
                if (requests.Count == 0 && (!keep_alive || stop))
                {
                    if (socket != null)
                    {
                        try {
                            socket.Close();
                        } finally {
                            socket = null;
                        }
                    }

                    if (!stop)
                    {
                        server.EndConnection(this);
                    }
                    if (receive_buffer != null && send_buffer != null)
                    {
                        server.ReleaseBuffers(receive_buffer, send_buffer);
                        receive_buffer = null;
                        send_buffer    = null;
                    }
                }
            }
        }
コード例 #4
0
ファイル: Connection.cs プロジェクト: louislatreille/xsp
		public void EndRequest (ushort requestID, int appStatus,
		                        ProtocolStatus protocolStatus)
		{
			var body = new EndRequestBody (appStatus, protocolStatus);
			try {	
				if (IsConnected) {
					byte[] bodyData = body.GetData ();
					CompatArraySegment<byte> bodyBuffer = send_buffers.EnforceBodyLength(bodyData.Length);
					Array.Copy(bodyData, 0, bodyBuffer.Array, bodyBuffer.Offset, bodyData.Length);
					var record = new NRecord (1, RecordType.EndRequest, requestID, bodyData.Length, send_buffers);
					record.Send (socket);
				}
			} catch (System.Net.Sockets.SocketException) {
			}
				
			RemoveRequest(requestID);	

			lock (connection_teardown_lock) {
				if (requests.Count == 0 && (!keep_alive || stop)) {
					CloseSocket ();

					if (!stop)
						server.EndConnection (this);

					receive_buffers.Return ();
					send_buffers.Return ();
				}
			}
		}
コード例 #5
0
ファイル: Connection.cs プロジェクト: vietnt/xsp
        /// <summary>
        ///    Sends an EndRequest record with a specified request ID,
        ///    application status, and protocol status, and releases the
        ///    associated resources.
        /// </summary>
        /// <param name="requestID">
        ///    A <see cref="ushort" /> containing the ID of the request
        ///    to end.
        /// </param>
        /// <param name="appStatus">
        ///    <para>A <see cref="int" /> containing the application
        ///    status the request ended with.</para>
        ///    <para>This is the same value as would be returned by a
        ///    program on termination. On successful termination, this
        ///    would be zero.</para>
        /// </param>
        /// <param name="protocolStatus">
        ///    A <see cref="ProtocolStatus" /> containing the FastCGI
        ///    protocol status with which the request is being ended.
        /// </param>
        public void EndRequest(ushort requestID, int appStatus,
		                        ProtocolStatus protocolStatus)
        {
            EndRequestBody body = new EndRequestBody (appStatus,
                protocolStatus);

            if (IsConnected)
                new Record (1, RecordType.EndRequest, requestID,
                    body.GetData ()).Send (socket);

            int index = GetRequestIndex (requestID);

            if (index >= 0) {
                lock (request_lock) {
                    requests.RemoveAt (index);
                }
            }

            if (requests.Count == 0 && (!keep_alive || stop)) {
                socket.Close ();
                server.EndConnection (this);
                server.ReleaseBuffers (receive_buffer,
                    send_buffer);
            }
        }
コード例 #6
0
ファイル: Connection.cs プロジェクト: ryepup/xsp
        public void EndRequest(ushort requestID, int appStatus,
		                        ProtocolStatus protocolStatus)
        {
            var body = new EndRequestBody (appStatus, protocolStatus);
            try {
                if (IsConnected)
                    new Record (1, RecordType.EndRequest, requestID,
                            body.GetData ()).Send (socket);
            } catch (System.Net.Sockets.SocketException) {
            }

            int index = GetRequestIndex (requestID);

            if (index >= 0) {
                lock (request_lock) {
                    requests.RemoveAt (index);
                }
            }

            lock (connection_teardown_lock) {
                if (requests.Count == 0 && (!keep_alive || stop)) {
                    if (socket != null) {
                        try {
                            socket.Close ();
                        } finally {
                            socket = null;
                        }
                    }

                    if (!stop)
                        server.EndConnection (this);
                    if (receive_buffer != null && send_buffer != null) {
                        server.ReleaseBuffers (receive_buffer, send_buffer);
                        receive_buffer = null;
                        send_buffer = null;
                    }
                }
            }
        }
コード例 #7
0
ファイル: Connection.cs プロジェクト: symform/xsp
        public void EndRequest(ushort requestID, int appStatus,
		                        ProtocolStatus protocolStatus)
        {
            var body = new EndRequestBody (appStatus, protocolStatus);
            try {
                if (IsConnected) {
                    byte[] bodyData = body.GetData ();
                    send_buffers.EnforceBodyLength(bodyData.Length);
                    Array.Copy(bodyData, 0, send_buffers.Body.Value.Array, send_buffers.Body.Value.Offset, bodyData.Length);
                    var record = new Record (1, RecordType.EndRequest, requestID, send_buffers, bodyData.Length);
                    record.Send (socket);
                }
            } catch (System.Net.Sockets.SocketException) {
            }

            int index = GetRequestIndex (requestID);

            if (index >= 0) {
                lock (request_lock) {
                    requests.RemoveAt (index);
                }
            }

            lock (connection_teardown_lock) {
                if (requests.Count == 0 && (!keep_alive || stop)) {
                    CloseSocket ();

                    if (!stop)
                        server.EndConnection (this);

                    receive_buffers.Return ();
                    send_buffers.Return ();
                }
            }
        }