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. v0.9.2-294


From: Giuseppe Scrivano
Subject: [myserver-commit] [SCM] GNU MyServer branch, master, updated. v0.9.2-294-g6e6a0d0
Date: Mon, 09 Aug 2010 01:45:09 +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  6e6a0d0d677091bfbcc04ee77f5685ef4659bcd0 (commit)
       via  0f8214b40499d12ab1663c489efdbb8d05bb3297 (commit)
       via  8746fa5b92b981e998b402e61786a5b98c32dbd6 (commit)
      from  556703b68cca205286663c76a16c324377954797 (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 6e6a0d0d677091bfbcc04ee77f5685ef4659bcd0
Author: Giuseppe Scrivano <address@hidden>
Date:   Mon Aug 9 03:44:35 2010 +0200

    FileStream: atomically cycle the log file not copying it.

diff --git a/myserver/src/log/stream/file_stream.cpp 
b/myserver/src/log/stream/file_stream.cpp
index d02a10c..efcb090 100644
--- a/myserver/src/log/stream/file_stream.cpp
+++ b/myserver/src/log/stream/file_stream.cpp
@@ -43,13 +43,23 @@ FileStream::streamCycle ()
   File *currentFile = dynamic_cast<File*>(out);
   string filepath (currentFile->getFilename ());
   string newFileName (makeNewFileName (currentFile->getFilename ()));
+  u_long opts = currentFile->getOpenOptions ();
 
-  if (FilesUtility::copyFile (currentFile->getFilename (), newFileName.c_str 
(), 1))
-    return 1;
-
-  cycledStreams.push_back (newFileName);
+  currentFile->close ();
+  try
+    {
+      FilesUtility::renameFile (filepath.c_str (),
+                                newFileName.c_str ());
+      cycledStreams.push_back (newFileName);
+    }
+  catch (...)
+    {
+      /* Whatever happens, try to don't leave the log file closed.  */
+      currentFile->openFile (filepath, opts);
+      throw;
+    }
 
-  currentFile->truncate ();
+  currentFile->openFile (filepath, opts);
 
   return 0;
 }



commit 0f8214b40499d12ab1663c489efdbb8d05bb3297
Author: Giuseppe Scrivano <address@hidden>
Date:   Mon Aug 9 03:38:16 2010 +0200

    tests: Adjust some tests to use exceptions.

diff --git a/myserver/tests/test_cached_file.cpp 
b/myserver/tests/test_cached_file.cpp
index 493ef6c..edc2ed0 100644
--- a/myserver/tests/test_cached_file.cpp
+++ b/myserver/tests/test_cached_file.cpp
@@ -74,18 +74,56 @@ public:
   void testOpenFile ()
   {
     string filename;
-    CPPUNIT_ASSERT (cf->openFile (NULL, 0));
-    CPPUNIT_ASSERT (cf->openFile (filename, 0));
+    int success = 0;
+    try
+      {
+        cf->openFile (NULL, 0);
+      }
+    catch (...)
+      {
+        success++;
+      }
+
+    try
+      {
+        cf->openFile (filename, 0);
+      }
+    catch (...)
+      {
+        success++;
+      }
+
+    CPPUNIT_ASSERT_EQUAL (success, 2);
   }
 
   void testCreateTemporaryFile ()
   {
-    CPPUNIT_ASSERT (cf->createTemporaryFile (NULL));
+    int success = 0;
+    try
+      {
+        cf->createTemporaryFile (NULL);
+      }
+    catch (...)
+      {
+        success++;
+      }
+
+    CPPUNIT_ASSERT_EQUAL (success, 1);
   }
 
   void testWrite ()
   {
-    CPPUNIT_ASSERT (cf->writeToFile (NULL, 0, NULL));
+    int success = 0;
+    try
+      {
+        cf->writeToFile (NULL, 0, NULL);
+      }
+    catch (...)
+      {
+        success++;
+      }
+
+    CPPUNIT_ASSERT_EQUAL (success, 1);
   }
 
   void testRead ()
@@ -104,9 +142,6 @@ public:
 
     delete [] buffer;
   }
-
-
-
 };
 
 CPPUNIT_TEST_SUITE_REGISTRATION ( TestCachedFile );



commit 8746fa5b92b981e998b402e61786a5b98c32dbd6
Author: Giuseppe Scrivano <address@hidden>
Date:   Mon Aug 9 02:42:15 2010 +0200

    FileStream: Fix a possible memory leak.

diff --git a/myserver/src/log/stream/file_stream_creator.cpp 
b/myserver/src/log/stream/file_stream_creator.cpp
index 83a47a0..f1c5fda 100644
--- a/myserver/src/log/stream/file_stream_creator.cpp
+++ b/myserver/src/log/stream/file_stream_creator.cpp
@@ -22,20 +22,28 @@ LogStream*
 FileStreamCreator::create (FiltersFactory* ff, string location,
                            list<string>& filters, u_long cycle)
 {
-  File* out = new File ();
-  char* path = const_cast<char*>(location.c_str ());
-  if (out && !out->openFile (path, FileStream::defaultFileMask))
+  File *out = new File ();
+  FiltersChain *fc = NULL;
+  char *path = const_cast<char*>(location.c_str ());
+  try
     {
       u_long nbw;
-      FiltersChain* fc = ff->chain (filters, out, &nbw);
+      out->openFile (path, FileStream::defaultFileMask);
+      fc = ff->chain (filters, out, &nbw);
       if (fc)
-        {
-          return new FileStream (ff, cycle, out, fc);
-        }
+        return new FileStream (ff, cycle, out, fc);
     }
-  if (out)
+  catch (...)
     {
+      if (fc)
+        delete fc;
+
       delete out;
+      throw;
     }
+
+  if (out)
+    delete out;
+
   return 0;
 }

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

Summary of changes:
 myserver/src/log/stream/file_stream.cpp         |   20 +++++++--
 myserver/src/log/stream/file_stream_creator.cpp |   24 +++++++----
 myserver/tests/test_cached_file.cpp             |   49 +++++++++++++++++++---
 3 files changed, 73 insertions(+), 20 deletions(-)


hooks/post-receive
-- 
GNU MyServer



reply via email to

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