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. 01a174502a


From: Giuseppe Scrivano
Subject: [myserver-commit] [SCM] GNU MyServer branch, master, updated. 01a174502a9a888210f32a33b10abc2d51b120d7
Date: Fri, 25 Sep 2009 20:31:02 +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  01a174502a9a888210f32a33b10abc2d51b120d7 (commit)
      from  45e9429f80e9c33f15bd5a914863fe28f6fb8c70 (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 01a174502a9a888210f32a33b10abc2d51b120d7
Author: Giuseppe Scrivano <address@hidden>
Date:   Fri Sep 25 22:30:01 2009 +0200

    Prevent a deadlock when logging to the main server log from the 
`LogManager' class.

diff --git a/myserver/include/log/log_manager.h 
b/myserver/include/log/log_manager.h
index 869e812..218b2c9 100644
--- a/myserver/include/log/log_manager.h
+++ b/myserver/include/log/log_manager.h
@@ -96,7 +96,6 @@ private:
   int add (const void *owner, string type, string location, LogStream* ls);
   int computeNewLine ();
   void associateLoggingLevelsWithNames ();
-  int log (const string &, LoggingLevel);
 
   LoggingLevel level;
   Mutex* mutex;
diff --git a/myserver/src/log/log_manager.cpp b/myserver/src/log/log_manager.cpp
index 3a9a02a..0558311 100644
--- a/myserver/src/log/log_manager.cpp
+++ b/myserver/src/log/log_manager.cpp
@@ -114,32 +114,33 @@ LogManager::add (const void *owner, string type, string 
location,
           failure = add (owner) || add (owner, type) ||
             add (owner, type, location, ls);
         }
+      mutex->unlock ();
+      return failure;
     }
-  else
-    {
-      int oldSize;
-      int newSize;
-      ostringstream oss;
 
-      oldSize = logStreamOwners[location].size ();
-      if (!containsOwner (owner))
-        {
-          failure = add (owner) || add (owner, type) ||
-            add (owner, type, location, logStreams[location]);
-        }
-      else if (!contains (owner, type))
-        {
-          failure = add (owner, type) ||
-            add (owner, type, location, logStreams[location]);
-        }
-      newSize = logStreamOwners[location].size ();
-      if (!failure && newSize > oldSize)
-        {
-          oss << "Warning: \'" << location << "\' shared between " << newSize 
<< " objects.";
-          log (oss.str (), MYSERVER_LOG_MSG_WARNING);
-        }
+  int oldSize;
+  int newSize;
+  ostringstream oss;
+
+  oldSize = logStreamOwners[location].size ();
+  if (!containsOwner (owner))
+    {
+      failure = add (owner) || add (owner, type) ||
+        add (owner, type, location, logStreams[location]);
+    }
+  else if (!contains (owner, type))
+    {
+      failure = add (owner, type) ||
+        add (owner, type, location, logStreams[location]);
     }
+  newSize = logStreamOwners[location].size ();
+
   mutex->unlock ();
+
+  if (!failure && newSize > oldSize && Server::getInstance ())
+    return Server::getInstance ()->log (MYSERVER_LOG_MSG_WARNING,
+                                     _("The %s log is shared among %i 
objects"),
+                                        location.c_str (), newSize);
   return failure;
 }
 
@@ -1113,23 +1114,6 @@ LogManager::getOwnersList (string location, list<const 
void*>* l)
 }
 
 /*!
- * Write a message on the main MyServer log.
- *
- * \param msg The message to write.
- * \param l The message logging level.
- *
- * \return 0 on success, 1 on error.
- */
-int
-LogManager::log (const string & msg, LoggingLevel l)
-{
-  if (Server::getInstance ())
-    return Server::getInstance ()->log (msg.c_str (), l);
-
-  return 1;
-}
-
-/*!
  * \return a list of strings each representing one of logging levels that
  * MyServer understands.
  */
@@ -1139,9 +1123,8 @@ LogManager::getLoggingLevelsByNames ()
   list<string> l;
   for (map<LoggingLevel, string>::iterator it = loggingLevels.begin ();
        it != loggingLevels.end (); it++)
-    {
       l.push_back (it->second);
-    }
+
   return l;
 }
 

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

Summary of changes:
 myserver/include/log/log_manager.h |    1 -
 myserver/src/log/log_manager.cpp   |   65 +++++++++++++----------------------
 2 files changed, 24 insertions(+), 42 deletions(-)


hooks/post-receive
-- 
GNU MyServer




reply via email to

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