Ejemplo n.º 1
0
		public Request (ushort requestID, Connection connection)
		{
			DataNeeded = true;

			RequestID  = requestID;
			this.connection = connection;
		}
Ejemplo n.º 2
0
		/// <summary>
		///    Constructs and initializes a new instance of <see
		///    cref="ResponderRequest" /> with the specified request ID
		///    and connection.
		/// </summary>
		/// <param name="requestID">
		///    A <see cref="ushort" /> containing the request ID of the
		///    new instance.
		/// </param>
		/// <param name="connection">
		///    A <see cref="Connection" /> object from which data is
		///    received and to which data will be sent.
		/// </param>
		public ResponderRequest (ushort requestID,
		                         Connection connection)
			: base (requestID, connection)
		{
			if (!Server.SupportsResponder)
				throw new Exception ();
			
			responder = Server.CreateResponder (this);
			
			InputDataReceived  += OnInputDataReceived;
		}
Ejemplo n.º 3
0
		public void EndConnection (Connection connection)
		{
			backend.EndConnection (new ConnectionProxy (connection));
		}
Ejemplo n.º 4
0
 /// <summary>
 ///    Constructs and initializes a new instance of <see
 ///    cref="Request" /> with the specified request ID and
 ///    connection.
 /// </summary>
 /// <param name="requestID">
 ///    A <see cref="ushort" /> containing the request ID of the
 ///    new instance.
 /// </param>
 /// <param name="connection">
 ///    A <see cref="Connection" /> object from which data is
 ///    received and to which data will be sent.
 /// </param>
 public Request(ushort requestID, Connection connection)
 {
     this.requestID  = requestID;
     this.connection = connection;
 }
Ejemplo n.º 5
0
        private void OnAccept(IAsyncResult ares)
        {
            Logger.Write (LogLevel.Debug, Strings.Server_Accepting);
            Connection connection = null;

            lock (accept_lock) {
                accepting = false;
            }

            try {
                try {
                    Socket accepted = listen_socket.EndAccept (ares);
                    connection = new Connection (accepted, this);
                    lock (connections)
                        connections.Add (connection);
                } catch (System.Net.Sockets.SocketException e) {
                    Logger.Write (LogLevel.Error,
                        Strings.Server_AcceptFailed, e.Message);
                    if (e.ErrorCode == 10022)
                        Stop ();
                } catch (System.ObjectDisposedException) {
                    Logger.Write (LogLevel.Debug, Strings.Server_ConnectionClosed);
                    return; // Already done (e.g., shutdown)
                }

                if (CanAccept)
                    BeginAccept ();
            } catch (System.Exception e) {
                Logger.Write (LogLevel.Error,
                    Strings.Server_AcceptFailed, e.Message);
            }

            if (connection == null)
                return;
            try {
                connection.Run ();
            } catch (System.Exception e) {
                Logger.Write (LogLevel.Error,
                    Strings.Server_ConnectionFailed, e.Message);
                try {
                    // Upon catastrophic failure, forcefully stop
                    // all remaining connection activity, since no
                    // specific error-handling kicked in to rescue
                    // the connection or its requests and the
                    // connection's main loop has now terminated.
                    // This prevents abandoned FastCGI connections
                    // from staying open indefinitely.
                    EndConnection(connection);
                    Logger.Write (LogLevel.Debug, Strings.Server_ConnectionClosed);
                } catch {
                    // Ignore at this point -- too bad
                }
            }
        }
Ejemplo n.º 6
0
        public void EndConnection(Connection connection)
        {
            if (connection == null)
                throw new ArgumentNullException ("connection");

            connection.Stop ();

            lock (connections) {
                if (connections.Contains (connection))
                    connections.Remove (connection);
            }

            if (!accepting && CanAccept)
                BeginAccept ();
        }
Ejemplo n.º 7
0
		public ConnectionProxy (Connection connection)
		{
			if (connection == null)
				throw new ArgumentNullException ("connection");
			this.connection = connection;
		}