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_2-62-g


From: Giuseppe Scrivano
Subject: [myserver-commit] [SCM] GNU MyServer branch, master, updated. 0_9_2-62-g59af382
Date: Mon, 01 Mar 2010 20:52:10 +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  59af38244e9dea8871df6294c59158676198ea63 (commit)
      from  c48f59eddcfe03fa31232bf611ad134cdfa0fb2d (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 59af38244e9dea8871df6294c59158676198ea63
Author: Giuseppe Scrivano <address@hidden>
Date:   Mon Mar 1 21:50:03 2010 +0100

    Remove lock from the virtual hosts manager.

diff --git a/myserver/include/conf/vhost/xml_vhost_handler.h 
b/myserver/include/conf/vhost/xml_vhost_handler.h
index 883c397..3f9f4f0 100644
--- a/myserver/include/conf/vhost/xml_vhost_handler.h
+++ b/myserver/include/conf/vhost/xml_vhost_handler.h
@@ -50,7 +50,6 @@ public:
 private:
   void loadXMLlogData (string, Vhost*, xmlNode*);
   ListenThreads* listenThreads;
-  Mutex mutex;
 
   /*! List of virtual hosts. */
   list<Vhost*> hostList;
diff --git a/myserver/src/conf/vhost/xml_vhost_handler.cpp 
b/myserver/src/conf/vhost/xml_vhost_handler.cpp
index 545eadd..6730090 100644
--- a/myserver/src/conf/vhost/xml_vhost_handler.cpp
+++ b/myserver/src/conf/vhost/xml_vhost_handler.cpp
@@ -51,8 +51,6 @@ int XmlVhostHandler::addVHost (Vhost* vh)
 {
   list<Vhost*>::iterator it;
 
-  mutex.lock ();
-
   /* Be sure there is a listening thread on the specified port.  */
   listenThreads->addListeningThread (vh->getPort ());
 
@@ -75,12 +73,10 @@ int XmlVhostHandler::addVHost (Vhost* vh)
                                     protocol.c_str ());
 
       hostList.push_back (vh);
-      mutex.unlock ();
       return 0;
     }
   catch (...)
     {
-      mutex.unlock ();
       return -1;
     };
 }
@@ -91,54 +87,44 @@ int XmlVhostHandler::addVHost (Vhost* vh)
 Vhost* XmlVhostHandler::getVHost (const char* host, const char* ip, u_short 
port)
 {
   list<Vhost*>::iterator it;
+  /*
+    Do a linear search here. We have to use the first full-matching
+    virtual host.
+  */
+  for (it = hostList.begin (); it != hostList.end (); it++)
+    {
+      Vhost* vh = *it;
 
-  mutex.lock ();
+      /* Control if the host port is the correct one.  */
+      if (vh->getPort () != port)
+        continue;
 
-  try
-    {
-      it = hostList.begin ();
+      /* If ip is defined check that it is allowed to connect to the host.  */
+      if (ip && !vh->isIPAllowed (ip))
+        continue;
 
-      /*Do a linear search here. We have to use the first full-matching
-       *virtual host.
-       */
-      for (; it != hostList.end (); it++)
-        {
-          Vhost* vh = *it;
-          /* Control if the host port is the correct one.  */
-          if (vh->getPort () != port)
-            continue;
-          /* If ip is defined check that it is allowed to connect to the host. 
 */
-          if (ip && !vh->isIPAllowed (ip))
-            continue;
-          /* If host is defined check if it is allowed to connect to the host. 
 */
-          if (host && !vh->isHostAllowed (host))
-            continue;
-          /* We find a valid host.  */
-          mutex.unlock ();
-          /* Add a reference.  */
-          vh->addRef ();
-          return vh;
-        }
-      mutex.unlock ();
-      return 0;
+      /* If host is defined check if it is allowed to connect to the host.  */
+      if (host && !vh->isHostAllowed (host))
+        continue;
+
+      /* Add a reference.  */
+      vh->addRef ();
+      return vh;
     }
-  catch (...)
-    {
-      mutex.unlock ();
-      return 0;
-    };
+  return 0;
+
+  return 0;
 }
 
 /*!
- *XmlVhostHandler costructor.
- *\param lt A ListenThreads object to use to create new threads.
- *\param lm The log manager to use.
+ * XmlVhostHandler costructor.
+ * \param lt A ListenThreads object to use to create new threads.
+ * \param lm The log manager to use.
  */
 XmlVhostHandler::XmlVhostHandler (ListenThreads* lt, LogManager* lm)
 {
   listenThreads = lt;
   hostList.clear ();
-  mutex.init ();
   logManager = lm;
 }
 
@@ -149,8 +135,6 @@ void XmlVhostHandler::clean ()
 {
   list<Vhost*>::iterator it;
 
-  mutex.lock ();
-
   it = hostList.begin ();
 
   try
@@ -159,12 +143,9 @@ void XmlVhostHandler::clean ()
         delete *it;
 
       hostList.clear ();
-
-      mutex.unlock ();
     }
   catch (...)
     {
-      mutex.unlock ();
       return;
     };
 }
@@ -175,7 +156,6 @@ void XmlVhostHandler::clean ()
 XmlVhostHandler::~XmlVhostHandler ()
 {
   clean ();
-  mutex.destroy ();
 }
 
 /*!
@@ -563,58 +543,36 @@ int XmlVhostHandler::load (const char *filename)
  */
 Vhost* XmlVhostHandler::getVHost (int n)
 {
-  Vhost* ret = 0;
-  mutex.lock ();
-  try
+  Vhost* ret = NULL;
+  list<Vhost*>::iterator i = hostList.begin ();
+  for ( ; i != hostList.end (); i++)
     {
-      list<Vhost*>::iterator i = hostList.begin ();
-      for ( ; i != hostList.end (); i++)
+      if (!(n--))
         {
-          if (!(n--))
-            {
-              ret = *i;
-              ret->addRef ();
-              break;
-            }
+          ret = *i;
+          ret->addRef ();
+          break;
         }
-      mutex.unlock ();
-
-      return ret;
     }
-  catch (...)
-    {
-      mutex.unlock ();
-      return ret;
-    };
+  return ret;
 }
 
 /*!
- *Remove a virtual host by its position in the list
- *First position is zero.
- *\param n The virtual host identifier in the list.
+ * Remove a virtual host by its position in the list
+ * First position is zero.
+ * \param n The virtual host identifier in the list.
  */
 int XmlVhostHandler::removeVHost (int n)
 {
-  mutex.lock ();
-  try
-    {
-      list<Vhost*>::iterator i = hostList.begin ();
+  list<Vhost*>::iterator i = hostList.begin ();
 
-      for ( ;i != hostList.end (); i++)
+  for ( ;i != hostList.end (); i++)
+    {
+      if (!(n--))
         {
-          if (!(n--))
-            {
-              delete *i;
-              mutex.unlock ();
-              return 1;
-            }
+          delete *i;
+          return 1;
         }
-      mutex.unlock ();
-      return 0;
     }
-  catch (...)
-    {
-      mutex.unlock ();
-      return 0;
-    };
+  return 0;
 }

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

Summary of changes:
 myserver/include/conf/vhost/xml_vhost_handler.h |    1 -
 myserver/src/conf/vhost/xml_vhost_handler.cpp   |  130 ++++++++---------------
 2 files changed, 44 insertions(+), 87 deletions(-)


hooks/post-receive
-- 
GNU MyServer




reply via email to

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