diff options
author | Sergei Golubchik <serg@mariadb.org> | 2018-05-17 22:53:57 +0200 |
---|---|---|
committer | Vladislav Vaintroub <wlad@mariadb.com> | 2018-05-21 16:34:10 +0000 |
commit | 3a7d7e180a871c5b2b2d98812d9d7f800cf33952 (patch) | |
tree | d4bd1765e16d3bf92d360b8c032b86f8a0b3a38f /mysys/mf_cache.c | |
parent | 2534ae20fd244eed569830bb7159518e42f24baa (diff) | |
download | mariadb-git-3a7d7e180a871c5b2b2d98812d9d7f800cf33952.tar.gz |
cleanup: create_temp_file()
simplify. move common code inside, specify common flags inside,
rewrite dead code (`if (mode & O_TEMPORARY)` on Linux, where
`O_TEMPORARY` is always 0) to actually do something.
Diffstat (limited to 'mysys/mf_cache.c')
-rw-r--r-- | mysys/mf_cache.c | 37 |
1 files changed, 2 insertions, 35 deletions
diff --git a/mysys/mf_cache.c b/mysys/mf_cache.c index a3426889a82..478900ddb2a 100644 --- a/mysys/mf_cache.c +++ b/mysys/mf_cache.c @@ -21,36 +21,6 @@ #include "mysys_err.h" /** - Remove an open tempfile so that it doesn't survive if we crash - - If the operating system doesn't support this, just remember - the file name for later removal -*/ - -static my_bool cache_remove_open_tmp(IO_CACHE *cache __attribute__((unused)), - const char *name) -{ -#if O_TEMPORARY == 0 -#if !defined(CANT_DELETE_OPEN_FILES) - /* The following should always succeed */ - (void) my_delete(name,MYF(MY_WME | ME_NOINPUT)); -#else - int length; - if (!(cache->file_name= - (char*) my_malloc((length=strlen(name)+1),MYF(MY_WME)))) - { - my_close(cache->file,MYF(0)); - cache->file = -1; - errno=my_errno=ENOMEM; - return 1; - } - memcpy(cache->file_name,name,length); -#endif -#endif /* O_TEMPORARY == 0 */ - return 0; -} - -/** Open tempfile cached by IO_CACHE Should be used when no seeks are done (only reinit_io_buff) @@ -88,14 +58,11 @@ my_bool real_open_cached_file(IO_CACHE *cache) char name_buff[FN_REFLEN]; int error=1; DBUG_ENTER("real_open_cached_file"); - if ((cache->file=create_temp_file(name_buff, cache->dir, + if ((cache->file= create_temp_file(name_buff, cache->dir, cache->prefix[0] ? cache->prefix : 0, - (O_RDWR | O_BINARY | O_TRUNC | - O_TEMPORARY | O_SHORT_LIVED), - MYF(MY_WME))) >= 0) + O_BINARY, MYF(MY_WME | MY_TEMPORARY))) >= 0) { error=0; - cache_remove_open_tmp(cache, name_buff); } DBUG_RETURN(error); } |