diff options
author | monty@mysql.com <> | 2003-11-21 14:41:57 +0200 |
---|---|---|
committer | monty@mysql.com <> | 2003-11-21 14:41:57 +0200 |
commit | d08945498e44acb968d1aab6d269d9b1874246e6 (patch) | |
tree | 1dae851e03d54c7a8de1e73a27a50426cef61563 /mysys/mf_iocache.c | |
parent | 19b5da3247c844b52de2706fc3dd19fe0099dc84 (diff) | |
download | mariadb-git-d08945498e44acb968d1aab6d269d9b1874246e6.tar.gz |
Fixed memory leak with RAID tables
Fixed tests for RAID tables
Detect uninitialized mutexes on lock and destroy
Diffstat (limited to 'mysys/mf_iocache.c')
-rw-r--r-- | mysys/mf_iocache.c | 62 |
1 files changed, 53 insertions, 9 deletions
diff --git a/mysys/mf_iocache.c b/mysys/mf_iocache.c index d96d4c0db3c..b5c80d9482f 100644 --- a/mysys/mf_iocache.c +++ b/mysys/mf_iocache.c @@ -110,11 +110,29 @@ init_functions(IO_CACHE* info, enum cache_type type) } } - /* - ** if cachesize == 0 then use default cachesize (from s-file) - ** if file == -1 then real_open_cached_file() will be called. - ** returns 0 if ok - */ + +/* + Initialize an IO_CACHE object + + SYNOPSOS + init_io_cache() + info cache handler to initialize + file File that should be associated to to the handler + If == -1 then real_open_cached_file() + will be called when it's time to open file. + cachesize Size of buffer to allocate for read/write + If == 0 then use my_default_record_cache_size + type Type of cache + seek_offset Where cache should start reading/writing + use_async_io Set to 1 of we should use async_io (if avaiable) + cache_myflags Bitmap of differnt flags + MY_WME | MY_FAE | MY_NABP | MY_FNABP | + MY_DONT_CHECK_FILESIZE + + RETURN + 0 ok + # error +*/ int init_io_cache(IO_CACHE *info, File file, uint cachesize, enum cache_type type, my_off_t seek_offset, @@ -127,7 +145,7 @@ int init_io_cache(IO_CACHE *info, File file, uint cachesize, (ulong) info, (int) type, (ulong) seek_offset)); info->file= file; - info->type=type; + info->type= 0; /* Don't set it until mutex are created */ info->pos_in_file= seek_offset; info->pre_close = info->pre_read = info->post_read = 0; info->arg = 0; @@ -138,9 +156,8 @@ int init_io_cache(IO_CACHE *info, File file, uint cachesize, info->share=0; #endif - if (!cachesize) - if (! (cachesize= my_default_record_cache_size)) - DBUG_RETURN(1); /* No cache requested */ + if (!cachesize && !(cachesize= my_default_record_cache_size)) + DBUG_RETURN(1); /* No cache requested */ min_cache=use_async_io ? IO_SIZE*4 : IO_SIZE*2; if (type == READ_CACHE || type == SEQ_READ_APPEND) { /* Assume file isn't growing */ @@ -201,6 +218,13 @@ int init_io_cache(IO_CACHE *info, File file, uint cachesize, pthread_mutex_init(&info->append_buffer_lock,MY_MUTEX_INIT_FAST); #endif } +#if defined(SAFE_MUTEX) && defined(THREAD) + else + { + /* Clear mutex so that safe_mutex will notice that it's not initialized */ + bzero((char*) &info->append_buffer_lock, sizeof(info)); + } +#endif if (type == WRITE_CACHE) info->write_end= @@ -211,6 +235,7 @@ int init_io_cache(IO_CACHE *info, File file, uint cachesize, /* End_of_file may be changed by user later */ info->end_of_file= end_of_file; info->error=0; + info->type= type; init_functions(info,type); #ifdef HAVE_AIOWAIT if (use_async_io && ! my_disable_async_io) @@ -1142,6 +1167,22 @@ int _flush_io_cache(IO_CACHE *info, int need_append_buffer_lock) DBUG_RETURN(0); } +/* + Free an IO_CACHE object + + SYNOPSOS + end_io_cache() + info IO_CACHE Handle to free + + NOTES + It's currently safe to call this if one has called io_cache_init() + on the 'info' object, even if io_cache_init() failed. + This function is also safe to call twice with the same handle. + + RETURN + 0 ok + # Error +*/ int end_io_cache(IO_CACHE *info) { @@ -1164,7 +1205,10 @@ int end_io_cache(IO_CACHE *info) #endif if ((pre_close=info->pre_close)) + { (*pre_close)(info); + info->pre_close= 0; + } if (info->alloced_buffer) { info->alloced_buffer=0; |