示例#1
0
        private void Run()
        {
            this.unix_listener.Start();

            if (!Shutdown.WorkerStart(this, String.Format("server '{0}'", socket_path)))
            {
                return;
            }

            while (this.running)
            {
                UnixClient client;
                try {
                    // This will block for an incoming connection.
                    // FIXME: But not really, it'll only wait a second.
                    // see the FIXME in UnixListener for more info.
                    client = this.unix_listener.AcceptUnixClient();
                } catch (SocketException) {
                    // If the listener is stopped while we
                    // wait for a connection, a
                    // SocketException is thrown.
                    break;
                }

                // FIXME: This is a hack to work around a mono
                // bug.  See the FIXMEs in UnixListener.cs for
                // more info, but client should never be null,
                // because AcceptUnixClient() should be
                // throwing a SocketException when the
                // listener is shut down.  So when that is
                // fixed, remove the if conditional.

                // If client is null, the socket timed out.
                if (client != null)
                {
                    ConnectionHandler handler = new UnixConnectionHandler(client);
                    lock (live_handlers)
                        live_handlers [handler] = handler;
                    ExceptionHandlingThread.Start(new ThreadStart(handler.HandleConnection));
                }
            }

            Shutdown.WorkerFinished(this);

            Logger.Log.Debug("Server '{0}' shut down", this.socket_path);
        }
示例#2
0
		private void Run ()
		{
			this.unix_listener.Start ();

			if (! Shutdown.WorkerStart (this, String.Format ("server '{0}'", socket_path)))
				return;

			while (this.running) {
				UnixClient client;
				try {
					// This will block for an incoming connection.
					// FIXME: But not really, it'll only wait a second.
					// see the FIXME in UnixListener for more info.
					client = this.unix_listener.AcceptUnixClient ();
				} catch (SocketException) {
					// If the listener is stopped while we
					// wait for a connection, a
					// SocketException is thrown.
					break;
				}

				// FIXME: This is a hack to work around a mono
				// bug.  See the FIXMEs in UnixListener.cs for
				// more info, but client should never be null,
				// because AcceptUnixClient() should be
				// throwing a SocketException when the
				// listener is shut down.  So when that is
				// fixed, remove the if conditional.

				// If client is null, the socket timed out.
				if (client != null) {
					ConnectionHandler handler = new UnixConnectionHandler (client);
					lock (live_handlers)
						live_handlers [handler] = handler;
					ExceptionHandlingThread.Start (new ThreadStart (handler.HandleConnection));
				}
			}

			Shutdown.WorkerFinished (this);

			Logger.Log.Debug ("Server '{0}' shut down", this.socket_path);
		}