diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2018-01-04 09:22:59 +0200 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2018-01-04 09:22:59 +0200 |
commit | 145ae15a33210e13d33d6f41b145b3f04cab2263 (patch) | |
tree | 02810e3c0d629f7d7def2dbc663154cbdb53242f /mysys | |
parent | acd2862e65a6555fba6065b7b4ded8513e2ce37c (diff) | |
parent | 1a1bda2222e0c2ab41baed1510f6fbca80c20d31 (diff) | |
download | mariadb-git-145ae15a33210e13d33d6f41b145b3f04cab2263.tar.gz |
Merge bb-10.2-ext into 10.3
Diffstat (limited to 'mysys')
-rw-r--r-- | mysys/mf_iocache.c | 11 | ||||
-rw-r--r-- | mysys/mf_iocache2.c | 27 | ||||
-rw-r--r-- | mysys/my_default.c | 6 | ||||
-rw-r--r-- | mysys/my_malloc.c | 2 | ||||
-rw-r--r-- | mysys/my_read.c | 40 | ||||
-rw-r--r-- | mysys/typelib.c | 12 |
6 files changed, 43 insertions, 55 deletions
diff --git a/mysys/mf_iocache.c b/mysys/mf_iocache.c index a52ea2c5c40..4dd0f7500aa 100644 --- a/mysys/mf_iocache.c +++ b/mysys/mf_iocache.c @@ -115,6 +115,7 @@ init_functions(IO_CACHE* info) DBUG_ASSERT(!(info->myflags & MY_ENCRYPT)); info->read_function = info->share ? _my_b_cache_read_r : _my_b_cache_read; info->write_function = info->share ? _my_b_cache_write_r : _my_b_cache_write; + info->myflags&= ~MY_FULL_IO; break; case TYPE_NOT_SET: DBUG_ASSERT(0); @@ -455,6 +456,8 @@ my_bool reinit_io_cache(IO_CACHE *info, enum cache_type type, { info->read_end=info->write_pos; info->end_of_file=my_b_tell(info); + /* Ensure we will read all data */ + info->myflags|= MY_FULL_IO; /* Trigger a new seek only if we have a valid file handle. @@ -469,6 +472,7 @@ my_bool reinit_io_cache(IO_CACHE *info, enum cache_type type, info->seek_not_done=1; } info->end_of_file = ~(my_off_t) 0; + info->myflags&= ~MY_FULL_IO; } pos=info->request_pos+(seek_offset-info->pos_in_file); if (type == WRITE_CACHE) @@ -1917,13 +1921,12 @@ int my_b_flush_io_cache(IO_CACHE *info, int need_append_buffer_lock) { if (append_cache) { - if (mysql_file_write(info->file, info->write_buffer, length, info->myflags | MY_NABP)) + { info->error= -1; - else - info->error= 0; - + DBUG_RETURN(-1); + } info->end_of_file+= info->write_pos - info->append_read_pos; info->append_read_pos= info->write_buffer; DBUG_ASSERT(info->end_of_file == mysql_file_tell(info->file, MYF(0))); diff --git a/mysys/mf_iocache2.c b/mysys/mf_iocache2.c index 2499094037d..ef163ee24d3 100644 --- a/mysys/mf_iocache2.c +++ b/mysys/mf_iocache2.c @@ -249,18 +249,16 @@ my_off_t my_b_filelength(IO_CACHE *info) } -size_t +my_bool my_b_write_backtick_quote(IO_CACHE *info, const char *str, size_t len) { const uchar *start; const uchar *p= (const uchar *)str; const uchar *end= p + len; size_t count; - size_t total= 0; if (my_b_write(info, (uchar *)"`", 1)) - return (size_t)-1; - ++total; + return 1; for (;;) { start= p; @@ -268,35 +266,32 @@ my_b_write_backtick_quote(IO_CACHE *info, const char *str, size_t len) ++p; count= p - start; if (count && my_b_write(info, start, count)) - return (size_t)-1; - total+= count; + return 1; if (p >= end) break; if (my_b_write(info, (uchar *)"``", 2)) - return (size_t)-1; - total+= 2; + return 1; ++p; } - if (my_b_write(info, (uchar *)"`", 1)) - return (size_t)-1; - ++total; - return total; + return (my_b_write(info, (uchar *)"`", 1)); } /* Simple printf version. Supports '%s', '%d', '%u', "%ld" and "%lu" - Used for logging in MySQL - returns number of written character, or (size_t) -1 on error + Used for logging in MariaDB + + @return 0 ok + 1 error */ -size_t my_b_printf(IO_CACHE *info, const char* fmt, ...) +my_bool my_b_printf(IO_CACHE *info, const char* fmt, ...) { size_t result; va_list args; va_start(args,fmt); result=my_b_vprintf(info, fmt, args); va_end(args); - return result; + return result == (size_t) -1; } diff --git a/mysys/my_default.c b/mysys/my_default.c index 37f6d2bfbbf..1c8e976d8dc 100644 --- a/mysys/my_default.c +++ b/mysys/my_default.c @@ -487,8 +487,7 @@ int load_defaults(const char *conf_file, const char **groups, easily command line options override options in configuration files NOTES - In case of fatal error, the function will print a warning and do - exit(1) + In case of fatal error, the function will print a warning and returns 2 To free used memory one should call free_defaults() with the argument that was put in *argv @@ -641,8 +640,7 @@ int my_load_defaults(const char *conf_file, const char **groups, err: fprintf(stderr,"Fatal error in defaults handling. Program aborted\n"); - exit(1); - return 0; /* Keep compiler happy */ + return 2; } diff --git a/mysys/my_malloc.c b/mysys/my_malloc.c index 2b022522f67..6b24f777aaa 100644 --- a/mysys/my_malloc.c +++ b/mysys/my_malloc.c @@ -109,7 +109,7 @@ void *my_malloc(size_t size, myf my_flags) my_error(EE_OUTOFMEMORY, MYF(ME_BELL + ME_WAITTANG + ME_NOREFRESH + ME_FATALERROR),size); if (my_flags & MY_FAE) - exit(1); + abort(); } else { diff --git a/mysys/my_read.c b/mysys/my_read.c index 922da5a7e95..89b368e9800 100644 --- a/mysys/my_read.c +++ b/mysys/my_read.c @@ -35,11 +35,10 @@ size_t my_read(File Filedes, uchar *Buffer, size_t Count, myf MyFlags) { - size_t readbytes, save_count; + size_t readbytes, save_count= 0; DBUG_ENTER("my_read"); DBUG_PRINT("my",("fd: %d Buffer: %p Count: %lu MyFlags: %lu", Filedes, Buffer, (ulong) Count, MyFlags)); - save_count= Count; if (!(MyFlags & (MY_WME | MY_FAE | MY_FNABP))) MyFlags|= my_global_flags; @@ -61,47 +60,52 @@ size_t my_read(File Filedes, uchar *Buffer, size_t Count, myf MyFlags) if (readbytes != Count) { - my_errno= errno; - if (errno == 0 || (readbytes != (size_t) -1 && - (MyFlags & (MY_NABP | MY_FNABP)))) - my_errno= HA_ERR_FILE_TOO_SHORT; + int got_errno= my_errno= errno; DBUG_PRINT("warning",("Read only %d bytes off %lu from %d, errno: %d", (int) readbytes, (ulong) Count, Filedes, - my_errno)); + got_errno)); + + if (got_errno == 0 || (readbytes != (size_t) -1 && + (MyFlags & (MY_NABP | MY_FNABP)))) + my_errno= HA_ERR_FILE_TOO_SHORT; - if ((readbytes == 0 || (int) readbytes == -1) && errno == EINTR) + if ((readbytes == 0 || (int) readbytes == -1) && got_errno == EINTR) { DBUG_PRINT("debug", ("my_read() was interrupted and returned %ld", (long) readbytes)); continue; /* Interrupted */ } + /* Do a read retry if we didn't get enough data on first read */ + if (readbytes != (size_t) -1 && readbytes != 0 && + (MyFlags & MY_FULL_IO)) + { + Buffer+= readbytes; + Count-= readbytes; + save_count+= readbytes; + continue; + } + if (MyFlags & (MY_WME | MY_FAE | MY_FNABP)) { if (readbytes == (size_t) -1) my_error(EE_READ, MYF(ME_BELL | ME_WAITTANG | (MyFlags & (ME_JUST_INFO | ME_NOREFRESH))), - my_filename(Filedes),my_errno); + 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))), - my_filename(Filedes),my_errno); + my_filename(Filedes), got_errno); } if (readbytes == (size_t) -1 || ((MyFlags & (MY_FNABP | MY_NABP)) && !(MyFlags & MY_FULL_IO))) DBUG_RETURN(MY_FILE_ERROR); /* Return with error */ - if (readbytes != (size_t) -1 && (MyFlags & MY_FULL_IO)) - { - Buffer+= readbytes; - Count-= readbytes; - continue; - } } if (MyFlags & (MY_NABP | MY_FNABP)) readbytes= 0; /* Ok on read */ - else if (MyFlags & MY_FULL_IO) - readbytes= save_count; + else + readbytes+= save_count; break; } DBUG_RETURN(readbytes); diff --git a/mysys/typelib.c b/mysys/typelib.c index e45ede2c43a..f0be211fd46 100644 --- a/mysys/typelib.c +++ b/mysys/typelib.c @@ -45,18 +45,6 @@ int find_type_with_warning(const char *x, TYPELIB *typelib, const char *option) } -int find_type_or_exit(const char *x, TYPELIB *typelib, const char *option) -{ - int res; - if ((res= find_type_with_warning(x, typelib, option)) <= 0) - { - sf_leaking_memory= 1; /* no memory leak reports here */ - exit(1); - } - return res; -} - - /** Search after a string in a list of strings. Endspace in x is not compared. |