mirror of
https://github.com/MariaDB/server.git
synced 2026-05-15 19:37:16 +02:00
Fixed memory leak with RAID tables
Fixed tests for RAID tables Detect uninitialized mutexes on lock and destroy mysql-test/r/raid.result: Updated results mysql-test/r/rpl_change_master.result: Update results missing from last patch mysql-test/t/raid.test: Clean up test mysys/mf_iocache.c: Comments Small safety fix mysys/thr_mutex.c: Detect uninitialized mutexes on lock and destroy sql/sql_db.cc: Fixed memory leak with RAID tables
This commit is contained in:
parent
eaae714708
commit
52521cc8c7
6 changed files with 82 additions and 21 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -97,10 +97,12 @@ int safe_mutex_lock(safe_mutex_t *mp,const char *file, uint line)
|
|||
int error;
|
||||
if (!mp->file)
|
||||
{
|
||||
fprintf(stderr,"safe_mutex: Trying to lock unitialized mutex at %s, line %d", file, line);
|
||||
fprintf(stderr,
|
||||
"safe_mutex: Trying to lock unitialized mutex at %s, line %d\n",
|
||||
file, line);
|
||||
fflush(stderr);
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
pthread_mutex_lock(&mp->global);
|
||||
if (mp->count > 0 && pthread_equal(pthread_self(),mp->thread))
|
||||
|
|
@ -262,6 +264,14 @@ int safe_cond_timedwait(pthread_cond_t *cond, safe_mutex_t *mp,
|
|||
int safe_mutex_destroy(safe_mutex_t *mp, const char *file, uint line)
|
||||
{
|
||||
int error=0;
|
||||
if (!mp->file)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"safe_mutex: Trying to destroy unitialized mutex at %s, line %d\n",
|
||||
file, line);
|
||||
fflush(stderr);
|
||||
abort();
|
||||
}
|
||||
if (mp->count != 0)
|
||||
{
|
||||
fprintf(stderr,"safe_mutex: Trying to destroy a mutex that was locked at %s, line %d at %s, line %d\n",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue