summaryrefslogtreecommitdiff
path: root/mysys/my_seek.c
diff options
context:
space:
mode:
authorsvoj@mysql.com/april.(none) <>2007-05-17 00:40:26 +0500
committersvoj@mysql.com/april.(none) <>2007-05-17 00:40:26 +0500
commitbf473b10696dca4ff0e72eeb945ca1b3f8bf3ce1 (patch)
tree8c2fd9efea4fbaa16ecb999f75d73177dfce4a4d /mysys/my_seek.c
parent3e21fb0f3baaa573a3b82728bb02ea3bf566d7db (diff)
parent3ea2ee357b03d909566965046a9a2c5f32f91b3b (diff)
downloadmariadb-git-bf473b10696dca4ff0e72eeb945ca1b3f8bf3ce1.tar.gz
Merge mysql.com:/home/svoj/devel/mysql/BUG25712/mysql-4.1-engines
into mysql.com:/home/svoj/devel/mysql/BUG25712/mysql-5.0-engines
Diffstat (limited to 'mysys/my_seek.c')
-rw-r--r--mysys/my_seek.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/mysys/my_seek.c b/mysys/my_seek.c
index 2be4812a2bd..d46a02a6a50 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;