List:Commits« Previous MessageNext Message »
From:Dmitry Shulga Date:September 22 2010 1:04pm
Subject:bzr push into mysql-5.1-bugteam branch (Dmitry.Shulga:3514 to 3515)
Bug#56821
View as plain text  
 3515 Dmitry Shulga	2010-09-22
      Fixed bug#56821 - failure to start the MySQL Service.
     @ sql/log.cc
        reopen_fstreams modified: fixed error in processing of
        stdout/stderr when run mysqld as Windows service.

    modified:
      sql/log.cc
 3514 Ingo Struewing	2010-09-21 [merge]
      Bug#46339 - crash on REPAIR TABLE merge table USE_FRM
      Merge from saved bundle.

    modified:
      mysql-test/r/merge.result
      mysql-test/t/merge.test
      sql/sql_table.cc
=== modified file 'sql/log.cc'
--- a/sql/log.cc	2010-09-02 13:05:06 +0000
+++ b/sql/log.cc	2010-09-22 12:53:06 +0000
@@ -5072,10 +5072,32 @@ extern "C" my_bool reopen_fstreams(const
                                    FILE *outstream, FILE *errstream)
 {
   int handle_fd;
-  int stream_fd;
+  int err_fd, out_fd;
   HANDLE osfh;
 
-  DBUG_ASSERT(filename && (outstream || errstream));
+  DBUG_ASSERT(filename && errstream);
+
+  // Services don't have stdout/stderr on Windows, so _fileno returns -1.
+  err_fd= _fileno(errstream);
+  if (err_fd < 0)
+  {
+    if (!freopen(filename, "a+", errstream))
+      return TRUE;
+
+    setbuf(errstream, NULL);
+    err_fd= _fileno(errstream);
+  }
+
+  if (outstream)
+  {
+    out_fd= _fileno(outstream);
+    if (out_fd < 0)
+    {
+      if (!freopen(filename, "a+", outstream))
+        return TRUE;
+      out_fd= _fileno(outstream);
+    }
+  }
 
   if ((osfh= CreateFile(filename, GENERIC_READ | GENERIC_WRITE,
                         FILE_SHARE_READ | FILE_SHARE_WRITE |
@@ -5091,24 +5113,16 @@ extern "C" my_bool reopen_fstreams(const
     return TRUE;
   }
 
-  if (outstream)
+  if (_dup2(handle_fd, err_fd) < 0)
   {
-    stream_fd= _fileno(outstream);
-    if (_dup2(handle_fd, stream_fd) < 0)
-    {
-      CloseHandle(osfh);
-      return TRUE;
-    }
+    CloseHandle(osfh);
+    return TRUE;
   }
 
-  if (errstream)
+  if (outstream && _dup2(handle_fd, out_fd) < 0)
   {
-    stream_fd= _fileno(errstream);
-    if (_dup2(handle_fd, stream_fd) < 0)
-    {
-      CloseHandle(osfh);
-      return TRUE;
-    }
+    CloseHandle(osfh);
+    return TRUE;
   }
 
   _close(handle_fd);


Attachment: [text/bzr-bundle] bzr/dmitry.shulga@sun.com-20100922125306-5xa16axg0zax73xh.bundle
Thread
bzr push into mysql-5.1-bugteam branch (Dmitry.Shulga:3514 to 3515)Bug#56821Dmitry Shulga22 Sep