myserver-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[myserver-commit] [SCM] GNU MyServer branch, master, updated. 0_9-357-g8


From: Giuseppe Scrivano
Subject: [myserver-commit] [SCM] GNU MyServer branch, master, updated. 0_9-357-g8803a55
Date: Thu, 05 Nov 2009 16:23:06 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU MyServer".

The branch, master has been updated
       via  8803a55881b0fecc63e40662a9e2771f1bfe20b0 (commit)
      from  c84058968a77da765df544b00bc3bb90cd7b96e5 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------


commit 8803a55881b0fecc63e40662a9e2771f1bfe20b0
Author: Giuseppe Scrivano <address@hidden>
Date:   Thu Nov 5 17:22:57 2009 +0100

    Read from the main configuration the default MIME types and virtual hosts 
handlers to be used.

diff --git a/myserver/include/conf/mime/mime_manager.h 
b/myserver/include/conf/mime/mime_manager.h
index 9d30448..79c8781 100644
--- a/myserver/include/conf/mime/mime_manager.h
+++ b/myserver/include/conf/mime/mime_manager.h
@@ -99,6 +99,8 @@ public:
   void registerHandler (string &name, MimeManagerHandler *handler);
   void setDefaultHandler (string &name);
   void clean ();
+  MimeManagerHandler *getDefaultHandler () {return defHandler;}
+
 
   void registerBuilder (string &name, MAKE_HANDLER builder);
   MimeManagerHandler *buildHandler (string &name);
diff --git a/myserver/include/server/server.h b/myserver/include/server/server.h
index 8382e99..4947ee0 100644
--- a/myserver/include/server/server.h
+++ b/myserver/include/server/server.h
@@ -171,8 +171,7 @@ public:
 private:
   friend class ClientsThread;
   XmlValidator *xmlValidator;
-  XmlMimeHandler *xmlMimeHandler;
-  XmlVhostHandler *vhostHandler;
+  VhostManagerHandler *vhostHandler;
 
   MainConfiguration *configurationFileManager;
   MainConfiguration* (*genMainConf) (Server *server, const char *arg);
diff --git a/myserver/src/server/server.cpp b/myserver/src/server/server.cpp
index 8e93aeb..2c2b803 100644
--- a/myserver/src/server/server.cpp
+++ b/myserver/src/server/server.cpp
@@ -279,36 +279,36 @@ int Server::postLoad ()
 
   log (MYSERVER_LOG_MSG_INFO, _("IP: %s"), ipAddresses->c_str ());
 
-  /* Load the MIME types.  */
-  log (MYSERVER_LOG_MSG_INFO, _("Loading MIME types..."));
-
-  xmlMimeHandler = new XmlMimeHandler ();
-  if (int nMIMEtypes = xmlMimeHandler->load (mimeConfigurationFile.c_str ()))
-    log (MYSERVER_LOG_MSG_INFO, _("Using %i MIME types"), nMIMEtypes);
-  else
-    log (MYSERVER_LOG_MSG_ERROR, _("Error while loading MIME types"));
-
-  string xml ("xml");
-  mimeManager.registerHandler (xml, xmlMimeHandler);
-  mimeManager.setDefaultHandler (xml);
-
   log (MYSERVER_LOG_MSG_INFO, _("Detected %i CPUs"), (int) getCPUCount ());
 
   connectionsScheduler.restart ();
 
   listenThreads.initialize ();
 
-  vhostHandler = new XmlVhostHandler (&listenThreads, logManager);
-  vhostManager.setHandler (vhostHandler);
-
   getProcessServerManager ()->load ();
 
+  if (path == NULL)
+    path = new string ();
+
+  if (getdefaultwd (*path))
+    return -1;
+
   /* Load the home directories configuration.  */
   homeDir.load ();
 
   loadStaticComponents ();
   loadPlugins ();
 
+  /* FIXME: refactor.. the same code is present in the main loop.  */
+  const char *vhostHandlerN = getData ("server.vhost_manager");
+  if (!vhostHandlerN)
+    vhostHandlerN = "xml";
+
+  string vhostHandlerStr (vhostHandlerN);
+  vhostHandler = vhostManager.buildHandler (vhostHandlerStr, &listenThreads,
+                                            logManager);
+  vhostManager.setHandler (vhostHandler);
+
   /* Load the virtual hosts configuration from the xml file.  */
   if (vhostHandler->load (vhostConfigurationFile.c_str ()))
     {
@@ -318,11 +318,22 @@ int Server::postLoad ()
       return -1;
     }
 
-  if (path == 0)
-    path = new string ();
 
-  if (getdefaultwd (*path))
-    return -1;
+  /* Load the MIME types.  */
+  log (MYSERVER_LOG_MSG_INFO, _("Loading MIME types..."));
+
+  const char *mimeManagerCfg = getData ("server.mime_manager");
+  if (!mimeManagerCfg)
+    mimeManagerCfg = "xml";
+
+  string handlerStr (mimeManagerCfg);
+  mimeManager.setDefaultHandler (handlerStr);
+
+  MimeManagerHandler *mimeHandler = mimeManager.getDefaultHandler ();
+  if (int nMIMEtypes = mimeHandler->load (mimeConfigurationFile.c_str ()))
+    log (MYSERVER_LOG_MSG_INFO, _("Using %i MIME types"), nMIMEtypes);
+  else
+    log (MYSERVER_LOG_MSG_ERROR, _("Error while loading MIME types"));
 
   for (u_long i = 0; i < nStaticThreads; i++)
     {
@@ -351,6 +362,8 @@ void Server::loadStaticComponents ()
 {
   string xml ("xml");
 
+  mimeManager.registerHandler (xml, new XmlMimeHandler ());
+
   XmlVhostHandler::registerBuilder (vhostManager);
   XmlMimeHandler::registerBuilder (mimeManager);
 
@@ -489,7 +502,16 @@ void Server::mainLoop ()
                   connectionsScheduler.restart ();
                   listenThreads.initialize ();
 
-                  vhostHandler = new XmlVhostHandler (&listenThreads, 
logManager);
+                  delete vhostHandler;
+
+                  const char *vhostHandlerN = getData ("server.vhost_manager");
+                  if (!vhostHandlerN)
+                    vhostHandlerN = "xml";
+
+                  string vhostHandlerStr (vhostHandlerN);
+                  vhostHandler = vhostManager.buildHandler (vhostHandlerStr,
+                                                            &listenThreads,
+                                                            logManager);
                   vhostManager.setHandler (vhostHandler);
 
                   delete oldvhost;
@@ -504,8 +526,7 @@ void Server::mainLoop ()
                   log (MYSERVER_LOG_MSG_INFO, _("Reloaded"));
                 }
             }
-        }//end  if (autoRebootEnabled)
-
+        }
     }
 }
 
@@ -1118,7 +1139,7 @@ ConnectionPtr Server::addConnectionToList (Socket* s,
   newConnection->setIpAddr (ipAddr);
   newConnection->setLocalIpAddr (localIpAddr);
   newConnection->host = vhostManager.getVHost (0, localIpAddr, localPort);
-  if (newConnection->host == 0)
+  if (newConnection->host == NULL)
     {
       connectionsPoolLock.lock ();
       connectionsPool.put (newConnection);

-----------------------------------------------------------------------

Summary of changes:
 myserver/include/conf/mime/mime_manager.h |    2 +
 myserver/include/server/server.h          |    3 +-
 myserver/src/server/server.cpp            |   69 +++++++++++++++++++----------
 3 files changed, 48 insertions(+), 26 deletions(-)


hooks/post-receive
-- 
GNU MyServer




reply via email to

[Prev in Thread] Current Thread [Next in Thread]