summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2016-09-29 12:59:51 +0200
committerSergei Golubchik <serg@mariadb.org>2016-09-29 12:59:51 +0200
commit2ede40e67e41f294a32ba3e4797bc6fc4c070217 (patch)
treeebc7c92dfe7b4f007abd0b331b407ccc61b19578
parentad2076945062f7f6d29752641048071229435391 (diff)
parenta3f11f75499ffc867aefe24c80a9c57fbdfb8ac2 (diff)
downloadmariadb-git-2ede40e67e41f294a32ba3e4797bc6fc4c070217.tar.gz
Merge branch '10.0' into 10.1
-rw-r--r--mysql-test/lib/My/Platform.pm49
-rw-r--r--mysql-test/lib/mtr_io.pl9
-rw-r--r--mysys/my_fopen.c6
-rw-r--r--plugin/feedback/utils.cc13
-rw-r--r--scripts/mysqld_safe.sh6
-rw-r--r--support-files/mysql.server.sh2
6 files changed, 73 insertions, 12 deletions
diff --git a/mysql-test/lib/My/Platform.pm b/mysql-test/lib/My/Platform.pm
index 1776f1008da..110cf8a20e0 100644
--- a/mysql-test/lib/My/Platform.pm
+++ b/mysql-test/lib/My/Platform.pm
@@ -24,7 +24,7 @@ use File::Path;
use base qw(Exporter);
our @EXPORT= qw(IS_CYGWIN IS_WINDOWS IS_WIN32PERL
native_path posix_path mixed_path
- check_socket_path_length process_alive);
+ check_socket_path_length process_alive open_for_append);
BEGIN {
if ($^O eq "cygwin") {
@@ -161,4 +161,51 @@ sub process_alive {
}
+
+use Symbol qw( gensym );
+
+use if $^O eq 'MSWin32', 'Win32API::File', qw( CloseHandle CreateFile GetOsFHandle OsFHandleOpen OPEN_ALWAYS FILE_APPEND_DATA
+ FILE_SHARE_READ FILE_SHARE_WRITE FILE_SHARE_DELETE );
+use if $^O eq 'MSWin32', 'Win32::API';
+
+use constant WIN32API_FILE_NULL => [];
+
+# Open a file for append
+# On Windows we use CreateFile with FILE_APPEND_DATA
+# to insure that writes are atomic, not interleaved
+# with writes by another processes.
+sub open_for_append
+{
+ my ($file) = @_;
+ my $fh = gensym();
+
+ if (IS_WIN32PERL)
+ {
+ my $handle;
+ if (!($handle = CreateFile(
+ $file,
+ FILE_APPEND_DATA(),
+ FILE_SHARE_READ()|FILE_SHARE_WRITE()|FILE_SHARE_DELETE(),
+ WIN32API_FILE_NULL,
+ OPEN_ALWAYS(),# Create if doesn't exist.
+ 0,
+ WIN32API_FILE_NULL,
+ )))
+ {
+ return undef;
+ }
+
+ if (!OsFHandleOpen($fh, $handle, 'wat'))
+ {
+ CloseHandle($handle);
+ return undef;
+ }
+ return $fh;
+ }
+
+ open($fh,">>",$file) or return undef;
+ return $fh;
+}
+
+
1;
diff --git a/mysql-test/lib/mtr_io.pl b/mysql-test/lib/mtr_io.pl
index 8c2803f0427..0de4d9612ac 100644
--- a/mysql-test/lib/mtr_io.pl
+++ b/mysql-test/lib/mtr_io.pl
@@ -21,6 +21,7 @@
use strict;
use Carp;
+use My::Platform;
sub mtr_fromfile ($);
sub mtr_tofile ($@);
@@ -45,10 +46,10 @@ sub mtr_fromfile ($) {
sub mtr_tofile ($@) {
my $file= shift;
-
- open(FILE,">>",$file) or mtr_error("can't open file \"$file\": $!");
- print FILE join("", @_);
- close FILE;
+ my $fh= open_for_append $file;
+ mtr_error("can't open file \"$file\": $!") unless defined($fh);
+ print $fh join("", @_);
+ close $fh;
}
diff --git a/mysys/my_fopen.c b/mysys/my_fopen.c
index 1fa3f9b9b8f..2ac033c8264 100644
--- a/mysys/my_fopen.c
+++ b/mysys/my_fopen.c
@@ -101,6 +101,7 @@ static FILE *my_win_freopen(const char *path, const char *mode, FILE *stream)
HANDLE osfh;
DBUG_ASSERT(path && stream);
+ DBUG_ASSERT(strchr(mode, 'a')); /* We use FILE_APPEND_DATA below */
/* Services don't have stdout/stderr on Windows, so _fileno returns -1. */
if (fd < 0)
@@ -111,15 +112,14 @@ static FILE *my_win_freopen(const char *path, const char *mode, FILE *stream)
fd= _fileno(stream);
}
- if ((osfh= CreateFile(path, GENERIC_READ | GENERIC_WRITE,
+ if ((osfh= CreateFile(path, GENERIC_READ | FILE_APPEND_DATA,
FILE_SHARE_READ | FILE_SHARE_WRITE |
FILE_SHARE_DELETE, NULL,
OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL,
NULL)) == INVALID_HANDLE_VALUE)
return NULL;
- if ((handle_fd= _open_osfhandle((intptr_t)osfh,
- _O_APPEND | _O_TEXT)) == -1)
+ if ((handle_fd= _open_osfhandle((intptr_t)osfh, _O_TEXT)) == -1)
{
CloseHandle(osfh);
return NULL;
diff --git a/plugin/feedback/utils.cc b/plugin/feedback/utils.cc
index b83b69be0ce..dad3d59e76d 100644
--- a/plugin/feedback/utils.cc
+++ b/plugin/feedback/utils.cc
@@ -43,7 +43,11 @@ static const char *get_os_version_name(OSVERSIONINFOEX *ver)
{
DWORD major = ver->dwMajorVersion;
DWORD minor = ver->dwMinorVersion;
-
+ if (major == 10 && minor == 0)
+ {
+ return (ver->wProductType == VER_NT_WORKSTATION) ?
+ "Windows 10" : "Windows Server 2016";
+ }
if (major == 6 && minor == 3)
{
return (ver->wProductType == VER_NT_WORKSTATION)?
@@ -102,7 +106,12 @@ static int uname(struct utsname *buf)
if(version_str && version_str[0])
sprintf(buf->version, "%s %s",version_str, ver.szCSDVersion);
else
- sprintf(buf->version, "%s", ver.szCSDVersion);
+ {
+ /* Fallback for unknown versions, e.g "Windows <major_ver>.<minor_ver>" */
+ sprintf(buf->version, "Windows %d.%d%s",
+ ver.dwMajorVersion, ver.dwMinorVersion,
+ (ver.wProductType == VER_NT_WORKSTATION ? "" : " Server"));
+ }
#ifdef _WIN64
strcpy(buf->machine, "x64");
diff --git a/scripts/mysqld_safe.sh b/scripts/mysqld_safe.sh
index 07bca1c0318..d4d2a0a6c37 100644
--- a/scripts/mysqld_safe.sh
+++ b/scripts/mysqld_safe.sh
@@ -738,6 +738,10 @@ else
logging=syslog
fi
+# close stdout and stderr, everything goes to $logging now
+exec 1>&-
+exec 2>&-
+
USER_OPTION=""
if test -w / -o "$USER" = "root"
then
@@ -768,7 +772,7 @@ if [ ! -d $mysql_unix_port_dir ]
then
if ! `mkdir -p $mysql_unix_port_dir`
then
- echo "Fatal error Can't create database directory '$mysql_unix_port'"
+ log_error "Fatal error Can't create database directory '$mysql_unix_port'"
exit 1
fi
chown $user $mysql_unix_port_dir
diff --git a/support-files/mysql.server.sh b/support-files/mysql.server.sh
index 54f9ff55e3b..145daff6962 100644
--- a/support-files/mysql.server.sh
+++ b/support-files/mysql.server.sh
@@ -308,7 +308,7 @@ case "$mode" in
then
# Give extra arguments to mysqld with the my.cnf file. This script
# may be overwritten at next upgrade.
- $bindir/mysqld_safe --datadir="$datadir" --pid-file="$mysqld_pid_file_path" "$@" >/dev/null &
+ $bindir/mysqld_safe --datadir="$datadir" --pid-file="$mysqld_pid_file_path" "$@" &
wait_for_ready; return_value=$?
# Make lock for RedHat / SuSE