Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
2c379a1e
Commit
2c379a1e
authored
Aug 25, 2010
by
Dmitry Shulga
Browse files
Options
Browse Files
Download
Plain Diff
Auto-merge from mysql-5.1-bugteam
parents
0827d824
8520a9fd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
82 additions
and
54 deletions
+82
-54
sql/log.cc
sql/log.cc
+70
-47
sql/mysqld.cc
sql/mysqld.cc
+12
-7
No files found.
sql/log.cc
View file @
2c379a1e
...
@@ -5447,70 +5447,93 @@ void sql_perror(const char *message)
...
@@ -5447,70 +5447,93 @@ void sql_perror(const char *message)
}
}
#ifdef __WIN__
extern
"C"
my_bool
reopen_fstreams
(
const
char
*
filename
,
FILE
*
outstream
,
FILE
*
errstream
)
{
int
handle_fd
;
int
stream_fd
;
HANDLE
osfh
;
DBUG_ASSERT
(
filename
&&
(
outstream
||
errstream
));
if
((
osfh
=
CreateFile
(
filename
,
GENERIC_READ
|
GENERIC_WRITE
,
FILE_SHARE_READ
|
FILE_SHARE_WRITE
|
FILE_SHARE_DELETE
,
NULL
,
OPEN_ALWAYS
,
FILE_ATTRIBUTE_NORMAL
,
NULL
))
==
INVALID_HANDLE_VALUE
)
return
TRUE
;
if
((
handle_fd
=
_open_osfhandle
((
intptr_t
)
osfh
,
_O_APPEND
|
_O_TEXT
))
==
-
1
)
{
CloseHandle
(
osfh
);
return
TRUE
;
}
if
(
outstream
)
{
stream_fd
=
_fileno
(
outstream
);
if
(
_dup2
(
handle_fd
,
stream_fd
)
<
0
)
{
CloseHandle
(
osfh
);
return
TRUE
;
}
}
if
(
errstream
)
{
stream_fd
=
_fileno
(
errstream
);
if
(
_dup2
(
handle_fd
,
stream_fd
)
<
0
)
{
CloseHandle
(
osfh
);
return
TRUE
;
}
}
_close
(
handle_fd
);
return
FALSE
;
}
#else
extern
"C"
my_bool
reopen_fstreams
(
const
char
*
filename
,
FILE
*
outstream
,
FILE
*
errstream
)
{
if
(
outstream
&&
!
freopen
(
filename
,
"a+"
,
outstream
))
return
TRUE
;
if
(
errstream
&&
!
freopen
(
filename
,
"a+"
,
errstream
))
return
TRUE
;
return
FALSE
;
}
#endif
/*
/*
Unfortunately, there seems to be no good way
Unfortunately, there seems to be no good way
to restore the original streams upon failure.
to restore the original streams upon failure.
*/
*/
static
bool
redirect_std_streams
(
const
char
*
file
)
static
bool
redirect_std_streams
(
const
char
*
file
)
{
{
if
(
freopen
(
file
,
"a+"
,
stdout
)
&&
freopen
(
file
,
"a+"
,
stderr
))
if
(
reopen_fstreams
(
file
,
stdout
,
stderr
))
{
return
TRUE
;
setbuf
(
stderr
,
NULL
);
return
FALSE
;
}
return
TRUE
;
setbuf
(
stderr
,
NULL
);
return
FALSE
;
}
}
bool
flush_error_log
()
bool
flush_error_log
()
{
{
bool
result
=
0
;
bool
result
=
0
;
if
(
opt_error_log
)
if
(
opt_error_log
)
{
{
char
err_renamed
[
FN_REFLEN
],
*
end
;
end
=
strmake
(
err_renamed
,
log_error_file
,
FN_REFLEN
-
5
);
strmov
(
end
,
"-old"
);
mysql_mutex_lock
(
&
LOCK_error_log
);
mysql_mutex_lock
(
&
LOCK_error_log
);
#ifdef __WIN__
if
(
redirect_std_streams
(
log_error_file
))
char
err_temp
[
FN_REFLEN
+
5
];
result
=
1
;
/*
On Windows is necessary a temporary file for to rename
the current error file.
*/
strxmov
(
err_temp
,
err_renamed
,
"-tmp"
,
NullS
);
my_delete
(
err_temp
,
MYF
(
0
));
if
(
freopen
(
err_temp
,
"a+"
,
stdout
))
{
int
fd
;
size_t
bytes
;
uchar
buf
[
IO_SIZE
];
freopen
(
err_temp
,
"a+"
,
stderr
);
setbuf
(
stderr
,
NULL
);
my_delete
(
err_renamed
,
MYF
(
0
));
my_rename
(
log_error_file
,
err_renamed
,
MYF
(
0
));
redirect_std_streams
(
log_error_file
);
if
((
fd
=
my_open
(
err_temp
,
O_RDONLY
,
MYF
(
0
)))
>=
0
)
{
while
((
bytes
=
mysql_file_read
(
fd
,
buf
,
IO_SIZE
,
MYF
(
0
)))
&&
bytes
!=
MY_FILE_ERROR
)
my_fwrite
(
stderr
,
buf
,
bytes
,
MYF
(
0
));
mysql_file_close
(
fd
,
MYF
(
0
));
}
my_delete
(
err_temp
,
MYF
(
0
));
}
else
result
=
1
;
#else
my_rename
(
log_error_file
,
err_renamed
,
MYF
(
0
));
if
(
redirect_std_streams
(
log_error_file
))
result
=
1
;
#endif
mysql_mutex_unlock
(
&
LOCK_error_log
);
mysql_mutex_unlock
(
&
LOCK_error_log
);
}
}
return
result
;
return
result
;
}
}
void
MYSQL_BIN_LOG
::
signal_update
()
void
MYSQL_BIN_LOG
::
signal_update
()
...
...
sql/mysqld.cc
View file @
2c379a1e
...
@@ -192,6 +192,9 @@ typedef fp_except fp_except_t;
...
@@ -192,6 +192,9 @@ typedef fp_except fp_except_t;
# endif
# endif
#endif
#endif
extern
"C"
my_bool
reopen_fstreams
(
const
char
*
filename
,
FILE
*
outstream
,
FILE
*
errstream
);
inline
void
setup_fpu
()
inline
void
setup_fpu
()
{
{
#if defined(__FreeBSD__) && defined(HAVE_IEEEFP_H)
#if defined(__FreeBSD__) && defined(HAVE_IEEEFP_H)
...
@@ -3741,13 +3744,15 @@ static int init_server_components()
...
@@ -3741,13 +3744,15 @@ static int init_server_components()
opt_error_log
=
0
;
// Too long file name
opt_error_log
=
0
;
// Too long file name
else
else
{
{
my_bool
res
;
#ifndef EMBEDDED_LIBRARY
#ifndef EMBEDDED_LIBRARY
if
(
freopen
(
log_error_file
,
"a+"
,
stdout
))
res
=
reopen_fstreams
(
log_error_file
,
stdout
,
stderr
);
#else
res
=
reopen_fstreams
(
log_error_file
,
NULL
,
stderr
);
#endif
#endif
{
if
(
freopen
(
log_error_file
,
"a+"
,
stderr
))
if
(
!
res
)
setbuf
(
stderr
,
NULL
);
setbuf
(
stderr
,
NULL
);
}
}
}
}
}
...
@@ -4460,8 +4465,8 @@ int mysqld_main(int argc, char **argv)
...
@@ -4460,8 +4465,8 @@ int mysqld_main(int argc, char **argv)
#ifdef __WIN__
#ifdef __WIN__
if
(
!
opt_console
)
if
(
!
opt_console
)
{
{
freopen
(
log_error_file
,
"a+"
,
stdout
);
if
(
reopen_fstreams
(
log_error_file
,
stdout
,
stderr
))
freopen
(
log_error_file
,
"a+"
,
stderr
);
unireg_abort
(
1
);
setbuf
(
stderr
,
NULL
);
setbuf
(
stderr
,
NULL
);
FreeConsole
();
// Remove window
FreeConsole
();
// Remove window
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment