diff options
author | monty@mysql.com <> | 2005-01-15 03:49:07 +0200 |
---|---|---|
committer | monty@mysql.com <> | 2005-01-15 03:49:07 +0200 |
commit | 7681e624229ded43c120f73d823a41bd68a33b76 (patch) | |
tree | 3bcf35791b10e121565898027952d04a93be916f /mysys/mf_iocache.c | |
parent | 5ebcb21f12c21c2634616ce9b87eb96666038523 (diff) | |
parent | 6d280ac1615efe5f67843a27c18af080acadc383 (diff) | |
download | mariadb-git-7681e624229ded43c120f73d823a41bd68a33b76.tar.gz |
Merge
Diffstat (limited to 'mysys/mf_iocache.c')
-rw-r--r-- | mysys/mf_iocache.c | 49 |
1 files changed, 35 insertions, 14 deletions
diff --git a/mysys/mf_iocache.c b/mysys/mf_iocache.c index f109df912f1..d80de3101be 100644 --- a/mysys/mf_iocache.c +++ b/mysys/mf_iocache.c @@ -70,9 +70,40 @@ static void my_aiowait(my_aio_result *result); #define IO_ROUND_UP(X) (((X)+IO_SIZE-1) & ~(IO_SIZE-1)) #define IO_ROUND_DN(X) ( (X) & ~(IO_SIZE-1)) + +/* + Setup internal pointers inside IO_CACHE + + SYNOPSIS + setup_io_cache() + info IO_CACHE handler + + NOTES + This is called on automaticly on init or reinit of IO_CACHE + It must be called externally if one moves or copies an IO_CACHE + object. +*/ + +void setup_io_cache(IO_CACHE* info) +{ + /* Ensure that my_b_tell() and my_b_bytes_in_cache works */ + if (info->type == WRITE_CACHE) + { + info->current_pos= &info->write_pos; + info->current_end= &info->write_end; + } + else + { + info->current_pos= &info->read_pos; + info->current_end= &info->read_end; + } +} + + static void -init_functions(IO_CACHE* info, enum cache_type type) +init_functions(IO_CACHE* info) { + enum cache_type type= info->type; switch (type) { case READ_NET: /* @@ -96,17 +127,7 @@ init_functions(IO_CACHE* info, enum cache_type type) info->write_function = _my_b_write; } - /* Ensure that my_b_tell() and my_b_bytes_in_cache works */ - if (type == WRITE_CACHE) - { - info->current_pos= &info->write_pos; - info->current_end= &info->write_end; - } - else - { - info->current_pos= &info->read_pos; - info->current_end= &info->read_end; - } + setup_io_cache(info); } @@ -236,7 +257,7 @@ int init_io_cache(IO_CACHE *info, File file, uint cachesize, info->end_of_file= end_of_file; info->error=0; info->type= type; - init_functions(info,type); + init_functions(info); #ifdef HAVE_AIOWAIT if (use_async_io && ! my_disable_async_io) { @@ -358,7 +379,7 @@ my_bool reinit_io_cache(IO_CACHE *info, enum cache_type type, } info->type=type; info->error=0; - init_functions(info,type); + init_functions(info); #ifdef HAVE_AIOWAIT if (use_async_io && ! my_disable_async_io && |