summaryrefslogtreecommitdiff
path: root/mysys/mf_iocache.c
diff options
context:
space:
mode:
authorunknown <serg@serg.mysql.com>2003-01-26 12:57:20 +0100
committerunknown <serg@serg.mysql.com>2003-01-26 12:57:20 +0100
commit7fe48f6949fdc316b528fecf8b5edcaedb121241 (patch)
tree5b477016b6994296aa4bd86e7671c882e9396641 /mysys/mf_iocache.c
parent2fde3f64426e375e260f2bdb0f5b2959294e470f (diff)
downloadmariadb-git-7fe48f6949fdc316b528fecf8b5edcaedb121241.tar.gz
do not "trust number of broadcasts" in shared IO_CACHE
Diffstat (limited to 'mysys/mf_iocache.c')
-rw-r--r--mysys/mf_iocache.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/mysys/mf_iocache.c b/mysys/mf_iocache.c
index 12e1894eb1a..0f35ee048bb 100644
--- a/mysys/mf_iocache.c
+++ b/mysys/mf_iocache.c
@@ -442,10 +442,9 @@ void init_io_cache_share(IO_CACHE *info, IO_CACHE_SHARE *s, uint num_threads)
pthread_mutex_init(&s->mutex, MY_MUTEX_INIT_FAST);
pthread_cond_init (&s->cond, 0);
s->total=s->count=num_threads-1;
- s->active=0; /* to catch errors */
+ s->active=0;
info->share=s;
info->read_function=_my_b_read_r;
- /* Ensure that the code doesn't use pointer to the IO_CACHE object */
info->current_pos= info->current_end= 0;
}
@@ -465,7 +464,7 @@ void remove_io_thread(IO_CACHE *info)
pthread_mutex_unlock(&s->mutex);
}
-static int lock_io_cache(IO_CACHE *info)
+static int lock_io_cache(IO_CACHE *info, my_off_t pos)
{
int total;
IO_CACHE_SHARE *s=info->share;
@@ -479,7 +478,8 @@ static int lock_io_cache(IO_CACHE *info)
total=s->total;
s->count--;
- pthread_cond_wait(&s->cond, &s->mutex);
+ while (!s->active || s->active->pos_in_file < pos)
+ pthread_cond_wait(&s->cond, &s->mutex);
if (s->total < total)
return 1;
@@ -536,7 +536,7 @@ int _my_b_read_r(register IO_CACHE *info, byte *Buffer, uint Count)
info->error=(int) read_len;
DBUG_RETURN(1);
}
- if (lock_io_cache(info))
+ if (lock_io_cache(info, pos_in_file))
{
info->share->active=info;
if (info->seek_not_done) /* File touched, do seek */