예제 #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
		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 ();
                }
            }
        }