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. 582ef5270d


From: Giuseppe Scrivano
Subject: [myserver-commit] [SCM] GNU MyServer branch, master, updated. 582ef5270d7e583a725575cd15f570cd64662610
Date: Tue, 04 Aug 2009 17:43:30 +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  582ef5270d7e583a725575cd15f570cd64662610 (commit)
       via  911c59d1eecdd38395c00aa687ba47dc37ab78d5 (commit)
       via  baa7b7cfe59b4ed4c55cca5bb78cdd90d8c7c78a (commit)
      from  d44143d5850c8244068fdc2aa6a9a3bc7aa10872 (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 582ef5270d7e583a725575cd15f570cd64662610
Author: Giuseppe Scrivano <address@hidden>
Date:   Tue Aug 4 19:23:21 2009 +0200

    Code refactoring for the class Thread.

diff --git a/myserver/src/base/thread/thread.cpp 
b/myserver/src/base/thread/thread.cpp
index acdbb4f..2e242b3 100755
--- a/myserver/src/base/thread/thread.cpp
+++ b/myserver/src/base/thread/thread.cpp
@@ -20,18 +20,19 @@ along with this program.  If not, see 
<http://www.gnu.org/licenses/>.
 #include <include/base/utility.h>
 #include <include/base/thread/thread.h>
 
-extern "C" {
+extern "C"
+{
 #include <string.h>
 #include <stdlib.h>
 #include <stdarg.h>
 #include <stdio.h>
 #ifndef WIN32
-#include <errno.h>
-#include <netdb.h>
-#include <unistd.h>
+# include <errno.h>
+# include <netdb.h>
+# include <unistd.h>
 #include <signal.h>
 #ifdef HAVE_PTHREAD
-#include <pthread.h>
+# include <pthread.h>
 #endif
 #include <sys/wait.h>
 #endif
@@ -46,12 +47,12 @@ extern "C" {
 /*!
  *Sleep the caller thread for [TIME] microseconds.
  */
-void Thread::wait(u_long time)
+void Thread::wait (u_long time)
 {
 #ifdef WIN32
-  Sleep(time/1000);
+  Sleep (time / 1000);
 #else
-  usleep(time);
+  usleep (time);
 #endif
 
 }
@@ -63,60 +64,60 @@ void Thread::wait(u_long time)
  *\param arg Argument to pass to the new created thread.
  */
 #ifdef WIN32
-int Thread::create(ThreadID*  ID, 
-                   unsigned int  (_stdcall *startRoutine)(void *), 
-                   void * arg)
+int Thread::create (ThreadID*  ID,
+                    unsigned int  (_stdcall *startRoutine)(void *),
+                    void * arg)
 #endif
 #ifdef HAVE_PTHREAD
-int Thread::create(ThreadID*  ID, void * (*startRoutine)(void *), 
-                   void * arg)
+int Thread::create (ThreadID*  ID, void * (*startRoutine)(void *),
+                    void * arg)
 #endif
 {
 #ifdef WIN32
-  *ID = _beginthreadex(NULL, 0, startRoutine, arg, 0, NULL);
+  *ID = _beginthreadex (NULL, 0, startRoutine, arg, 0, NULL);
 
   return !(*ID);
 #endif
 #ifdef HAVE_PTHREAD
-  return pthread_create((pthread_t*)ID, NULL, startRoutine, (void *)(arg));
+  return pthread_create ((pthread_t*)ID, NULL, startRoutine, (void *)(arg));
 #endif
 }
 
 /*!
  *Get the calling thread ID.
  */
-ThreadID Thread::threadID()
+ThreadID Thread::threadID ()
 {
 #ifdef WIN32
-  return GetCurrentThreadId();
+  return GetCurrentThreadId ();
 #endif
 #ifdef HAVE_PTHREAD
-  return pthread_self();
+  return pthread_self ();
 #endif
 }
 
 /*!
  *Terminate the caller thread.
  */
-void Thread::terminate()
+void Thread::terminate ()
 {
 #ifdef WIN32
-  _endthread();
+  _endthread ();
 #endif
 #ifdef HAVE_PTHREAD
-  pthread_exit(0);
+  pthread_exit (0);
 #endif
 }
 
 /*!
  *Sleep until the thread identified by tid complete its execution.
  */
-int Thread::join(ThreadID tid)
+int Thread::join (ThreadID tid)
 {
 #ifdef WIN32
-  return WaitForSingleObject((void*)tid, INFINITE) != WAIT_OBJECT_0;
+  return WaitForSingleObject ((void*)tid, INFINITE) != WAIT_OBJECT_0;
 #endif
 #ifdef HAVE_PTHREAD
-  return pthread_join(tid, NULL);
+  return pthread_join (tid, NULL);
 #endif
 }



commit 911c59d1eecdd38395c00aa687ba47dc37ab78d5
Author: Giuseppe Scrivano <address@hidden>
Date:   Tue Aug 4 19:22:27 2009 +0200

    Free resources used by the thread.

diff --git a/myserver/src/server/server.cpp b/myserver/src/server/server.cpp
index ad46279..32d1ba9 100644
--- a/myserver/src/server/server.cpp
+++ b/myserver/src/server/server.cpp
@@ -762,15 +762,16 @@ int Server::purgeThreads()
     /*
      *Shutdown all threads that can be destroyed.
      */
-    if(thread->isToDestroy())
+    if (thread->isToDestroy ())
     {
-      if(destroyed < purgeThreadsThreshold)
+      if (destroyed < purgeThreadsThreshold)
       {
         list<ClientsThread*>::iterator next = it;
         next++;
 
-        thread->stop();
-        threads.erase(it);
+        thread->stop ();
+        thread->join ();
+        threads.erase (it);
         destroyed++;
 
         it = next;
@@ -780,10 +781,10 @@ int Server::purgeThreads()
     }
     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++;
     }
   }



commit baa7b7cfe59b4ed4c55cca5bb78cdd90d8c7c78a
Author: Giuseppe Scrivano <address@hidden>
Date:   Tue Aug 4 18:56:16 2009 +0200

    Alloc dinamically the connection if there are not free slots in the slab.

diff --git a/myserver/src/server/server.cpp b/myserver/src/server/server.cpp
index b87fb40..ad46279 100644
--- a/myserver/src/server/server.cpp
+++ b/myserver/src/server/server.cpp
@@ -1375,7 +1375,7 @@ ConnectionPtr Server::addConnectionToList(Socket* s,
   vector<Multicast<string, void*, int>*>* handlers;
 
   connectionsPoolLock.lock ();
-  newConnection = connectionsPool.get ();
+  newConnection = connectionsPool.forcedGet ();
   connectionsPoolLock.unlock ();
 
   if(!newConnection)

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

Summary of changes:
 myserver/src/base/thread/thread.cpp |   49 ++++++++++++++++++-----------------
 myserver/src/server/server.cpp      |   17 ++++++-----
 2 files changed, 34 insertions(+), 32 deletions(-)


hooks/post-receive
-- 
GNU MyServer




reply via email to

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