diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2020-04-15 09:56:03 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2020-04-15 09:56:03 +0300 |
commit | 84db10f27bdb4c8d9edf7f554afdcd2a24e3285a (patch) | |
tree | 5f9d5b22cdfee6f147274d85b279d98f8a1bb46b /mysys | |
parent | 9aacda409db8606b985a93f675487943846cbc86 (diff) | |
parent | ccaec18b3934ee384296b4597bdf462fac66c5a4 (diff) | |
download | mariadb-git-84db10f27bdb4c8d9edf7f554afdcd2a24e3285a.tar.gz |
Merge 10.2 into 10.3
Diffstat (limited to 'mysys')
-rw-r--r-- | mysys/hash.c | 8 | ||||
-rw-r--r-- | mysys/my_getncpus.c | 4 | ||||
-rw-r--r-- | mysys/my_lib.c | 18 |
3 files changed, 22 insertions, 8 deletions
diff --git a/mysys/hash.c b/mysys/hash.c index bf2c176f9df..077895ed677 100644 --- a/mysys/hash.c +++ b/mysys/hash.c @@ -116,17 +116,23 @@ my_hash_init2(HASH *hash, uint growth_size, CHARSET_INFO *charset, static inline void my_hash_free_elements(HASH *hash) { uint records= hash->records; + if (records == 0) + return; + /* Set records to 0 early to guard against anyone looking at the structure during the free process */ hash->records= 0; + if (hash->free) { HASH_LINK *data=dynamic_element(&hash->array,0,HASH_LINK*); HASH_LINK *end= data + records; - while (data < end) + do + { (*hash->free)((data++)->data); + } while (data < end); } } diff --git a/mysys/my_getncpus.c b/mysys/my_getncpus.c index 6890de4f827..0d081b72d11 100644 --- a/mysys/my_getncpus.c +++ b/mysys/my_getncpus.c @@ -39,7 +39,11 @@ int my_getncpus(void) configured via core affinity. */ #if (defined(__linux__) || defined(__FreeBSD__)) && defined(HAVE_PTHREAD_GETAFFINITY_NP) +#ifdef __linux__ cpu_set_t set; +#else + cpuset_t set; +#endif if (pthread_getaffinity_np(pthread_self(), sizeof(set), &set) == 0) { #ifdef CPU_COUNT diff --git a/mysys/my_lib.c b/mysys/my_lib.c index 8bab1d3c783..8ce23f65fd3 100644 --- a/mysys/my_lib.c +++ b/mysys/my_lib.c @@ -1,4 +1,5 @@ /* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2008, 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 @@ -109,7 +110,7 @@ static char *directory_file_name (char * dst, const char *src) MY_DIR *my_dir(const char *path, myf MyFlags) { - MY_DIR_HANDLE *dirh= 0; + MY_DIR_HANDLE *dirh; FILEINFO finfo; DIR *dirp; struct dirent *dp; @@ -122,10 +123,13 @@ MY_DIR *my_dir(const char *path, myf MyFlags) tmp_file= directory_file_name(tmp_path, path); if (!(dirp= opendir(tmp_path))) - goto error; + { + my_errno= errno; + goto err_open; + } if (!(dirh= my_malloc(sizeof(*dirh), MyFlags | MY_ZEROFILL))) - goto error; + goto err_alloc; if (my_init_dynamic_array(&dirh->array, sizeof(FILEINFO), ENTRIES_START_SIZE, ENTRIES_INCREMENT, @@ -179,11 +183,11 @@ MY_DIR *my_dir(const char *path, myf MyFlags) DBUG_RETURN(&dirh->dir); - error: - my_errno=errno; - if (dirp) - (void) closedir(dirp); +error: my_dirend(&dirh->dir); +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); DBUG_RETURN(NULL); |