summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorDmitry Shulga <Dmitry.Shulga@Sun.COM>2010-09-22 20:11:40 +0700
committerDmitry Shulga <Dmitry.Shulga@Sun.COM>2010-09-22 20:11:40 +0700
commit3589c8729b8f42cb4640c1ccfe7c0c55362fb455 (patch)
tree48f2b119353089b82c27d3faa042e5fa1a96463c /sql
parentb7a8979d0dda5f6238c2107e0005d38473f73833 (diff)
parent9516e824e01d99165a37966fc5fc4f03acbd4c4e (diff)
downloadmariadb-git-3589c8729b8f42cb4640c1ccfe7c0c55362fb455.tar.gz
Auto-merge from mysql-5.1-bugteam for bug#56821.
Diffstat (limited to 'sql')
-rw-r--r--sql/log.cc46
1 files changed, 30 insertions, 16 deletions
diff --git a/sql/log.cc b/sql/log.cc
index 711534818e8..4aeb55ddbac 100644
--- a/sql/log.cc
+++ b/sql/log.cc
@@ -5456,10 +5456,32 @@ extern "C" my_bool reopen_fstreams(const char *filename,
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 |
@@ -5475,24 +5497,16 @@ extern "C" my_bool reopen_fstreams(const char *filename,
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);