diff options
author | svoj@april.(none) <> | 2007-05-17 02:16:31 +0500 |
---|---|---|
committer | svoj@april.(none) <> | 2007-05-17 02:16:31 +0500 |
commit | 820651cd533fbe1bc322370e8abaa8d5db903bfa (patch) | |
tree | 9897289be013ff250fa050765ff6e434efb93b0e /mysys | |
parent | 3ed42fbb2d4f768660b6b95076546eba8712f728 (diff) | |
parent | bf473b10696dca4ff0e72eeb945ca1b3f8bf3ce1 (diff) | |
download | mariadb-git-820651cd533fbe1bc322370e8abaa8d5db903bfa.tar.gz |
Merge mysql.com:/home/svoj/devel/mysql/BUG25712/mysql-5.0-engines
into mysql.com:/home/svoj/devel/mysql/BUG25712/mysql-5.1-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 6f3c1349722..e8b9fa0ecd2 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_lock(&my_file_info[fd].mutex); + } + else +#endif + newpos= lseek(fd, pos, whence); if (newpos == (os_off_t) -1) { my_errno=errno; |