List:Commits« Previous MessageNext Message »
From:Dmitry Shulga Date:September 22 2010 5:40am
Subject:bzr commit into mysql-5.1-bugteam branch (Dmitry.Shulga:3514) Bug#56821
View as plain text  
#At file:///Users/shulga/projects/mysql/5.1-bugteam-bug56821/ based on revid:alfranio.correia@stripped

 3514 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
=== modified file 'sql/log.cc'
--- a/sql/log.cc	2010-09-02 13:05:06 +0000
+++ b/sql/log.cc	2010-09-22 05:40:31 +0000
@@ -5075,7 +5075,21 @@ extern "C" my_bool reopen_fstreams(const
   int stream_fd;
   HANDLE osfh;
 
-  DBUG_ASSERT(filename && (outstream || errstream));
+  DBUG_ASSERT(filename && errstream);
+
+  // Services don't have stdout/stderr on Win2k and NT, so _fileno returns -1.
+  stream_fd= _fileno(errstream);
+  if (stream_fd < 0)
+  {
+    if (outstream && !freopen(filename, "a+", stdout))
+      return TRUE;
+
+    if (!freopen(filename, "a+", stderr))
+      return TRUE;
+
+    setbuf(stderr, NULL);
+    return FALSE;
+  }
 
   if ((osfh= CreateFile(filename, GENERIC_READ | GENERIC_WRITE,
                         FILE_SHARE_READ | FILE_SHARE_WRITE |
@@ -5091,24 +5105,16 @@ extern "C" my_bool reopen_fstreams(const
     return TRUE;
   }
 
-  if (outstream)
+  if (_dup2(handle_fd, stream_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, _fileno(outstream)) < 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-20100922054031-njs1rm2wq8iffsyj.bundle
Thread
bzr commit into mysql-5.1-bugteam branch (Dmitry.Shulga:3514) Bug#56821Dmitry Shulga22 Sep