diff options
author | unknown <svoj@mysql.com/june.mysql.com> | 2007-05-23 12:39:33 +0500 |
---|---|---|
committer | unknown <svoj@mysql.com/june.mysql.com> | 2007-05-23 12:39:33 +0500 |
commit | adef673652c7b01338cb67a842d147b401532354 (patch) | |
tree | 710ce2b32e46d79e575a971e8497c752fd5b09fa /mysys | |
parent | d06875b3a4e7cb89f320794994b1b2300686b860 (diff) | |
parent | 32e868239dc7c701af3375a1b7a25281fa93fe4a (diff) | |
download | mariadb-git-adef673652c7b01338cb67a842d147b401532354.tar.gz |
Merge mysql.com:/home/svoj/devel/bk/mysql-5.0
into mysql.com:/home/svoj/devel/mysql/merge/mysql-5.0-engines
Diffstat (limited to 'mysys')
-rw-r--r-- | mysys/my_seek.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/mysys/my_seek.c b/mysys/my_seek.c index 2be4812a2bd..3d415400aa2 100644 --- a/mysys/my_seek.c +++ b/mysys/my_seek.c @@ -23,7 +23,9 @@ my_off_t pos The expected position (absolute or relative) int whence A direction parameter and one of {SEEK_SET, SEEK_CUR, SEEK_END} - myf MyFlags Not used. + myf MyFlags MY_THREADSAFE must be set in case my_seek may be mixed + with my_pread/my_pwrite calls and fd is shared among + threads. DESCRIPTION The my_seek function is a wrapper around the system call lseek and @@ -54,9 +56,16 @@ my_off_t my_seek(File fd, my_off_t pos, int whence, Make sure we are using a valid file descriptor! */ DBUG_ASSERT(fd != -1); - - newpos= lseek(fd, pos, whence); - +#if defined(THREAD) && !defined(HAVE_PREAD) + if (MyFlags & MY_THREADSAFE) + { + pthread_mutex_lock(&my_file_info[fd].mutex); + newpos= lseek(fd, pos, whence); + pthread_mutex_unlock(&my_file_info[fd].mutex); + } + else +#endif + newpos= lseek(fd, pos, whence); if (newpos == (os_off_t) -1) { my_errno=errno; |