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. 0ab6af04e9


From: Giuseppe Scrivano
Subject: [myserver-commit] [SCM] GNU MyServer branch, master, updated. 0ab6af04e95a4f4db41f9bfb5385ccab319307fd
Date: Wed, 05 Aug 2009 20:56:49 +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  0ab6af04e95a4f4db41f9bfb5385ccab319307fd (commit)
       via  16b1ddee345a0af3d378c1b5111c6f98cc9281b4 (commit)
       via  4039683a689de1d2aeb973c272eb2db907ed3028 (commit)
       via  c9cd743bc922211f2467400ac52a246c25c62842 (commit)
      from  70c279cbf4b71bd0931a1e438c38cf65aee31ee7 (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 0ab6af04e95a4f4db41f9bfb5385ccab319307fd
Author: Giuseppe Scrivano <address@hidden>
Date:   Wed Aug 5 22:42:37 2009 +0200

    Protect the access to the connections map.

diff --git a/myserver/src/connections_scheduler/connections_scheduler.cpp 
b/myserver/src/connections_scheduler/connections_scheduler.cpp
index 803dc6e..853b327 100644
--- a/myserver/src/connections_scheduler/connections_scheduler.cpp
+++ b/myserver/src/connections_scheduler/connections_scheduler.cpp
@@ -69,7 +69,12 @@ static void newDataHandler(int fd, short event, void *param)
 
 void ConnectionsScheduler::newData(short event, SocketHandle handle)
 {
-  ConnectionPtr connection = connections.get (handle);
+  ConnectionPtr connection = NULL;
+
+  connectionsMutex.lock();
+  connection = connections.get (handle);
+  connectionsMutex.unlock();
+
 
   if(connection == NULL || server == NULL)
     return;



commit 16b1ddee345a0af3d378c1b5111c6f98cc9281b4
Author: Giuseppe Scrivano <address@hidden>
Date:   Wed Aug 5 22:25:40 2009 +0200

    Specify the Content-Length with keep-alive connections too when it is 
possible.

diff --git a/myserver/src/http_handler/http_file/http_file.cpp 
b/myserver/src/http_handler/http_file/http_file.cpp
index 9a15cce..f1839e4 100644
--- a/myserver/src/http_handler/http_file/http_file.cpp
+++ b/myserver/src/http_handler/http_file/http_file.cpp
@@ -408,7 +408,7 @@ int HttpFile::send (HttpThreadContext* td,
 
     useModifiers = chain.hasModifiersFilters ();
  
-    if (keepalive && !useModifiers)
+    if (!useModifiers)
       {
         ostringstream buffer;
         buffer << (u_int)bytesToSend;
@@ -424,10 +424,11 @@ int HttpFile::send (HttpThreadContext* td,
       {
         string s;
         HttpResponseHeader::Entry *e;
-        chain.getName(s);
+        chain.getName (s);
         e = td->response.other.get ("Content-Encoding");
+
         if (e)
-        e->value->assign (s);
+          e->value->assign (s);
         else
           {
             e = new HttpResponseHeader::Entry ();
@@ -436,21 +437,21 @@ int HttpFile::send (HttpThreadContext* td,
             td->response.other.put (*(e->name), e);
           }
         /* Do not use chunked transfer with old HTTP/1.0 clients.  */
-      if (keepalive)
-        {
-          HttpResponseHeader::Entry *e;
-          e = td->response.other.get ("Transfer-Encoding");
-          if(e)
-            e->value->assign ("chunked");
-          else
-            {
-              e = new HttpResponseHeader::Entry ();
-              e->name->assign ("Transfer-Encoding");
+        if (keepalive)
+          {
+            HttpResponseHeader::Entry *e;
+            e = td->response.other.get ("Transfer-Encoding");
+            if(e)
               e->value->assign ("chunked");
-              td->response.other.put (*(e->name), e);
-            }
-          useChunks = true;
-        }
+            else
+              {
+                e = new HttpResponseHeader::Entry ();
+                e->name->assign ("Transfer-Encoding");
+                e->value->assign ("chunked");
+                td->response.other.put (*(e->name), e);
+              }
+            useChunks = true;
+          }
       }
  
     u_long hdrLen = HttpHeaders::buildHTTPResponseHeader 
(td->buffer->getBuffer(),
@@ -461,15 +462,15 @@ int HttpFile::send (HttpThreadContext* td,
     if (!td->appendOutputs)
       {
         /* Send the HTTP header.  */
-      if (td->connection->socket->send(td->buffer->getBuffer(),
-                                       (u_long)td->buffer->getLength(),
-                                       0) == SOCKET_ERROR)
-        {
-          file->close ();
-          delete file;
-        chain.clearAllFilters ();
-        return 1;
-        }
+        if (td->connection->socket->send (td->buffer->getBuffer (),
+                                          (u_long) td->buffer->getLength (),
+                                          0) == SOCKET_ERROR)
+          {
+            file->close ();
+            delete file;
+            chain.clearAllFilters ();
+            return 1;
+          }
       }
 
     /*



commit 4039683a689de1d2aeb973c272eb2db907ed3028
Author: Giuseppe Scrivano <address@hidden>
Date:   Wed Aug 5 21:34:35 2009 +0200

    The main server purge threads loop avoids to join a sleeping thread.

diff --git a/myserver/src/server/clients_thread.cpp 
b/myserver/src/server/clients_thread.cpp
index 6fe7768..ce6c941 100644
--- a/myserver/src/server/clients_thread.cpp
+++ b/myserver/src/server/clients_thread.cpp
@@ -169,52 +169,47 @@ DEFINE_THREAD(clients_thread, pParam)
    *This function when is alive only call the controlConnections(...) function
    *of the ClientsThread class instance used for control the thread.
    */
-  while(ct->threadIsRunning) 
-  {
-    int ret;
-    try
-    {
-      /*
-       *If the thread can be destroyed don't use it.
-       */
-      if((!ct->isStatic()) && ct->isToDestroy())
-      {
-        Thread::wait(1000);
-        continue;
-      }
-
-      ret = ct->controlConnections();
-      ct->server->increaseFreeThread();
-      ct->busy = 0;
-
-      /*
-       *The thread served the connection, so update the timeout value.
-       */
-      if(ret != 1)
-      {
-        ct->setTimeout(getTicks());
-      }
-    }
-    catch( bad_alloc &ba)
-    {
-      ostringstream s;
-      s << "Bad alloc: " << ba.what();
-      
-      ct->server->logWriteln(s.str().c_str(), MYSERVER_LOG_MSG_ERROR);
-    }
-    catch( exception &e)
+  while (ct->threadIsRunning)
     {
-      ostringstream s;
-      s << "Error: " << e.what();
-
-      ct->server->logWriteln(s.str().c_str(), MYSERVER_LOG_MSG_ERROR);
-    };
-    
+      int ret;
+      try
+        {
+          /*
+           *If the thread can be destroyed don't use it.
+           */
+          if ((!ct->isStatic ()) && ct->isToDestroy ())
+            {
+              Thread::wait (1000);
+              break;
+            }
+
+          ret = ct->controlConnections ();
+          ct->server->increaseFreeThread ();
+          ct->busy = 0;
+
+          /*
+           *The thread served the connection, so update the timeout value.
+           */
+          if (ret != 1)
+            ct->setTimeout (getTicks ());
+        }
+      catch (bad_alloc &ba)
+        {
+          ostringstream s;
+          s << "Bad alloc: " << ba.what();
+
+          ct->server->logWriteln (s.str ().c_str (), MYSERVER_LOG_MSG_ERROR);
+        }
+      catch (exception &e)
+        {
+          ostringstream s;
+          s << "Error: " << e.what ();
+          ct->server->logWriteln (s.str ().c_str (), MYSERVER_LOG_MSG_ERROR);
+        };
   }
 
-  ct->server->decreaseFreeThread();
-
-  delete ct;
+  ct->server->decreaseFreeThread ();
+  ct->threadIsStopped = 1;
 
   Thread::terminate();
   return 0;
diff --git a/myserver/src/server/server.cpp b/myserver/src/server/server.cpp
index 32d1ba9..74d3435 100644
--- a/myserver/src/server/server.cpp
+++ b/myserver/src/server/server.cpp
@@ -762,31 +762,34 @@ int Server::purgeThreads()
     /*
      *Shutdown all threads that can be destroyed.
      */
-    if (thread->isToDestroy ())
-    {
-      if (destroyed < purgeThreadsThreshold)
+    if (thread->isStopped ())
       {
+        ClientsThread* thread = *it;
         list<ClientsThread*>::iterator next = it;
         next++;
 
-        thread->stop ();
         thread->join ();
         threads.erase (it);
-        destroyed++;
+        delete thread;
 
+        destroyed++;
         it = next;
       }
-      else
+    if (thread->isToDestroy ())
+      {
+        if (destroyed < purgeThreadsThreshold)
+          thread->stop ();
+
         it++;
-    }
+      }
     else
-    {
-      if (!thread->isStatic ())
-        if (ticks - thread->getTimeout () > MYSERVER_SEC (15))
-          thread->setToDestroy (1);
+      {
+        if (!thread->isStatic ())
+          if (ticks - thread->getTimeout () > MYSERVER_SEC (15))
+            thread->setToDestroy (1);
 
-      it++;
-    }
+        it++;
+      }
   }
   threadsMutex->unlock();
 
@@ -796,17 +799,17 @@ int Server::purgeThreads()
 /*!
  *Do the final cleanup.  Called once when the process is terminated.
  */
-void Server::finalCleanup()
+void Server::finalCleanup ()
 {
-  XmlParser::cleanXML();
-  freecwdBuffer();
-  myserver_safetime_destroy();
+  XmlParser::cleanXML ();
+  freecwdBuffer ();
+  myserver_safetime_destroy ();
 }
 
 /*!
  *Return the user identifier to use for the process.
  */
-const char *Server::getUid()
+const char *Server::getUid ()
 {
   return uid.c_str ();
 }
@@ -814,7 +817,7 @@ const char *Server::getUid()
 /*!
  *Return the group identifier to use for the process.
  */
-const char *Server::getGid()
+const char *Server::getGid ()
 {
   return gid.c_str ();
 }
@@ -822,7 +825,7 @@ const char *Server::getGid()
 /*!
  *Get a pointer to the language parser.
  */
-XmlParser* Server::getLanguageParser()
+XmlParser* Server::getLanguageParser ()
 {
   return &languageParser;
 }
@@ -830,7 +833,7 @@ XmlParser* Server::getLanguageParser()
 /*!
  *Returns the numbers of active connections the list.
  */
-u_long Server::getNumConnections()
+u_long Server::getNumConnections ()
 {
   return connectionsScheduler.getConnectionsNumber();
 }
@@ -838,15 +841,15 @@ u_long Server::getNumConnections()
 /*!
  *Returns the numbers of all the connections to the server.
  */
-u_long Server::getNumTotalConnections()
+u_long Server::getNumTotalConnections ()
 {
-  return connectionsScheduler.getNumTotalConnections();
+  return connectionsScheduler.getNumTotalConnections ();
 }
 
 /*!
  *Get the verbosity value.
  */
-u_long Server::getVerbosity()
+u_long Server::getVerbosity ()
 {
   return verbosity;
 }
@@ -854,7 +857,7 @@ u_long Server::getVerbosity()
 /*!
  *Set the verbosity value.
  */
-void  Server::setVerbosity(u_long nv)
+void  Server::setVerbosity (u_long nv)
 {
   verbosity=nv;
 }
@@ -862,7 +865,7 @@ void  Server::setVerbosity(u_long nv)
 /*!
  *Return a home directory object.
  */
-HomeDir* Server::getHomeDir()
+HomeDir* Server::getHomeDir ()
 {
   return &homeDir;
 }
@@ -870,7 +873,7 @@ HomeDir* Server::getHomeDir()
 /*!
  *Stop the execution of the server.
  */
-void Server::stop()
+void Server::stop ()
 {
   endServer = true;
 }
@@ -879,95 +882,89 @@ void Server::stop()
  *Unload the server.
  *Return nonzero on errors.
  */
-int Server::terminate()
+int Server::terminate ()
 {
-  list<ThreadID> threadsIds;
+  if (verbosity > 1)
+    logWriteln(languageParser.getValue ("MSG_STOPT"));
 
-  if(verbosity > 1)
-    logWriteln(languageParser.getValue("MSG_STOPT"));
+  listenThreads.terminate ();
 
-  listenThreads.terminate();
+  threadsMutex->lock ();
 
-  threadsMutex->lock();
-
-  for(list<ClientsThread*>::iterator it = threads.begin(); it != 
threads.end(); it++)
-  {
-    threadsIds.push_back((*it)->getThreadId());
-    (*it)->stop();
-  }
+  for (list<ClientsThread*>::iterator it = threads.begin ();
+       it != threads.end (); it++)
+    (*it)->stop ();
 
-  threadsMutex->unlock();
-  Socket::stopBlockingOperations(true);
+  threadsMutex->unlock ();
+  Socket::stopBlockingOperations (true);
 
-  connectionsScheduler.release();
+  connectionsScheduler.release ();
 
-  for(list<ThreadID>::iterator it = threadsIds.begin(); it != 
threadsIds.end(); it++)
-  {
-    Thread::join(*it);
-  }
+  for (list<ClientsThread*>::iterator it = threads.begin ();
+       it != threads.end (); it++)
+    {
+      Thread::join ((*it)->getThreadId ());
+      delete *it;
+    }
 
-  clearAllConnections();
+  clearAllConnections ();
 
   /* Clear the home directories data.  */
-  homeDir.clear();
+  homeDir.clear ();
 
-  if(verbosity > 1)
-    logWriteln(languageParser.getValue("MSG_TSTOPPED"));
+  if (verbosity > 1)
+    logWriteln (languageParser.getValue ("MSG_TSTOPPED"));
 
 
-  if(verbosity > 1)
-  {
-    logWriteln(languageParser.getValue("MSG_MEMCLEAN"));
-  }
+  if (verbosity > 1)
+    logWriteln (languageParser.getValue ("MSG_MEMCLEAN"));
 
-  freeHashedData();
+  freeHashedData ();
 
   /* Restore the blocking status in case of a reboot.  */
-  Socket::stopBlockingOperations(false);
+  Socket::stopBlockingOperations (false);
 
   ipAddresses = 0;
   vhostList = 0;
-  languageParser.close();
+  languageParser.close ();
 
-  if(mimeManager)
-  {
-    mimeManager->clean();
-    delete mimeManager;
-    mimeManager = 0;
-  }
+  if (mimeManager)
+    {
+      mimeManager->clean ();
+      delete mimeManager;
+      mimeManager = 0;
+    }
 
 #ifdef WIN32
   /*
    *Under WIN32 cleanup environment strings.
    */
-  FreeEnvironmentStrings((LPTSTR)envString);
+  FreeEnvironmentStrings ((LPTSTR)envString);
 #endif
 
-  getProcessServerManager()->clear();
+  getProcessServerManager ()->clear ();
 
-  filtersFactory.free();
+  filtersFactory.free ();
 
-  getPluginsManager()->unLoad();
+  getPluginsManager ()->unLoad ();
 
   delete connectionsMutex;
 
-  clearMulticastRegistry();
+  clearMulticastRegistry ();
 
-  globalData.clear();
+  globalData.clear ();
 
   /*
    *Free all the threads.
    */
-  threadsMutex->lock();
-  threads.clear();
-  threadsMutex->unlock();
+  threadsMutex->lock ();
+  threads.clear ();
+  threadsMutex->unlock ();
   delete threadsMutex;
 
   nStaticThreads = 0;
-  if(verbosity > 1)
-  {
-    logWriteln("MyServer is stopped");
-  }
+  if (verbosity > 1)
+    logWriteln ("MyServer is stopped");
   
   logManager->clear ();
   



commit c9cd743bc922211f2467400ac52a246c25c62842
Author: Giuseppe Scrivano <address@hidden>
Date:   Wed Aug 5 20:01:03 2009 +0200

    Ensure xml document root is not null.

diff --git a/myserver/src/conf/security/xml_validator.cpp 
b/myserver/src/conf/security/xml_validator.cpp
index a70b08b..e738849 100644
--- a/myserver/src/conf/security/xml_validator.cpp
+++ b/myserver/src/conf/security/xml_validator.cpp
@@ -189,7 +189,7 @@ int XmlValidator::getPermissionMaskImpl (SecurityToken* st,
 {
   XmlParser* xmlFile = getParser (st);
 
-  if (!xmlFile)
+  if (!xmlFile || !xmlFile->getDoc ())
     return 0;
 
   for (xmlNodePtr cur = xmlFile->getDoc ()->children; cur; cur = cur->next)

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

Summary of changes:
 myserver/src/conf/security/xml_validator.cpp       |    2 +-
 .../connections_scheduler.cpp                      |    7 +-
 myserver/src/http_handler/http_file/http_file.cpp  |   53 ++++----
 myserver/src/server/clients_thread.cpp             |   81 +++++------
 myserver/src/server/server.cpp                     |  149 ++++++++++----------
 5 files changed, 145 insertions(+), 147 deletions(-)


hooks/post-receive
-- 
GNU MyServer




reply via email to

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