summaryrefslogtreecommitdiff
path: root/mysys
diff options
context:
space:
mode:
Diffstat (limited to 'mysys')
-rw-r--r--mysys/CMakeLists.txt15
-rw-r--r--mysys/errors.c4
-rw-r--r--mysys/lf_alloc-pin.c1
-rw-r--r--mysys/lf_hash.c1
-rw-r--r--mysys/ma_dyncol.c6
-rw-r--r--mysys/mf_cache.c2
-rw-r--r--mysys/mf_iocache.c22
-rw-r--r--mysys/mf_keycache.c2
-rw-r--r--mysys/mf_tempfile.c35
-rw-r--r--mysys/my_alloc.c15
-rw-r--r--mysys/my_atomic_writes.c2
-rw-r--r--mysys/my_bitmap.c11
-rw-r--r--mysys/my_chsize.c2
-rw-r--r--mysys/my_copy.c4
-rw-r--r--mysys/my_cpu.c21
-rw-r--r--mysys/my_delete.c6
-rw-r--r--mysys/my_fopen.c11
-rw-r--r--mysys/my_fstream.c8
-rw-r--r--mysys/my_getopt.c9
-rw-r--r--mysys/my_getwd.c4
-rw-r--r--mysys/my_lib.c6
-rw-r--r--mysys/my_lock.c4
-rw-r--r--mysys/my_lockmem.c2
-rw-r--r--mysys/my_malloc.c5
-rw-r--r--mysys/my_mess.c2
-rw-r--r--mysys/my_mkdir.c2
-rw-r--r--mysys/my_once.c2
-rw-r--r--mysys/my_open.c9
-rw-r--r--mysys/my_pread.c6
-rw-r--r--mysys/my_rdtsc.c223
-rw-r--r--mysys/my_read.c4
-rw-r--r--mysys/my_redel.c6
-rw-r--r--mysys/my_rename.c2
-rw-r--r--mysys/my_rnd.c13
-rw-r--r--mysys/my_setuser.c8
-rw-r--r--mysys/my_static.c2
-rw-r--r--mysys/my_sync.c2
-rw-r--r--mysys/my_timer_cycles.il39
-rw-r--r--mysys/my_win_popen.cc170
-rw-r--r--mysys/my_windac.c202
-rw-r--r--mysys/my_write.c2
-rw-r--r--mysys/thr_alarm.c6
-rw-r--r--mysys/thr_lock.c127
-rw-r--r--mysys/waiting_threads.c1
44 files changed, 324 insertions, 702 deletions
diff --git a/mysys/CMakeLists.txt b/mysys/CMakeLists.txt
index 09d3f726ffc..5f124f4e659 100644
--- a/mysys/CMakeLists.txt
+++ b/mysys/CMakeLists.txt
@@ -48,7 +48,14 @@ SET(MYSYS_SOURCES array.c charset-def.c charset.c checksum.c my_default.c
file_logger.c my_dlerror.c)
IF (WIN32)
- SET (MYSYS_SOURCES ${MYSYS_SOURCES} my_winthread.c my_wincond.c my_winerr.c my_winfile.c my_windac.c my_conio.c my_minidump.cc)
+ SET (MYSYS_SOURCES ${MYSYS_SOURCES}
+ my_winthread.c
+ my_wincond.c
+ my_winerr.c
+ my_winfile.c
+ my_conio.c
+ my_minidump.cc
+ my_win_popen.cc)
ENDIF()
IF(UNIX)
@@ -59,12 +66,6 @@ IF(HAVE_ALARM)
SET(MYSYS_SOURCES ${MYSYS_SOURCES} my_alarm.c)
ENDIF()
-IF(CMAKE_SYSTEM_NAME MATCHES "SunOS" AND CMAKE_C_COMPILER_ID MATCHES "SunPro")
- # Inline assembly template for rdtsc
- SET_SOURCE_FILES_PROPERTIES(my_rdtsc.c
- PROPERTIES COMPILE_FLAGS "${CMAKE_CURRENT_SOURCE_DIR}/my_timer_cycles.il")
-ENDIF()
-
IF(HAVE_LINUX_LARGE_PAGES)
SET(MYSYS_SOURCES ${MYSYS_SOURCES} my_largepage.c)
ENDIF()
diff --git a/mysys/errors.c b/mysys/errors.c
index 1b7a55eb1e5..45a77d8c129 100644
--- a/mysys/errors.c
+++ b/mysys/errors.c
@@ -107,12 +107,12 @@ void init_glob_errs()
void wait_for_free_space(const char *filename, int errors)
{
if (errors == 0)
- my_error(EE_DISK_FULL,MYF(ME_BELL | ME_NOREFRESH | ME_JUST_WARNING),
+ my_error(EE_DISK_FULL,MYF(ME_BELL | ME_ERROR_LOG | ME_WARNING),
filename,my_errno,MY_WAIT_FOR_USER_TO_FIX_PANIC);
if (!(errors % MY_WAIT_GIVE_USER_A_MESSAGE))
my_printf_error(EE_DISK_FULL,
"Retry in %d secs. Message reprinted in %d secs",
- MYF(ME_BELL | ME_NOREFRESH | ME_JUST_WARNING),
+ MYF(ME_BELL | ME_ERROR_LOG | ME_WARNING),
MY_WAIT_FOR_USER_TO_FIX_PANIC,
MY_WAIT_GIVE_USER_A_MESSAGE * MY_WAIT_FOR_USER_TO_FIX_PANIC );
(void) sleep(MY_WAIT_FOR_USER_TO_FIX_PANIC);
diff --git a/mysys/lf_alloc-pin.c b/mysys/lf_alloc-pin.c
index 280cf74e657..f844920a664 100644
--- a/mysys/lf_alloc-pin.c
+++ b/mysys/lf_alloc-pin.c
@@ -102,6 +102,7 @@
#include <my_global.h>
#include <my_sys.h>
#include <lf.h>
+#include "my_cpu.h"
/*
when using alloca() leave at least that many bytes of the stack -
diff --git a/mysys/lf_hash.c b/mysys/lf_hash.c
index 8bff2e3bfa4..90389c01d6a 100644
--- a/mysys/lf_hash.c
+++ b/mysys/lf_hash.c
@@ -28,6 +28,7 @@
#include <mysys_err.h>
#include <my_bit.h>
#include <lf.h>
+#include "my_cpu.h"
/* An element of the list */
typedef struct {
diff --git a/mysys/ma_dyncol.c b/mysys/ma_dyncol.c
index 0085c375aa1..b438d910157 100644
--- a/mysys/ma_dyncol.c
+++ b/mysys/ma_dyncol.c
@@ -865,7 +865,7 @@ dynamic_column_uint_read(DYNAMIC_COLUMN_VALUE *store_it_here,
static size_t dynamic_column_sint_bytes(longlong val)
{
- return dynamic_column_uint_bytes((val << 1) ^
+ return dynamic_column_uint_bytes((((ulonglong) val) << 1) ^
(val < 0 ? 0xffffffffffffffffull : 0));
}
@@ -883,8 +883,8 @@ static enum enum_dyncol_func_result
dynamic_column_sint_store(DYNAMIC_COLUMN *str, longlong val)
{
return dynamic_column_uint_store(str,
- (val << 1) ^
- (val < 0 ? 0xffffffffffffffffULL : 0));
+ (((ulonglong) val) << 1) ^
+ (val < 0 ? 0xffffffffffffffffULL : 0));
}
diff --git a/mysys/mf_cache.c b/mysys/mf_cache.c
index dba5f5b831c..2fec59f4e70 100644
--- a/mysys/mf_cache.c
+++ b/mysys/mf_cache.c
@@ -82,7 +82,7 @@ void close_cached_file(IO_CACHE *cache)
#ifdef CANT_DELETE_OPEN_FILES
if (cache->file_name)
{
- (void) my_delete(cache->file_name,MYF(MY_WME | ME_NOINPUT));
+ (void) my_delete(cache->file_name, MYF(MY_WME));
my_free(cache->file_name);
}
#endif
diff --git a/mysys/mf_iocache.c b/mysys/mf_iocache.c
index 33930316f08..06c6fc088c0 100644
--- a/mysys/mf_iocache.c
+++ b/mysys/mf_iocache.c
@@ -496,10 +496,20 @@ my_bool reinit_io_cache(IO_CACHE *info, enum cache_type type,
{
/*
If we change from WRITE_CACHE to READ_CACHE, assume that everything
- after the current positions should be ignored
+ after the current positions should be ignored. In other cases we
+ update end_of_file as it may have changed since last init.
*/
- if (info->type == WRITE_CACHE && type == READ_CACHE)
- info->end_of_file=my_b_tell(info);
+ if (type == READ_CACHE)
+ {
+ if (info->type == WRITE_CACHE)
+ info->end_of_file= my_b_tell(info);
+ else
+ {
+ if (!(info->myflags & MY_ENCRYPT))
+ info->end_of_file= mysql_file_seek(info->file, 0L,
+ MY_SEEK_END, MYF(0));
+ }
+ }
/* flush cache if we want to reuse it */
if (!clear_cache && my_b_flush_io_cache(info,1))
DBUG_RETURN(1);
@@ -1547,8 +1557,7 @@ int _my_b_async_read(IO_CACHE *info, uchar *Buffer, size_t Count)
if (info->aio_result.result.aio_errno)
{
if (info->myflags & MY_WME)
- my_error(EE_READ, MYF(ME_BELL+ME_WAITTANG),
- my_filename(info->file),
+ my_error(EE_READ, MYF(ME_BELL), my_filename(info->file),
info->aio_result.result.aio_errno);
my_errno=info->aio_result.result.aio_errno;
info->error= -1;
@@ -1641,8 +1650,7 @@ int _my_b_async_read(IO_CACHE *info, uchar *Buffer, size_t Count)
if (Count != use_length)
{ /* Didn't find hole block */
if (info->myflags & (MY_WME | MY_FAE | MY_FNABP) && Count != org_Count)
- my_error(EE_EOFERR, MYF(ME_BELL+ME_WAITTANG),
- my_filename(info->file),my_errno);
+ my_error(EE_EOFERR, MYF(ME_BELL), my_filename(info->file), my_errno);
info->error=(int) (read_length+left_length);
return 1;
}
diff --git a/mysys/mf_keycache.c b/mysys/mf_keycache.c
index 8aa60064e06..f09739ae8af 100644
--- a/mysys/mf_keycache.c
+++ b/mysys/mf_keycache.c
@@ -576,7 +576,7 @@ int init_simple_key_cache(SIMPLE_KEY_CACHE_CB *keycache,
if (blocks < 8)
{
my_errno= ENOMEM;
- my_error(EE_OUTOFMEMORY, MYF(ME_FATALERROR),
+ my_error(EE_OUTOFMEMORY, MYF(ME_FATAL),
blocks * keycache->key_cache_block_size);
goto err;
}
diff --git a/mysys/mf_tempfile.c b/mysys/mf_tempfile.c
index 25bfca344f2..0f1c6d6b1bc 100644
--- a/mysys/mf_tempfile.c
+++ b/mysys/mf_tempfile.c
@@ -65,7 +65,7 @@ File create_temp_file(char *to, const char *dir, const char *prefix,
File file= -1;
DBUG_ENTER("create_temp_file");
- DBUG_PRINT("enter", ("dir: %s, prefix: %s", dir, prefix));
+ DBUG_PRINT("enter", ("dir: %s, prefix: %s", dir ? dir : "(null)", prefix));
DBUG_ASSERT((mode & (O_EXCL | O_TRUNC | O_CREAT | O_RDWR)) == 0);
mode|= O_TRUNC | O_CREAT | O_RDWR; /* not O_EXCL, see Windows code below */
@@ -110,6 +110,35 @@ File create_temp_file(char *to, const char *dir, const char *prefix,
}
}
#elif defined(HAVE_MKSTEMP)
+ if (!dir && ! (dir =getenv("TMPDIR")))
+ dir= DEFAULT_TMPDIR;
+#ifdef O_TMPFILE
+ {
+ static int O_TMPFILE_works= 1;
+
+ if ((MyFlags & MY_TEMPORARY) && O_TMPFILE_works)
+ {
+ /* explictly don't use O_EXCL here has it has a different
+ meaning with O_TMPFILE
+ */
+ if ((file= open(dir, (mode & ~O_CREAT) | O_TMPFILE | O_CLOEXEC,
+ S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP)) >= 0)
+ {
+ my_snprintf(to, FN_REFLEN, "%s/#sql/fd=%d", dir, file);
+ file=my_register_filename(file, to, FILE_BY_O_TMPFILE,
+ EE_CANTCREATEFILE, MyFlags);
+ }
+ else if (errno == EOPNOTSUPP || errno == EINVAL)
+ {
+ my_printf_error(EE_CANTCREATEFILE, "O_TMPFILE is not supported on %s "
+ "(disabling future attempts)",
+ MYF(ME_NOTE | ME_ERROR_LOG_ONLY), dir);
+ O_TMPFILE_works= 0;
+ }
+ }
+ }
+ if (file == -1)
+#endif /* O_TMPFILE */
{
char prefix_buff[30];
uint pfx_len;
@@ -119,8 +148,6 @@ File create_temp_file(char *to, const char *dir, const char *prefix,
prefix ? prefix : "tmp.",
sizeof(prefix_buff)-7),"XXXXXX") -
prefix_buff);
- if (!dir && ! (dir =getenv("TMPDIR")))
- dir= DEFAULT_TMPDIR;
if (strlen(dir)+ pfx_len > FN_REFLEN-2)
{
errno=my_errno= ENAMETOOLONG;
@@ -137,7 +164,7 @@ File create_temp_file(char *to, const char *dir, const char *prefix,
{
int tmp=my_errno;
close(org_file);
- (void) my_delete(to, MYF(MY_WME | ME_NOINPUT));
+ (void) my_delete(to, MYF(MY_WME));
my_errno=tmp;
}
}
diff --git a/mysys/my_alloc.c b/mysys/my_alloc.c
index a7d4ec1c248..a6f38dcb145 100644
--- a/mysys/my_alloc.c
+++ b/mysys/my_alloc.c
@@ -193,7 +193,7 @@ void *alloc_root(MEM_ROOT *mem_root, size_t length)
length+=ALIGN_SIZE(sizeof(USED_MEM));
if (!(next = (USED_MEM*) my_malloc(length,
- MYF(MY_WME | ME_FATALERROR |
+ MYF(MY_WME | ME_FATAL |
MALLOC_FLAG(mem_root->block_size)))))
{
if (mem_root->error_handler)
@@ -249,7 +249,7 @@ void *alloc_root(MEM_ROOT *mem_root, size_t length)
get_size= MY_MAX(get_size, block_size);
if (!(next = (USED_MEM*) my_malloc(get_size,
- MYF(MY_WME | ME_FATALERROR |
+ MYF(MY_WME | ME_FATAL |
MALLOC_FLAG(mem_root->
block_size)))))
{
@@ -495,3 +495,14 @@ void *memdup_root(MEM_ROOT *root, const void *str, size_t len)
memcpy(pos,str,len);
return pos;
}
+
+LEX_CSTRING safe_lexcstrdup_root(MEM_ROOT *root, const LEX_CSTRING str)
+{
+ LEX_CSTRING res;
+ if (str.length)
+ res.str= strmake_root(root, str.str, str.length);
+ else
+ res.str= (const char *)"";
+ res.length= str.length;
+ return res;
+}
diff --git a/mysys/my_atomic_writes.c b/mysys/my_atomic_writes.c
index 7f1e353c121..b383af11ba8 100644
--- a/mysys/my_atomic_writes.c
+++ b/mysys/my_atomic_writes.c
@@ -15,7 +15,7 @@
#include "mysys_priv.h"
-my_bool my_may_have_atomic_write= 0;
+my_bool my_may_have_atomic_write= IF_WIN(1,0);
#ifdef __linux__
diff --git a/mysys/my_bitmap.c b/mysys/my_bitmap.c
index 5111174d749..c69eb4748f7 100644
--- a/mysys/my_bitmap.c
+++ b/mysys/my_bitmap.c
@@ -38,17 +38,6 @@
#include <m_string.h>
#include <my_bit.h>
-
-/* Create a mask of the significant bits for the last byte (1,3,7,..255) */
-
-static inline uchar last_byte_mask(uint bits)
-{
- /* Get the number of used bits-1 (0..7) in the last byte */
- unsigned int const used= (bits - 1U) & 7U;
- /* Return bitmask for the significant bits */
- return ((2U << used) - 1);
-}
-
/*
Create a mask with the upper 'unused' bits set and the lower 'used'
bits clear. The bits within each byte is stored in big-endian order.
diff --git a/mysys/my_chsize.c b/mysys/my_chsize.c
index 4fd443f5364..f1affb80b16 100644
--- a/mysys/my_chsize.c
+++ b/mysys/my_chsize.c
@@ -96,6 +96,6 @@ int my_chsize(File fd, my_off_t newlength, int filler, myf MyFlags)
err:
DBUG_PRINT("error", ("errno: %d", errno));
if (MyFlags & MY_WME)
- my_error(EE_CANT_CHSIZE, MYF(ME_BELL+ME_WAITTANG), my_errno);
+ my_error(EE_CANT_CHSIZE, MYF(ME_BELL), my_errno);
DBUG_RETURN(1);
} /* my_chsize */
diff --git a/mysys/my_copy.c b/mysys/my_copy.c
index f73737828ce..94ad3f6b665 100644
--- a/mysys/my_copy.c
+++ b/mysys/my_copy.c
@@ -112,7 +112,7 @@ int my_copy(const char *from, const char *to, myf MyFlags)
{
my_errno= errno;
if (MyFlags & MY_WME)
- my_error(EE_CHANGE_PERMISSIONS, MYF(ME_BELL+ME_WAITTANG), to, errno);
+ my_error(EE_CHANGE_PERMISSIONS, MYF(ME_BELL), to, errno);
if (MyFlags & MY_FAE)
goto err;
}
@@ -122,7 +122,7 @@ int my_copy(const char *from, const char *to, myf MyFlags)
{
my_errno= errno;
if (MyFlags & MY_WME)
- my_error(EE_CANT_COPY_OWNERSHIP, MYF(ME_BELL+ME_WAITTANG), to, errno);
+ my_error(EE_CANT_COPY_OWNERSHIP, MYF(ME_BELL), to, errno);
if (MyFlags & MY_FAE)
goto err;
}
diff --git a/mysys/my_cpu.c b/mysys/my_cpu.c
index 3b0ef08a326..52500d78ef7 100644
--- a/mysys/my_cpu.c
+++ b/mysys/my_cpu.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2019, MariaDB Corporation.
+/* Copyright (c) 2019, 2020, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -14,28 +14,13 @@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
#include <my_global.h>
-#include <my_atomic.h>
#include <my_cpu.h>
+#include <my_rdtsc.h>
#ifdef HAVE_PAUSE_INSTRUCTION
/** How many times to invoke PAUSE in a loop */
unsigned my_cpu_relax_multiplier = 200;
-# include <stdint.h>
-
-# ifdef _MSC_VER
-# include <intrin.h>
-# define my_timer_cycles __rdtsc
-# elif !defined __x86_64__
-/* On some x86 targets, __rdtsc() causes an unresolved external symbol error,
-instead of being inlined. Let us fall back to my_timer_cycles(), which
-internally invokes rdtsc. */
-# include <my_rdtsc.h>
-# else
-# include <x86intrin.h>
-# define my_timer_cycles __rdtsc
-# endif
-
#define PAUSE4 MY_RELAX_CPU(); MY_RELAX_CPU(); MY_RELAX_CPU(); MY_RELAX_CPU()
#define PAUSE16 PAUSE4; PAUSE4; PAUSE4; PAUSE4
@@ -82,7 +67,7 @@ internally invokes rdtsc. */
*/
void my_cpu_init(void)
{
- uint64_t t0, t1, t2;
+ ulonglong t0, t1, t2;
t0= my_timer_cycles();
PAUSE16;
t1= my_timer_cycles();
diff --git a/mysys/my_delete.c b/mysys/my_delete.c
index cce26643ef7..face960c1eb 100644
--- a/mysys/my_delete.c
+++ b/mysys/my_delete.c
@@ -47,11 +47,9 @@ int my_delete(const char *name, myf MyFlags)
{
my_errno=errno;
if (MyFlags & (MY_FAE+MY_WME))
- my_error(EE_DELETE,MYF(ME_BELL+ME_WAITTANG+(MyFlags & ME_NOINPUT)),
- name,errno);
+ my_error(EE_DELETE, MYF(ME_BELL), name, errno);
}
- else if ((MyFlags & MY_SYNC_DIR) &&
- my_sync_dir_by_file(name, MyFlags))
+ else if ((MyFlags & MY_SYNC_DIR) && my_sync_dir_by_file(name, MyFlags))
err= -1;
DBUG_RETURN(err);
} /* my_delete */
diff --git a/mysys/my_fopen.c b/mysys/my_fopen.c
index 2450ec85d60..a22ffc50626 100644
--- a/mysys/my_fopen.c
+++ b/mysys/my_fopen.c
@@ -18,6 +18,7 @@
#include "my_static.h"
#include <errno.h>
#include "mysys_err.h"
+#include "my_atomic.h"
static void make_ftype(char * to,int flag);
@@ -76,7 +77,7 @@ FILE *my_fopen(const char *filename, int flags, myf MyFlags)
DBUG_PRINT("error",("Got error %d on open",my_errno));
if (MyFlags & (MY_FFNF | MY_FAE | MY_WME))
my_error((flags & O_RDONLY) ? EE_FILENOTFOUND : EE_CANTCREATEFILE,
- MYF(ME_BELL+ME_WAITTANG), filename, my_errno);
+ MYF(ME_BELL), filename, my_errno);
DBUG_RETURN((FILE*) 0);
} /* my_fopen */
@@ -179,8 +180,7 @@ int my_fclose(FILE *fd, myf MyFlags)
{
my_errno=errno;
if (MyFlags & (MY_FAE | MY_WME))
- my_error(EE_BADCLOSE, MYF(ME_BELL+ME_WAITTANG),
- name,errno);
+ my_error(EE_BADCLOSE, MYF(ME_BELL), name, errno);
}
else
statistic_decrement(my_stream_opened, &THR_LOCK_open);
@@ -214,7 +214,7 @@ FILE *my_fdopen(File Filedes, const char *name, int Flags, myf MyFlags)
{
my_errno=errno;
if (MyFlags & (MY_FAE | MY_WME))
- my_error(EE_CANT_OPEN_STREAM, MYF(ME_BELL+ME_WAITTANG),errno);
+ my_error(EE_CANT_OPEN_STREAM, MYF(ME_BELL), errno);
}
else
{
@@ -223,7 +223,8 @@ FILE *my_fdopen(File Filedes, const char *name, int Flags, myf MyFlags)
{
if (my_file_info[Filedes].type != UNOPEN)
{
- thread_safe_decrement32(&my_file_opened); /* File is opened with my_open ! */
+ /* File is opened with my_open ! */
+ my_atomic_add32_explicit(&my_file_opened, -1, MY_MEMORY_ORDER_RELAXED);
}
else
{
diff --git a/mysys/my_fstream.c b/mysys/my_fstream.c
index 8a6db2e8502..a43fe13c9f0 100644
--- a/mysys/my_fstream.c
+++ b/mysys/my_fstream.c
@@ -55,11 +55,11 @@ size_t my_fread(FILE *stream, uchar *Buffer, size_t Count, myf MyFlags)
if (MyFlags & (MY_WME | MY_FAE | MY_FNABP))
{
if (ferror(stream))
- my_error(EE_READ, MYF(ME_BELL+ME_WAITTANG),
+ my_error(EE_READ, MYF(ME_BELL),
my_filename(my_fileno(stream)),errno);
else
if (MyFlags & (MY_NABP | MY_FNABP))
- my_error(EE_EOFERR, MYF(ME_BELL+ME_WAITTANG),
+ my_error(EE_EOFERR, MYF(ME_BELL),
my_filename(my_fileno(stream)),errno);
}
my_errno=errno ? errno : -1;
@@ -140,8 +140,8 @@ size_t my_fwrite(FILE *stream, const uchar *Buffer, size_t Count, myf MyFlags)
{
if (MyFlags & (MY_WME | MY_FAE | MY_FNABP))
{
- my_error(EE_WRITE, MYF(ME_BELL+ME_WAITTANG),
- my_filename(my_fileno(stream)),errno);
+ my_error(EE_WRITE, MYF(ME_BELL),
+ my_filename(my_fileno(stream)), errno);
}
writtenbytes= (size_t) -1; /* Return that we got error */
break;
diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c
index 7d539cd44fe..c4f83475f7b 100644
--- a/mysys/my_getopt.c
+++ b/mysys/my_getopt.c
@@ -79,6 +79,12 @@ my_bool my_getopt_skip_unknown= 0;
*/
my_bool my_getopt_prefix_matching= 1;
+/*
+ This is a flag that can be set in client programs. 1 means that
+ handle_options() will not initialize options to default values.
+*/
+my_bool my_handle_options_init_variables = 1;
+
static void default_reporter(enum loglevel level,
const char *format, ...)
{
@@ -212,7 +218,8 @@ int handle_options(int *argc, char ***argv,
DBUG_ASSERT(argv && *argv);
(*argc)--; /* Skip the program name */
(*argv)++; /* --- || ---- */
- init_variables(longopts, init_one_value);
+ if (my_handle_options_init_variables)
+ init_variables(longopts, init_one_value);
/*
Search for args_separator, if found, then the first part of the
diff --git a/mysys/my_getwd.c b/mysys/my_getwd.c
index c4f18b51f35..cdad96b3a84 100644
--- a/mysys/my_getwd.c
+++ b/mysys/my_getwd.c
@@ -64,7 +64,7 @@ int my_getwd(char * buf, size_t size, myf MyFlags)
if (!getcwd(buf,(uint) (size-2)) && MyFlags & MY_WME)
{
my_errno=errno;
- my_error(EE_GETWD,MYF(ME_BELL+ME_WAITTANG),errno);
+ my_error(EE_GETWD,MYF(ME_BELL),errno);
DBUG_RETURN(-1);
}
#elif defined(HAVE_GETWD)
@@ -104,7 +104,7 @@ int my_setwd(const char *dir, myf MyFlags)
{
my_errno=errno;
if (MyFlags & MY_WME)
- my_error(EE_SETWD,MYF(ME_BELL+ME_WAITTANG),start,errno);
+ my_error(EE_SETWD,MYF(ME_BELL),start,errno);
}
else
{
diff --git a/mysys/my_lib.c b/mysys/my_lib.c
index 8ce23f65fd3..b61a02449bc 100644
--- a/mysys/my_lib.c
+++ b/mysys/my_lib.c
@@ -189,7 +189,7 @@ err_alloc:
(void) closedir(dirp);
err_open:
if (MyFlags & (MY_FAE | MY_WME))
- my_error(EE_DIR, MYF(ME_BELL | ME_WAITTANG), path, my_errno);
+ my_error(EE_DIR, MYF(ME_BELL), path, my_errno);
DBUG_RETURN(NULL);
} /* my_dir */
@@ -312,7 +312,7 @@ error:
_findclose(handle);
my_dirend(&dirh->dir);
if (MyFlags & (MY_FAE | MY_WME))
- my_error(EE_DIR,MYF(ME_BELL | ME_WAITTANG), path, errno);
+ my_error(EE_DIR,MYF(ME_BELL), path, errno);
DBUG_RETURN(NULL);
} /* my_dir */
@@ -362,7 +362,7 @@ MY_STAT *my_stat(const char *path, MY_STAT *stat_area, myf my_flags)
error:
if (my_flags & (MY_FAE+MY_WME))
{
- my_error(EE_STAT, MYF(ME_BELL+ME_WAITTANG),path,my_errno);
+ my_error(EE_STAT, MYF(ME_BELL), path, my_errno);
DBUG_RETURN((MY_STAT *) NULL);
}
DBUG_RETURN((MY_STAT *) NULL);
diff --git a/mysys/my_lock.c b/mysys/my_lock.c
index 3319f6d8cb2..7597436f381 100644
--- a/mysys/my_lock.c
+++ b/mysys/my_lock.c
@@ -219,9 +219,9 @@ int my_lock(File fd, int locktype, my_off_t start, my_off_t length,
if (MyFlags & MY_WME)
{
if (locktype == F_UNLCK)
- my_error(EE_CANTUNLOCK,MYF(ME_BELL+ME_WAITTANG),my_errno);
+ my_error(EE_CANTUNLOCK,MYF(ME_BELL),my_errno);
else
- my_error(EE_CANTLOCK,MYF(ME_BELL+ME_WAITTANG),my_errno);
+ my_error(EE_CANTLOCK,MYF(ME_BELL),my_errno);
}
DBUG_PRINT("error",("my_errno: %d (%d)",my_errno,errno));
DBUG_RETURN(-1);
diff --git a/mysys/my_lockmem.c b/mysys/my_lockmem.c
index 3ce0f07af58..e159502a278 100644
--- a/mysys/my_lockmem.c
+++ b/mysys/my_lockmem.c
@@ -42,7 +42,7 @@ uchar *my_malloc_lock(uint size,myf MyFlags)
if (!(ptr=memalign(pagesize,size)))
{
if (MyFlags & (MY_FAE+MY_WME))
- my_error(EE_OUTOFMEMORY, MYF(ME_BELL+ME_WAITTANG+ME_FATALERROR), size);
+ my_error(EE_OUTOFMEMORY, MYF(ME_BELL+ME_FATAL), size);
DBUG_RETURN(0);
}
success = mlock((uchar*) ptr,size);
diff --git a/mysys/my_malloc.c b/mysys/my_malloc.c
index 55ef2673ef2..d54270a7f20 100644
--- a/mysys/my_malloc.c
+++ b/mysys/my_malloc.c
@@ -106,8 +106,7 @@ void *my_malloc(size_t size, myf my_flags)
if (my_flags & MY_FAE)
error_handler_hook=fatal_error_handler_hook;
if (my_flags & (MY_FAE+MY_WME))
- my_error(EE_OUTOFMEMORY, MYF(ME_BELL + ME_WAITTANG +
- ME_NOREFRESH + ME_FATALERROR),size);
+ my_error(EE_OUTOFMEMORY, MYF(ME_BELL+ME_ERROR_LOG+ME_FATAL),size);
if (my_flags & MY_FAE)
abort();
}
@@ -176,7 +175,7 @@ void *my_realloc(void *oldpoint, size_t size, myf my_flags)
DBUG_RETURN(oldpoint);
my_errno=errno;
if (my_flags & (MY_FAE+MY_WME))
- my_error(EE_OUTOFMEMORY, MYF(ME_BELL + ME_WAITTANG + ME_FATALERROR), size);
+ my_error(EE_OUTOFMEMORY, MYF(ME_BELL + ME_FATAL), size);
}
else
{
diff --git a/mysys/my_mess.c b/mysys/my_mess.c
index 7bc4c038cb6..c9a1aee64b6 100644
--- a/mysys/my_mess.c
+++ b/mysys/my_mess.c
@@ -21,6 +21,8 @@ void my_message_stderr(uint error __attribute__((unused)),
DBUG_ENTER("my_message_stderr");
DBUG_PRINT("enter",("message: %s",str));
(void) fflush(stdout);
+ if (MyFlags & (ME_NOTE | ME_ERROR_LOG_ONLY))
+ DBUG_VOID_RETURN;
if (MyFlags & ME_BELL)
(void) fputc('\007', stderr);
if (my_progname)
diff --git a/mysys/my_mkdir.c b/mysys/my_mkdir.c
index 6c0a01abb73..ea1f66f3b7b 100644
--- a/mysys/my_mkdir.c
+++ b/mysys/my_mkdir.c
@@ -36,7 +36,7 @@ int my_mkdir(const char *dir, int Flags, myf MyFlags)
my_errno=errno;
DBUG_PRINT("error",("error %d when creating direcory %s",my_errno,dir));
if (MyFlags & (MY_FFNF | MY_FAE | MY_WME))
- my_error(EE_CANT_MKDIR, MYF(ME_BELL+ME_WAITTANG), dir, my_errno);
+ my_error(EE_CANT_MKDIR, MYF(ME_BELL), dir, my_errno);
DBUG_RETURN(-1);
}
DBUG_RETURN(0);
diff --git a/mysys/my_once.c b/mysys/my_once.c
index 28a175579fd..e2bea0a4d1e 100644
--- a/mysys/my_once.c
+++ b/mysys/my_once.c
@@ -59,7 +59,7 @@ void* my_once_alloc(size_t Size, myf MyFlags)
{
my_errno=errno;
if (MyFlags & (MY_FAE+MY_WME))
- my_error(EE_OUTOFMEMORY, MYF(ME_BELL+ME_WAITTANG+ME_FATALERROR), get_size);
+ my_error(EE_OUTOFMEMORY, MYF(ME_BELL+ME_FATAL), get_size);
return((uchar*) 0);
}
DBUG_PRINT("test",("my_once_malloc %lu byte malloced", (ulong) get_size));
diff --git a/mysys/my_open.c b/mysys/my_open.c
index 8edef360f92..09fa201c0bd 100644
--- a/mysys/my_open.c
+++ b/mysys/my_open.c
@@ -17,6 +17,7 @@
#include "mysys_err.h"
#include <m_string.h>
#include <errno.h>
+#include "my_atomic.h"
CREATE_NOSYMLINK_FUNCTION(
open_nosymlinks(const char *pathname, int flags, int mode),
@@ -98,14 +99,14 @@ int my_close(File fd, myf MyFlags)
DBUG_PRINT("error",("Got error %d on close",err));
my_errno=errno;
if (MyFlags & (MY_FAE | MY_WME))
- my_error(EE_BADCLOSE, MYF(ME_BELL | ME_WAITTANG | (MyFlags & (ME_JUST_INFO | ME_NOREFRESH))),
+ my_error(EE_BADCLOSE, MYF(ME_BELL | (MyFlags & (ME_NOTE | ME_ERROR_LOG))),
name,errno);
}
if (name)
{
my_free(name);
}
- thread_safe_decrement32(&my_file_opened);
+ my_atomic_add32_explicit(&my_file_opened, -1, MY_MEMORY_ORDER_RELAXED);
DBUG_RETURN(err);
} /* my_close */
@@ -133,7 +134,7 @@ File my_register_filename(File fd, const char *FileName, enum file_type
DBUG_ENTER("my_register_filename");
if ((int) fd >= MY_FILE_MIN)
{
- thread_safe_increment32(&my_file_opened);
+ my_atomic_add32_explicit(&my_file_opened, 1, MY_MEMORY_ORDER_RELAXED);
if ((uint) fd >= my_file_limit)
DBUG_RETURN(fd);
my_file_info[fd].name = (char*) my_strdup(FileName, MyFlags);
@@ -150,7 +151,7 @@ File my_register_filename(File fd, const char *FileName, enum file_type
if (my_errno == EMFILE)
error_message_number= EE_OUT_OF_FILERESOURCES;
my_error(error_message_number,
- MYF(ME_BELL | ME_WAITTANG | (MyFlags & (ME_JUST_INFO | ME_NOREFRESH))),
+ MYF(ME_BELL | (MyFlags & (ME_NOTE | ME_ERROR_LOG))),
FileName, my_errno);
}
DBUG_RETURN(-1);
diff --git a/mysys/my_pread.c b/mysys/my_pread.c
index 9d3fdb3e0ee..56cc91ae083 100644
--- a/mysys/my_pread.c
+++ b/mysys/my_pread.c
@@ -98,11 +98,11 @@ size_t my_pread(File Filedes, uchar *Buffer, size_t Count, my_off_t offset,
{
if (readbytes == (size_t) -1)
my_error(EE_READ,
- MYF(ME_BELL | ME_WAITTANG | (MyFlags & (ME_JUST_INFO | ME_NOREFRESH))),
+ MYF(ME_BELL | (MyFlags & (ME_NOTE | ME_ERROR_LOG))),
my_filename(Filedes),my_errno);
else if (MyFlags & (MY_NABP | MY_FNABP))
my_error(EE_EOFERR,
- MYF(ME_BELL | ME_WAITTANG | (MyFlags & (ME_JUST_INFO | ME_NOREFRESH))),
+ MYF(ME_BELL | (MyFlags & (ME_NOTE | ME_ERROR_LOG))),
my_filename(Filedes),my_errno);
}
if (readbytes == (size_t) -1 || (MyFlags & (MY_FNABP | MY_NABP)))
@@ -187,7 +187,7 @@ size_t my_pwrite(int Filedes, const uchar *Buffer, size_t Count,
if (MyFlags & (MY_NABP | MY_FNABP))
{
if (MyFlags & (MY_WME | MY_FAE | MY_FNABP))
- my_error(EE_WRITE, MYF(ME_BELL | ME_WAITTANG | (MyFlags & (ME_JUST_INFO | ME_NOREFRESH))),
+ my_error(EE_WRITE, MYF(ME_BELL | (MyFlags & (ME_NOTE | ME_ERROR_LOG))),
my_filename(Filedes),my_errno);
DBUG_RETURN(MY_FILE_ERROR); /* Error on write */
}
diff --git a/mysys/my_rdtsc.c b/mysys/my_rdtsc.c
index 605ac20350c..1503a5db442 100644
--- a/mysys/my_rdtsc.c
+++ b/mysys/my_rdtsc.c
@@ -1,4 +1,5 @@
/* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+ Copyright (c) 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -74,10 +75,6 @@
#endif
#endif
-#if defined(HAVE_ASM_MSR_H) && defined(HAVE_RDTSCLL)
-#include <asm/msr.h> /* for rdtscll */
-#endif
-
#if defined(HAVE_SYS_TIMEB_H) && defined(HAVE_FTIME)
#include <sys/timeb.h> /* for ftime */
#endif
@@ -86,190 +83,10 @@
#include <sys/times.h> /* for times */
#endif
-#if defined(__INTEL_COMPILER) && defined(__ia64__) && defined(HAVE_IA64INTRIN_H)
-#include <ia64intrin.h> /* for __GetReg */
-#endif
-
#if defined(__APPLE__) && defined(__MACH__)
#include <mach/mach_time.h>
#endif
-#if defined(__SUNPRO_CC) && defined(__sparcv9) && defined(_LP64) && !defined(__SunOS_5_7)
-extern "C" ulonglong my_timer_cycles_il_sparc64();
-#elif defined(__SUNPRO_CC) && defined(_ILP32) && !defined(__SunOS_5_7)
-extern "C" ulonglong my_timer_cycles_il_sparc32();
-#elif defined(__SUNPRO_CC) && defined(__i386) && defined(_ILP32)
-extern "C" ulonglong my_timer_cycles_il_i386();
-#elif defined(__SUNPRO_CC) && defined(__x86_64) && defined(_LP64)
-extern "C" ulonglong my_timer_cycles_il_x86_64();
-#elif defined(__SUNPRO_C) && defined(__sparcv9) && defined(_LP64) && !defined(__SunOS_5_7)
-ulonglong my_timer_cycles_il_sparc64();
-#elif defined(__SUNPRO_C) && defined(_ILP32) && !defined(__SunOS_5_7)
-ulonglong my_timer_cycles_il_sparc32();
-#elif defined(__SUNPRO_C) && defined(__i386) && defined(_ILP32)
-ulonglong my_timer_cycles_il_i386();
-#elif defined(__SUNPRO_C) && defined(__x86_64) && defined(_LP64)
-ulonglong my_timer_cycles_il_x86_64();
-#endif
-
-#if defined(__INTEL_COMPILER)
-/*
- icc warning #1011 is:
- missing return statement at end of non-void function
-*/
-#pragma warning (disable:1011)
-#endif
-
-/*
- For cycles, we depend on RDTSC for x86 platforms,
- or on time buffer (which is not really a cycle count
- but a separate counter with less than nanosecond
- resolution) for most PowerPC platforms, or on
- gethrtime which is okay for hpux and solaris, or on
- clock_gettime(CLOCK_SGI_CYCLE) for Irix platforms,
- or on read_real_time for aix platforms. There is
- nothing for Alpha platforms, they would be tricky.
-
- On the platforms that do not have a CYCLE timer,
- "wait" events are initialized to use NANOSECOND instead of CYCLE
- during performance_schema initialization (at the server startup).
-
- Linux performance monitor (see "man perf_event_open") can
- provide cycle counter on the platforms that do not have
- other kinds of cycle counters. But we don't use it so far.
-
- ARM notes
- ---------
- During tests on ARMv7 Debian, perf_even_open() based cycle counter provided
- too low frequency with too high overhead:
- MariaDB [performance_schema]> SELECT * FROM performance_timers;
- +-------------+-----------------+------------------+----------------+
- | TIMER_NAME | TIMER_FREQUENCY | TIMER_RESOLUTION | TIMER_OVERHEAD |
- +-------------+-----------------+------------------+----------------+
- | CYCLE | 689368159 | 1 | 970 |
- | NANOSECOND | 1000000000 | 1 | 308 |
- | MICROSECOND | 1000000 | 1 | 417 |
- | MILLISECOND | 1000 | 1000 | 407 |
- | TICK | 127 | 1 | 612 |
- +-------------+-----------------+------------------+----------------+
- Therefore, it was decided not to use perf_even_open() on ARM
- (i.e. go without CYCLE and have "wait" events use NANOSECOND by default).
-*/
-
-ulonglong my_timer_cycles(void)
-{
-#if defined(__GNUC__) && defined(__i386__)
- /* This works much better if compiled with "gcc -O3". */
- ulonglong result;
- __asm__ __volatile__ ("rdtsc" : "=A" (result));
- return result;
-#elif defined(__SUNPRO_C) && defined(__i386)
- __asm("rdtsc");
-#elif defined(__GNUC__) && defined(__x86_64__)
- ulonglong result;
- __asm__ __volatile__ ("rdtsc\n\t" \
- "shlq $32,%%rdx\n\t" \
- "orq %%rdx,%%rax"
- : "=a" (result) :: "%edx");
- return result;
-#elif defined(HAVE_ASM_MSR_H) && defined(HAVE_RDTSCLL)
- {
- ulonglong result;
- rdtscll(result);
- return result;
- }
-#elif defined(_WIN32) && defined(_M_IX86)
- __asm {rdtsc};
-#elif defined(_WIN64) && defined(_M_X64)
- /* For 64-bit Windows: unsigned __int64 __rdtsc(); */
- return __rdtsc();
-#elif defined(__INTEL_COMPILER) && defined(__ia64__) && defined(HAVE_IA64INTRIN_H)
- return (ulonglong) __getReg(_IA64_REG_AR_ITC); /* (3116) */
-#elif defined(__GNUC__) && defined(__ia64__)
- {
- ulonglong result;
- __asm __volatile__ ("mov %0=ar.itc" : "=r" (result));
- return result;
- }
-#elif defined(__GNUC__) && (defined(__powerpc__) || defined(__POWERPC__) || (defined(_POWER) && defined(_AIX52))) && (defined(__64BIT__) || defined(_ARCH_PPC64))
- {
- ulonglong result;
- __asm __volatile__ ("mftb %0" : "=r" (result));
- return result;
- }
-#elif defined(__GNUC__) && (defined(__powerpc__) || defined(__POWERPC__) || (defined(_POWER) && defined(_AIX52))) && (!defined(__64BIT__) && !defined(_ARCH_PPC64))
- {
- /*
- mftbu means "move from time-buffer-upper to result".
- The loop is saying: x1=upper, x2=lower, x3=upper,
- if x1!=x3 there was an overflow so repeat.
- */
- unsigned int x1, x2, x3;
- ulonglong result;
- for (;;)
- {
- __asm __volatile__ ( "mftbu %0" : "=r"(x1) );
- __asm __volatile__ ( "mftb %0" : "=r"(x2) );
- __asm __volatile__ ( "mftbu %0" : "=r"(x3) );
- if (x1 == x3) break;
- }
- result = x1;
- return ( result << 32 ) | x2;
- }
-#elif (defined(__SUNPRO_CC) || defined(__SUNPRO_C)) && defined(__sparcv9) && defined(_LP64) && !defined(__SunOS_5_7)
- return (my_timer_cycles_il_sparc64());
-#elif (defined(__SUNPRO_CC) || defined(__SUNPRO_C)) && defined(_ILP32) && !defined(__SunOS_5_7)
- return (my_timer_cycles_il_sparc32());
-#elif (defined(__SUNPRO_CC) || defined(__SUNPRO_C)) && defined(__i386) && defined(_ILP32)
- /* This is probably redundant for __SUNPRO_C. */
- return (my_timer_cycles_il_i386());
-#elif (defined(__SUNPRO_CC) || defined(__SUNPRO_C)) && defined(__x86_64) && defined(_LP64)
- return (my_timer_cycles_il_x86_64());
-#elif defined(__GNUC__) && defined(__sparcv9) && defined(_LP64) && (__GNUC__>2)
- {
- ulonglong result;
- __asm __volatile__ ("rd %%tick,%0" : "=r" (result));
- return result;
- }
-#elif defined(__GNUC__) && defined(__sparc__) && !defined(_LP64) && (__GNUC__>2)
- {
- union {
- ulonglong wholeresult;
- struct {
- ulong high;
- ulong low;
- } splitresult;
- } result;
- __asm __volatile__ ("rd %%tick,%1; srlx %1,32,%0" : "=r" (result.splitresult.high), "=r" (result.splitresult.low));
- return result.wholeresult;
- }
-#elif defined(__sgi) && defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_SGI_CYCLE)
- {
- struct timespec tp;
- clock_gettime(CLOCK_SGI_CYCLE, &tp);
- return (ulonglong) tp.tv_sec * 1000000000 + (ulonglong) tp.tv_nsec;
- }
-#elif defined(__GNUC__) && defined(__s390__)
- /* covers both s390 and s390x */
- {
- ulonglong result;
- __asm__ __volatile__ ("stck %0" : "=Q" (result) : : "cc");
- return result;
- }
-#elif defined(HAVE_SYS_TIMES_H) && defined(HAVE_GETHRTIME)
- /* gethrtime may appear as either cycle or nanosecond counter */
- return (ulonglong) gethrtime();
-#else
- return 0;
-#endif
-}
-
-#if defined(__INTEL_COMPILER)
-/* re-enable warning#1011 which was only for my_timer_cycles() */
-/* There may be an icc bug which means we must leave disabled. */
-#pragma warning (default:1011)
-#endif
-
/*
For nanoseconds, most platforms have nothing available that
(a) doesn't require bringing in a 40-kb librt.so library
@@ -538,7 +355,7 @@ static ulonglong my_timer_init_frequency(MY_TIMER_INFO *mti)
/*
Call my_timer_init before the first call to my_timer_xxx().
If something must be initialized, it happens here.
- Set: what routine is being used e.g. "asm_x86"
+ Set: what routine is being used e.g. "rdtsc"
Set: function, overhead, actual frequency, resolution.
*/
@@ -551,42 +368,22 @@ void my_timer_init(MY_TIMER_INFO *mti)
/* cycles */
mti->cycles.frequency= 1000000000;
-#if defined(__GNUC__) && defined(__i386__)
- mti->cycles.routine= MY_TIMER_ROUTINE_ASM_X86;
-#elif defined(__SUNPRO_C) && defined(__i386)
- mti->cycles.routine= MY_TIMER_ROUTINE_ASM_X86;
-#elif defined(__GNUC__) && defined(__x86_64__)
- mti->cycles.routine= MY_TIMER_ROUTINE_ASM_X86_64;
-#elif defined(HAVE_ASM_MSR_H) && defined(HAVE_RDTSCLL)
- mti->cycles.routine= MY_TIMER_ROUTINE_RDTSCLL;
-#elif defined(_WIN32) && defined(_M_IX86)
- mti->cycles.routine= MY_TIMER_ROUTINE_ASM_X86_WIN;
-#elif defined(_WIN64) && defined(_M_X64)
+#if defined _WIN32 || defined __i386__ || defined __x86_64__
mti->cycles.routine= MY_TIMER_ROUTINE_RDTSC;
#elif defined(__INTEL_COMPILER) && defined(__ia64__) && defined(HAVE_IA64INTRIN_H)
mti->cycles.routine= MY_TIMER_ROUTINE_ASM_IA64;
#elif defined(__GNUC__) && defined(__ia64__)
mti->cycles.routine= MY_TIMER_ROUTINE_ASM_IA64;
-#elif defined(__GNUC__) && (defined(__powerpc__) || defined(__POWERPC__) || (defined(_POWER) && defined(_AIX52))) && (defined(__64BIT__) || defined(_ARCH_PPC64))
- mti->cycles.routine= MY_TIMER_ROUTINE_ASM_PPC64;
-#elif defined(__GNUC__) && (defined(__powerpc__) || defined(__POWERPC__) || (defined(_POWER) && defined(_AIX52))) && (!defined(__64BIT__) && !defined(_ARCH_PPC64))
- mti->cycles.routine= MY_TIMER_ROUTINE_ASM_PPC;
-#elif (defined(__SUNPRO_CC) || defined(__SUNPRO_C)) && defined(__sparcv9) && defined(_LP64) && !defined(__SunOS_5_7)
- mti->cycles.routine= MY_TIMER_ROUTINE_ASM_SUNPRO_SPARC64;
-#elif (defined(__SUNPRO_CC) || defined(__SUNPRO_C)) && defined(_ILP32) && !defined(__SunOS_5_7)
- mti->cycles.routine= MY_TIMER_ROUTINE_ASM_SUNPRO_SPARC32;
-#elif (defined(__SUNPRO_CC) || defined(__SUNPRO_C)) && defined(__i386) && defined(_ILP32)
- mti->cycles.routine= MY_TIMER_ROUTINE_ASM_SUNPRO_I386;
-#elif (defined(__SUNPRO_CC) || defined(__SUNPRO_C)) && defined(__x86_64) && defined(_LP64)
- mti->cycles.routine= MY_TIMER_ROUTINE_ASM_SUNPRO_X86_64;
+#elif defined __GNUC__ && defined __powerpc__
+ mti->cycles.routine= MY_TIMER_ROUTINE_PPC_GET_TIMEBASE;
#elif defined(__GNUC__) && defined(__sparcv9) && defined(_LP64) && (__GNUC__>2)
mti->cycles.routine= MY_TIMER_ROUTINE_ASM_GCC_SPARC64;
#elif defined(__GNUC__) && defined(__sparc__) && !defined(_LP64) && (__GNUC__>2)
mti->cycles.routine= MY_TIMER_ROUTINE_ASM_GCC_SPARC32;
-#elif defined(__sgi) && defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_SGI_CYCLE)
- mti->cycles.routine= MY_TIMER_ROUTINE_SGI_CYCLE;
#elif defined(__GNUC__) && defined(__s390__)
mti->cycles.routine= MY_TIMER_ROUTINE_ASM_S390;
+#elif defined(__GNUC__) && defined (__aarch64__)
+ mti->cycles.routine= MY_TIMER_ROUTINE_AARCH64;
#elif defined(HAVE_SYS_TIMES_H) && defined(HAVE_GETHRTIME)
mti->cycles.routine= MY_TIMER_ROUTINE_GETHRTIME;
#else
@@ -957,8 +754,8 @@ void my_timer_init(MY_TIMER_INFO *mti)
"include <linux/timex.h>" or "include <asm/timex.h>"
can lead to autoconf or compile errors, depending on system.
- rdtsc, __rdtsc, rdtscll: available for x86 with Linux BSD,
- Solaris, Windows. See "possible flaws and dangers" comments.
+ __rdtsc(): available for IA-32 and AMD64.
+ See "possible flaws and dangers" comments.
times(): what we use for ticks. Should just read the last
(xtime) tick count, therefore should be fast, but usually
@@ -992,7 +789,7 @@ void my_timer_init(MY_TIMER_INFO *mti)
getclock(): documented for Alpha, but not found during tests.
mach_absolute_time() and UpTime() are recommended for Apple.
- Inititally they weren't tried, because asm_ppc seems to do the job.
+ Initially they weren't tried, because ppc_get_timebase seems to do the job.
But now we use mach_absolute_time for nanoseconds.
Any clock-based timer can be affected by NPT (ntpd program),
diff --git a/mysys/my_read.c b/mysys/my_read.c
index 9a78e8d7977..6b4f17e9df6 100644
--- a/mysys/my_read.c
+++ b/mysys/my_read.c
@@ -90,11 +90,11 @@ size_t my_read(File Filedes, uchar *Buffer, size_t Count, myf MyFlags)
{
if (readbytes == (size_t) -1)
my_error(EE_READ,
- MYF(ME_BELL | ME_WAITTANG | (MyFlags & (ME_JUST_INFO | ME_NOREFRESH))),
+ MYF(ME_BELL | (MyFlags & (ME_NOTE | ME_ERROR_LOG))),
my_filename(Filedes), got_errno);
else if (MyFlags & (MY_NABP | MY_FNABP))
my_error(EE_EOFERR,
- MYF(ME_BELL | ME_WAITTANG | (MyFlags & (ME_JUST_INFO | ME_NOREFRESH))),
+ MYF(ME_BELL | (MyFlags & (ME_NOTE | ME_ERROR_LOG))),
my_filename(Filedes), got_errno);
}
if (readbytes == (size_t) -1 ||
diff --git a/mysys/my_redel.c b/mysys/my_redel.c
index 96ab410a382..1a69eaa291f 100644
--- a/mysys/my_redel.c
+++ b/mysys/my_redel.c
@@ -102,7 +102,7 @@ int my_copystat(const char *from, const char *to, int MyFlags)
{
my_errno= errno;
if (MyFlags & (MY_FAE+MY_WME))
- my_error(EE_CHANGE_PERMISSIONS, MYF(ME_BELL+ME_WAITTANG), from, errno);
+ my_error(EE_CHANGE_PERMISSIONS, MYF(ME_BELL), from, errno);
return -1;
}
@@ -110,14 +110,14 @@ int my_copystat(const char *from, const char *to, int MyFlags)
if (statbuf.st_nlink > 1 && MyFlags & MY_LINK_WARNING)
{
if (MyFlags & MY_LINK_WARNING)
- my_error(EE_LINK_WARNING,MYF(ME_BELL+ME_WAITTANG),from,statbuf.st_nlink);
+ my_error(EE_LINK_WARNING,MYF(ME_BELL),from,statbuf.st_nlink);
}
/* Copy ownership */
if (chown(to, statbuf.st_uid, statbuf.st_gid))
{
my_errno= errno;
if (MyFlags & MY_WME)
- my_error(EE_CHANGE_OWNERSHIP, MYF(ME_BELL+ME_WAITTANG), from, errno);
+ my_error(EE_CHANGE_OWNERSHIP, MYF(ME_BELL), from, errno);
if (MyFlags & MY_FAE)
return -1;
}
diff --git a/mysys/my_rename.c b/mysys/my_rename.c
index 23dbec2d7ff..389994b9a09 100644
--- a/mysys/my_rename.c
+++ b/mysys/my_rename.c
@@ -101,7 +101,7 @@ int my_rename(const char *from, const char *to, myf MyFlags)
my_errno= errno;
error = -1;
if (MyFlags & (MY_FAE+MY_WME))
- my_error(EE_LINK, MYF(ME_BELL+ME_WAITTANG),from,to,my_errno);
+ my_error(EE_LINK, MYF(ME_BELL),from,to,my_errno);
}
else if (MyFlags & MY_SYNC_DIR)
{
diff --git a/mysys/my_rnd.c b/mysys/my_rnd.c
index c38682a2012..0af251b4ade 100644
--- a/mysys/my_rnd.c
+++ b/mysys/my_rnd.c
@@ -78,20 +78,11 @@ double my_rnd(struct my_rnd_struct *rand_st)
double my_rnd_ssl(struct my_rnd_struct *rand_st)
{
-
-#if defined(HAVE_YASSL) || defined(HAVE_OPENSSL)
- int rc;
- unsigned int res;
-
-#if defined(HAVE_YASSL)
- rc= yaSSL::RAND_bytes((unsigned char *) &res, sizeof (unsigned int));
-#else
+#if defined(HAVE_OPENSSL)
rc= RAND_bytes((unsigned char *) &res, sizeof (unsigned int));
-#endif /* HAVE_YASSL */
-
if (rc)
return (double)res / (double)UINT_MAX;
-#endif /* defined(HAVE_YASSL) || defined(HAVE_OPENSSL) */
+#endif /* defined(HAVE_OPENSSL) */
return my_rnd(rand_st);
}
diff --git a/mysys/my_setuser.c b/mysys/my_setuser.c
index 14ab04dd10f..e35d6602aca 100644
--- a/mysys/my_setuser.c
+++ b/mysys/my_setuser.c
@@ -27,7 +27,7 @@ struct passwd *my_check_user(const char *user, myf MyFlags)
my_errno= EPERM;
if (MyFlags & MY_WME)
my_printf_error(my_errno, "One can only use the --user switch if "
- "running as root", MYF(ME_JUST_WARNING|ME_NOREFRESH));
+ "running as root", MYF(ME_WARNING|ME_ERROR_LOG));
}
}
DBUG_RETURN(NULL);
@@ -38,7 +38,7 @@ struct passwd *my_check_user(const char *user, myf MyFlags)
{
my_errno= EINVAL;
my_printf_error(my_errno, "Please consult the Knowledge Base to find "
- "out how to run mysqld as root!", MYF(ME_NOREFRESH));
+ "out how to run mysqld as root!", MYF(ME_ERROR_LOG));
}
DBUG_RETURN(NULL);
}
@@ -54,7 +54,7 @@ struct passwd *my_check_user(const char *user, myf MyFlags)
{
my_errno= EINVAL;
my_printf_error(my_errno, "Can't change to run as user '%s'. Please "
- "check that the user exists!", MYF(ME_NOREFRESH), user);
+ "check that the user exists!", MYF(ME_ERROR_LOG), user);
DBUG_RETURN(NULL);
}
}
@@ -74,7 +74,7 @@ int my_set_user(const char *user, struct passwd *user_info, myf MyFlags)
{
my_errno= errno;
if (MyFlags & MY_WME)
- my_printf_error(errno, "Cannot change uid/gid (errno: %d)", MYF(ME_NOREFRESH),
+ my_printf_error(errno, "Cannot change uid/gid (errno: %d)", MYF(ME_ERROR_LOG),
errno);
DBUG_RETURN(my_errno);
}
diff --git a/mysys/my_static.c b/mysys/my_static.c
index 2b5f6c3eb1d..fc4c60bc237 100644
--- a/mysys/my_static.c
+++ b/mysys/my_static.c
@@ -106,7 +106,7 @@ my_bool my_disable_copystat_in_redel=0;
/* Typelib by all clients */
const char *sql_protocol_names_lib[] =
-{ "TCP", "SOCKET", "PIPE", "MEMORY", NullS };
+{ "TCP", "SOCKET", "PIPE", NullS };
TYPELIB sql_protocol_typelib ={ array_elements(sql_protocol_names_lib) - 1, "",
sql_protocol_names_lib, NULL };
diff --git a/mysys/my_sync.c b/mysys/my_sync.c
index 5a21a511dda..736d97d14ef 100644
--- a/mysys/my_sync.c
+++ b/mysys/my_sync.c
@@ -122,7 +122,7 @@ int my_sync(File fd, myf my_flags)
res= 0;
}
else if (my_flags & MY_WME)
- my_error(EE_SYNC, MYF(ME_BELL+ME_WAITTANG), my_filename(fd), my_errno);
+ my_error(EE_SYNC, MYF(ME_BELL), my_filename(fd), my_errno);
}
else
{
diff --git a/mysys/my_timer_cycles.il b/mysys/my_timer_cycles.il
deleted file mode 100644
index f6eb922c8fc..00000000000
--- a/mysys/my_timer_cycles.il
+++ /dev/null
@@ -1,39 +0,0 @@
-/* Copyright (c) 2008 MySQL AB, 2009 Sun Microsystems, Inc.
- Use is subject to license terms.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; version 2 of the License.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */
-
-/* Sun Studio SPARC inline templates for cycle timer */
-/* Sun Studio i386 and x86_64 inline templates for cycle timer */
-/* I didn't say ".volatile" or ".nonvolatile". */
-
-.inline my_timer_cycles_il_sparc64,0
-rd %tick,%o0
-.end
-
-.inline my_timer_cycles_il_sparc32,0
-rd %tick,%o2
-srlx %o2,32,%o0
-sra %o2,0,%o1
-.end
-
-.inline my_timer_cycles_il_i386,0
-rdtsc
-.end
-
-.inline my_timer_cycles_il_x86_64,0
-rdtsc
-shlq $32,%rdx
-orq %rdx,%rax
-.end
diff --git a/mysys/my_win_popen.cc b/mysys/my_win_popen.cc
new file mode 100644
index 00000000000..f41f54100f1
--- /dev/null
+++ b/mysys/my_win_popen.cc
@@ -0,0 +1,170 @@
+/* 2019, MariaDB Corporation.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; version 2 of the License.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
+
+/*
+ Replacement of the buggy implementations of popen in Windows CRT
+*/
+#include <windows.h>
+#include <fcntl.h>
+#include <io.h>
+#include <mutex>
+#include <stdlib.h>
+#include <unordered_map>
+
+enum
+{
+ REDIRECT_STDIN= 'w',
+ REDIRECT_STDOUT= 'r'
+};
+
+/** Map from FILE* returned by popen() to corresponding process handle.*/
+static std::unordered_map<FILE *, HANDLE> popen_map;
+/* Mutex to protect the map.*/
+static std::mutex popen_mtx;
+
+/**
+Creates a FILE* from HANDLE.
+*/
+static FILE *make_fp(HANDLE *handle, const char *mode)
+{
+ int flags = 0;
+
+ if (mode[0] == REDIRECT_STDOUT)
+ flags |= O_RDONLY;
+ switch (mode[1])
+ {
+ case 't':
+ flags |= _O_TEXT;
+ break;
+ case 'b':
+ flags |= _O_BINARY;
+ break;
+ }
+
+ int fd= _open_osfhandle((intptr_t) *handle, flags);
+ if (fd < 0)
+ return NULL;
+ FILE *fp= fdopen(fd, mode);
+ if (!fp)
+ {
+ /* Closing file descriptor also closes underlying handle.*/
+ close(fd);
+ *handle= 0;
+ }
+ return fp;
+}
+
+/** A home-backed version of popen(). */
+extern "C" FILE *my_win_popen(const char *cmd, const char *mode)
+{
+ FILE *fp(0);
+ char type= mode[0];
+ HANDLE parent_pipe_end(0);
+ HANDLE child_pipe_end(0);
+ PROCESS_INFORMATION pi{};
+ STARTUPINFO si{};
+ std::string command_line;
+
+ /* Create a pipe between this and child process.*/
+ SECURITY_ATTRIBUTES sa_attr{};
+ sa_attr.nLength= sizeof(SECURITY_ATTRIBUTES);
+ sa_attr.bInheritHandle= TRUE;
+ switch (type)
+ {
+ case REDIRECT_STDIN:
+ if (!CreatePipe(&child_pipe_end, &parent_pipe_end, &sa_attr, 0))
+ goto error;
+ break;
+ case REDIRECT_STDOUT:
+ if (!CreatePipe(&parent_pipe_end, &child_pipe_end, &sa_attr, 0))
+ goto error;
+ break;
+ default:
+ /* Unknown mode, éxpected "r", "rt", "w", "wt" */
+ abort();
+ }
+ if (!SetHandleInformation(parent_pipe_end, HANDLE_FLAG_INHERIT, 0))
+ goto error;
+
+ /* Start child process with redirected output.*/
+
+ si.cb= sizeof(STARTUPINFO);
+ si.hStdError= GetStdHandle(STD_ERROR_HANDLE);
+ si.hStdOutput= (type == REDIRECT_STDOUT) ? child_pipe_end
+ : GetStdHandle(STD_OUTPUT_HANDLE);
+ si.hStdInput= (type == REDIRECT_STDIN) ? child_pipe_end
+ : GetStdHandle(STD_INPUT_HANDLE);
+
+ si.dwFlags|= STARTF_USESTDHANDLES;
+ command_line.append("cmd.exe /c ").append(cmd);
+
+ if (!CreateProcess(0, (LPSTR) command_line.c_str(), 0, 0, TRUE, 0, 0, 0, &si,
+ &pi))
+ goto error;
+
+ CloseHandle(pi.hThread);
+ CloseHandle(child_pipe_end);
+ child_pipe_end= 0;
+
+ fp= make_fp(&parent_pipe_end, mode);
+ if (fp)
+ {
+ std::unique_lock<std::mutex> lk(popen_mtx);
+ popen_map[fp]= pi.hProcess;
+ return fp;
+ }
+
+error:
+ for (auto handle : { parent_pipe_end, child_pipe_end })
+ {
+ if (handle)
+ CloseHandle(handle);
+ }
+
+ if (pi.hProcess)
+ {
+ TerminateProcess(pi.hProcess, 1);
+ CloseHandle(pi.hProcess);
+ }
+ return NULL;
+}
+
+/** A home-backed version of pclose(). */
+
+extern "C" int my_win_pclose(FILE *fp)
+{
+ /* Find process entry for given file pointer.*/
+ std::unique_lock<std::mutex> lk(popen_mtx);
+ HANDLE proc= popen_map[fp];
+ if (!proc)
+ {
+ errno= EINVAL;
+ return -1;
+ }
+ popen_map.erase(fp);
+ lk.unlock();
+
+ fclose(fp);
+
+ /* Wait for process to complete, return its exit code.*/
+ DWORD ret;
+ if (WaitForSingleObject(proc, INFINITE) || !GetExitCodeProcess(proc, &ret))
+ {
+ ret= -1;
+ errno= EINVAL;
+ }
+ CloseHandle(proc);
+ return ret;
+}
diff --git a/mysys/my_windac.c b/mysys/my_windac.c
deleted file mode 100644
index 9a2686a44f4..00000000000
--- a/mysys/my_windac.c
+++ /dev/null
@@ -1,202 +0,0 @@
-/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; version 2 of the License.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */
-
-#include "mysys_priv.h"
-#include "m_string.h"
-#ifdef __WIN__
-
-/*
- Auxiliary structure to store pointers to the data which we need to keep
- around while SECURITY_ATTRIBUTES is in use.
-*/
-
-typedef struct st_my_security_attr
-{
- PSID everyone_sid;
- PACL dacl;
-} My_security_attr;
-
-
-/*
- Allocate and initialize SECURITY_ATTRIBUTES setting up access
- rights for the owner and group `Everybody'.
-
- SYNOPSIS
- my_security_attr_create()
- psa [OUT] pointer to store the pointer to SA in
- perror [OUT] pointer to store error message if there was an
- error
- owner_rights [IN] access rights for the owner
- everyone_rights [IN] access rights for group Everybody
-
- DESCRIPTION
- Set up the security attributes to provide clients with sufficient
- access rights to a kernel object. We need this function
- because if we simply grant all access to everybody (by installing
- a NULL DACL) a mailicious user can attempt a denial of service
- attack by taking ownership over the kernel object. Upon successful
- return `psa' contains a pointer to SECUIRITY_ATTRIBUTES that can be used
- to create kernel objects with proper access rights.
-
- RETURN
- 0 success, psa is 0 or points to a valid SA structure,
- perror is left intact
- !0 error, SA is set to 0, error message is stored in perror
-*/
-
-int my_security_attr_create(SECURITY_ATTRIBUTES **psa, const char **perror,
- DWORD owner_rights, DWORD everyone_rights)
-{
- /* Top-level SID authority */
- SID_IDENTIFIER_AUTHORITY world_auth= SECURITY_WORLD_SID_AUTHORITY;
- PSID everyone_sid= 0;
- HANDLE htoken= 0;
- SECURITY_ATTRIBUTES *sa= 0;
- PACL dacl= 0;
- DWORD owner_token_length, dacl_length;
- SECURITY_DESCRIPTOR *sd;
- PTOKEN_USER owner_token;
- PSID owner_sid;
- My_security_attr *attr;
-
- /*
- Get SID of Everyone group. Easier to retrieve all SIDs each time
- this function is called than worry about thread safety.
- */
- if (! AllocateAndInitializeSid(&world_auth, 1, SECURITY_WORLD_RID,
- 0, 0, 0, 0, 0, 0, 0, &everyone_sid))
- {
- *perror= "Failed to retrieve the SID of Everyone group";
- goto error;
- }
-
- /*
- Get SID of the owner. Using GetSecurityInfo this task can be done
- in just one call instead of five, but GetSecurityInfo declared in
- aclapi.h, so I hesitate to use it.
- SIC: OpenThreadToken works only if there is an active impersonation
- token, hence OpenProcessToken is used.
- */
- if (! OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &htoken))
- {
- *perror= "Failed to retrieve thread access token";
- goto error;
- }
- GetTokenInformation(htoken, TokenUser, 0, 0, &owner_token_length);
-
- if (! my_multi_malloc(MYF(MY_WME),
- &sa, ALIGN_SIZE(sizeof(SECURITY_ATTRIBUTES)) +
- sizeof(My_security_attr),
- &sd, sizeof(SECURITY_DESCRIPTOR),
- &owner_token, owner_token_length,
- 0))
- {
- *perror= "Failed to allocate memory for SECURITY_ATTRIBUTES";
- goto error;
- }
- bzero(owner_token, owner_token_length);
- if (! GetTokenInformation(htoken, TokenUser, owner_token,
- owner_token_length, &owner_token_length))
- {
- *perror= "GetTokenInformation failed";
- goto error;
- }
- owner_sid= owner_token->User.Sid;
-
- if (! IsValidSid(owner_sid))
- {
- *perror= "IsValidSid failed";
- goto error;
- }
-
- /* Calculate the amount of memory that must be allocated for the DACL */
- dacl_length= sizeof(ACL) + (sizeof(ACCESS_ALLOWED_ACE)-sizeof(DWORD)) * 2 +
- GetLengthSid(everyone_sid) + GetLengthSid(owner_sid);
-
- /* Create an ACL */
- if (! (dacl= (PACL) my_malloc(dacl_length, MYF(MY_ZEROFILL|MY_WME))))
- {
- *perror= "Failed to allocate memory for DACL";
- goto error;
- }
- if (! InitializeAcl(dacl, dacl_length, ACL_REVISION))
- {
- *perror= "Failed to initialize DACL";
- goto error;
- }
- if (! AddAccessAllowedAce(dacl, ACL_REVISION, everyone_rights, everyone_sid))
- {
- *perror= "Failed to set up DACL";
- goto error;
- }
- if (! AddAccessAllowedAce(dacl, ACL_REVISION, owner_rights, owner_sid))
- {
- *perror= "Failed to set up DACL";
- goto error;
- }
- if (! InitializeSecurityDescriptor(sd, SECURITY_DESCRIPTOR_REVISION))
- {
- *perror= "Could not initialize security descriptor";
- goto error;
- }
- if (! SetSecurityDescriptorDacl(sd, TRUE, dacl, FALSE))
- {
- *perror= "Failed to install DACL";
- goto error;
- }
-
- sa->nLength= sizeof(*sa);
- sa->bInheritHandle= TRUE;
- sa->lpSecurityDescriptor= sd;
- /* Save pointers to everyone_sid and dacl to be able to clean them up */
- attr= (My_security_attr*) (((char*) sa) + ALIGN_SIZE(sizeof(*sa)));
- attr->everyone_sid= everyone_sid;
- attr->dacl= dacl;
- *psa= sa;
-
- CloseHandle(htoken);
- return 0;
-error:
- if (everyone_sid)
- FreeSid(everyone_sid);
- if (htoken)
- CloseHandle(htoken);
- my_free(sa);
- my_free(dacl);
- *psa= 0;
- return 1;
-}
-
-/*
- Cleanup security attributes freeing used memory.
-
- SYNOPSIS
- my_security_attr_free()
- sa security attributes
-*/
-
-void my_security_attr_free(SECURITY_ATTRIBUTES *sa)
-{
- if (sa)
- {
- My_security_attr *attr= (My_security_attr*)
- (((char*)sa) + ALIGN_SIZE(sizeof(*sa)));
- FreeSid(attr->everyone_sid);
- my_free(attr->dacl);
- my_free(sa);
- }
-}
-
-#endif /* __WIN__ */
diff --git a/mysys/my_write.c b/mysys/my_write.c
index 53288b43f2e..06914b25641 100644
--- a/mysys/my_write.c
+++ b/mysys/my_write.c
@@ -107,7 +107,7 @@ size_t my_write(File Filedes, const uchar *Buffer, size_t Count, myf MyFlags)
{
if (MyFlags & (MY_WME | MY_FAE | MY_FNABP))
{
- my_error(EE_WRITE, MYF(ME_BELL | ME_WAITTANG | (MyFlags & (ME_JUST_INFO | ME_NOREFRESH))),
+ my_error(EE_WRITE, MYF(ME_BELL | (MyFlags & (ME_NOTE | ME_ERROR_LOG))),
my_filename(Filedes),my_errno);
}
DBUG_RETURN(MY_FILE_ERROR); /* Error on read */
diff --git a/mysys/thr_alarm.c b/mysys/thr_alarm.c
index 8a89762de2a..553dc55bfc3 100644
--- a/mysys/thr_alarm.c
+++ b/mysys/thr_alarm.c
@@ -731,7 +731,8 @@ static void *signal_hand(void *arg __attribute__((unused)))
DBUG_PRINT("info",("Starting signal and alarm handling thread"));
for(;;)
{
- while ((error=my_sigwait(&set,&sig)) == EINTR)
+ int code;
+ while ((error=my_sigwait(&set,&sig,&code)) == EINTR)
printf("sigwait restarted\n");
if (error)
{
@@ -805,8 +806,7 @@ int main(int argc __attribute__((unused)),char **argv __attribute__((unused)))
/* Start signal thread and wait for it to start */
mysql_mutex_lock(&LOCK_thread_count);
- mysql_thread_create(0,
- &tid, &thr_attr, signal_hand, NULL);
+ mysql_thread_create(0, &tid, &thr_attr, signal_hand, NULL);
mysql_cond_wait(&COND_thread_count, &LOCK_thread_count);
mysql_mutex_unlock(&LOCK_thread_count);
DBUG_PRINT("info",("signal thread created"));
diff --git a/mysys/thr_lock.c b/mysys/thr_lock.c
index c798c8595e7..363e1a1ea26 100644
--- a/mysys/thr_lock.c
+++ b/mysys/thr_lock.c
@@ -95,24 +95,6 @@ my_bool thr_lock_inited=0;
ulong locks_immediate = 0L, locks_waited = 0L;
enum thr_lock_type thr_upgraded_concurrent_insert_lock = TL_WRITE;
-#ifdef WITH_WSREP
-static wsrep_thd_is_brute_force_fun wsrep_thd_is_brute_force= NULL;
-static wsrep_abort_thd_fun wsrep_abort_thd= NULL;
-static my_bool wsrep_debug;
-static my_bool wsrep_convert_LOCK_to_trx;
-static wsrep_on_fun wsrep_on = NULL;
-
-void wsrep_thr_lock_init(
- wsrep_thd_is_brute_force_fun bf_fun, wsrep_abort_thd_fun abort_fun,
- my_bool debug, my_bool convert_LOCK_to_trx, wsrep_on_fun on_fun
-) {
- wsrep_thd_is_brute_force = bf_fun;
- wsrep_abort_thd = abort_fun;
- wsrep_debug = debug;
- wsrep_convert_LOCK_to_trx= convert_LOCK_to_trx;
- wsrep_on = on_fun;
-}
-#endif
/* The following constants are only for debug output */
#define MAX_THREADS 1000
#define MAX_LOCKS 1000
@@ -652,93 +634,6 @@ wait_for_lock(struct st_lock_list *wait, THR_LOCK_DATA *data,
DBUG_RETURN(result);
}
-#ifdef WITH_WSREP
-/*
- * If brute force applier would need to wait for a thr lock,
- * it needs to make sure that it will get the lock without (too much)
- * delay.
- * We identify here the owners of blocking locks and ask them to
- * abort. We then put our lock request in the first place in the
- * wait queue. When lock holders abort (one by one) the lock release
- * algorithm should grant the lock to us. We rely on this and proceed
- * to wait_for_locks().
- * wsrep_break_locks() should be called in all the cases, where lock
- * wait would happen.
- *
- * TODO: current implementation might not cover all possible lock wait
- * situations. This needs an review still.
- * TODO: lock release, might favor some other lock (instead our bf).
- * This needs an condition to check for bf locks first.
- * TODO: we still have a debug fprintf, this should be removed
- */
-static my_bool
-wsrep_break_lock(
- THR_LOCK_DATA *data, struct st_lock_list *lock_queue1,
- struct st_lock_list *wait_queue)
-{
- if (wsrep_on && wsrep_on(data->owner->mysql_thd) &&
- wsrep_thd_is_brute_force &&
- wsrep_thd_is_brute_force(data->owner->mysql_thd, TRUE))
- {
- THR_LOCK_DATA *holder;
-
- /* if locking session conversion to transaction has been enabled,
- we know that this conflicting lock must be read lock and furthermore,
- lock holder is read-only. It is safe to wait for him.
- */
-#ifdef TODO_WHEN_LOCK_TABLES_IS_A_TRANSACTION
- if (wsrep_convert_LOCK_to_trx &&
- (THD*)(data->owner->mysql_thd)->in_lock_tables)
- {
- if (wsrep_debug)
- fprintf(stderr,"WSREP wsrep_break_lock read lock untouched\n");
- return FALSE;
- }
-#endif
- if (wsrep_debug)
- fprintf(stderr,"WSREP wsrep_break_lock aborting locks\n");
-
- /* aborting lock holder(s) here */
- for (holder=(lock_queue1) ? lock_queue1->data : NULL;
- holder;
- holder=holder->next)
- {
- if (!wsrep_thd_is_brute_force(holder->owner->mysql_thd, TRUE))
- {
- wsrep_abort_thd(data->owner->mysql_thd,
- holder->owner->mysql_thd, FALSE);
- }
- else
- {
- if (wsrep_debug)
- fprintf(stderr,"WSREP wsrep_break_lock skipping BF lock conflict\n");
- return FALSE;
- }
- }
-
- /* Add our lock to the head of the wait queue */
- if (*(wait_queue->last)==wait_queue->data)
- {
- wait_queue->last=&data->next;
- assert(wait_queue->data==0);
- }
- else
- {
- assert(wait_queue->data!=0);
- wait_queue->data->prev=&data->next;
- }
- data->next=wait_queue->data;
- data->prev=&wait_queue->data;
- wait_queue->data=data;
- data->cond=get_cond();
-
- statistic_increment(locks_immediate,&THR_LOCK_lock);
- return TRUE;
- }
- return FALSE;
-}
-#endif
-
static enum enum_thr_lock_result
thr_lock(THR_LOCK_DATA *data, THR_LOCK_INFO *owner, ulong lock_wait_timeout)
{
@@ -746,9 +641,6 @@ thr_lock(THR_LOCK_DATA *data, THR_LOCK_INFO *owner, ulong lock_wait_timeout)
enum enum_thr_lock_result result= THR_LOCK_SUCCESS;
struct st_lock_list *wait_queue;
enum thr_lock_type lock_type= data->type;
-#ifdef WITH_WSREP
- my_bool wsrep_lock_inserted= FALSE;
-#endif
MYSQL_TABLE_WAIT_VARIABLES(locker, state) /* no ';' */
DBUG_ENTER("thr_lock");
@@ -845,13 +737,6 @@ thr_lock(THR_LOCK_DATA *data, THR_LOCK_INFO *owner, ulong lock_wait_timeout)
lock but a high priority write waiting in the write_wait queue.
In the latter case we should yield the lock to the writer.
*/
-#ifdef WITH_WSREP
- if (wsrep_break_lock(data, &lock->write, &lock->read_wait))
- {
- wsrep_lock_inserted= TRUE;
- }
-#endif
-
wait_queue= &lock->read_wait;
}
else /* Request for WRITE lock */
@@ -997,20 +882,8 @@ thr_lock(THR_LOCK_DATA *data, THR_LOCK_INFO *owner, ulong lock_wait_timeout)
(ulong) lock->read.data->owner->thread_id,
data->type));
}
-#ifdef WITH_WSREP
- if (wsrep_break_lock(data, &lock->write, &lock->write_wait))
- {
- wsrep_lock_inserted= TRUE;
- }
-#endif
-
wait_queue= &lock->write_wait;
}
- /* Can't get lock yet; Wait for it */
-#ifdef WITH_WSREP
- if (wsrep_lock_inserted && wsrep_on(data->owner->mysql_thd))
- DBUG_RETURN(wait_for_lock(wait_queue, data, 1, lock_wait_timeout));
-#endif
result= wait_for_lock(wait_queue, data, 0, lock_wait_timeout);
MYSQL_END_TABLE_LOCK_WAIT(locker);
DBUG_RETURN(result);
diff --git a/mysys/waiting_threads.c b/mysys/waiting_threads.c
index 4564059b31a..1441c25cc59 100644
--- a/mysys/waiting_threads.c
+++ b/mysys/waiting_threads.c
@@ -175,6 +175,7 @@
#include <my_global.h>
#include <waiting_threads.h>
#include <m_string.h>
+#include "my_cpu.h"
/* status variables */