Fix build script
[senf.git] / Console / Server.cc
index 310e341..3ef80ba 100644 (file)
@@ -83,27 +83,18 @@ senf::console::Server::start(senf::INet6SocketAddress const & address)
     return server;
 }
 
-prefix_ boost::scoped_ptr<senf::console::Server> & senf::console::Server::instancePtr()
-{
-    // We cannot make 'instance' a global or class-static variable, since it will then be destructed
-    // at an unknown time which may fail if the scheduler or the file-handle pool allocators have
-    // already been destructed.
-    static boost::scoped_ptr<senf::console::Server> instance;
-    return instance;
-}
-
 prefix_ senf::console::Server & senf::console::Server::start(ServerHandle handle)
 {
     // Uah .... ensure the scheduler is created before the instance pointer so it get's destructed
     // AFTER it.
     (void) senf::Scheduler::instance();
-    SENF_ASSERT( ! instancePtr() );
-    instancePtr().reset(new Server(handle));
-    return * instancePtr();
+    boost::intrusive_ptr<Server> p (new Server(handle));
+    detail::ServerManager::add(boost::intrusive_ptr<Server>(p));
+    return *p;
 }
 
 prefix_ senf::console::Server::Server(ServerHandle handle)
-    : handle_ (handle), mode_ (Automatic)
+    : handle_ (handle), root_ (senf::console::root().thisptr()), mode_ (Automatic)
 {
     Scheduler::instance().add( handle_, senf::membind(&Server::newClient, this) );
 }
@@ -113,7 +104,7 @@ prefix_ senf::console::Server::~Server()
     Scheduler::instance().remove(handle_);
 }
 
-prefix_ void senf::console::Server::newClient(Scheduler::EventId event)
+prefix_ void senf::console::Server::newClient(int event)
 {
     ServerHandle::ClientSocketHandle client (handle_.accept());
     boost::intrusive_ptr<Client> p (new Client(*this, client));
@@ -209,7 +200,7 @@ prefix_ void senf::console::detail::NoninteractiveClientReader::v_translate(std:
 {}
 
 prefix_ void
-senf::console::detail::NoninteractiveClientReader::newData(senf::Scheduler::EventId event)
+senf::console::detail::NoninteractiveClientReader::newData(int event)
 {
     if (event != senf::Scheduler::EV_READ || handle().eof()) {
         if (! buffer_.empty())
@@ -238,6 +229,7 @@ prefix_ senf::console::Client::Client(Server & server, ClientHandle handle)
       name_ (server.name()), reader_ (), mode_ (server.mode())
 {
     handle_.facet<senf::TCPSocketProtocol>().nodelay();
+    executor_.chroot(root());
     switch (mode_) {
     case Server::Interactive :
         setInteractive();
@@ -254,7 +246,6 @@ prefix_ senf::console::Client::Client(Server & server, ClientHandle handle)
 
 prefix_ void senf::console::Client::setInteractive()
 {
-    SENF_LOG(("Set client interactive"));
     binding_.disable();
     timer_.disable();
     mode_ = Server::Interactive;
@@ -264,7 +255,6 @@ prefix_ void senf::console::Client::setInteractive()
 
 prefix_ void senf::console::Client::setNoninteractive()
 {
-    SENF_LOG(("Set client non-interactive"));
     binding_.disable();
     timer_.disable();
     mode_ = Server::Noninteractive;
@@ -279,8 +269,6 @@ prefix_ void senf::console::Client::translate(std::string & data)
 prefix_ std::string::size_type senf::console::Client::handleInput(std::string data,
                                                                   bool incremental)
 {
-    SENF_LOG(("Data: " << data));
-    
     if (data.empty() && ! incremental)
         data = lastCommand_;
     else