summaryrefslogtreecommitdiff
path: root/mysys
diff options
context:
space:
mode:
authorsvoj@mysql.com/june.mysql.com <>2007-05-23 12:38:34 +0500
committersvoj@mysql.com/june.mysql.com <>2007-05-23 12:38:34 +0500
commita4ddc2262139d4e020e903516bb96df359378873 (patch)
treef3d76e21e36cfecb2630972071b33b496b3477a9 /mysys
parent7b2c430f5843c2d08d79096230cfa0097e902b9b (diff)
parentf6a111dfef4ef1c442a4954d31628eed92a0f357 (diff)
downloadmariadb-git-a4ddc2262139d4e020e903516bb96df359378873.tar.gz
Merge mysql.com:/home/svoj/devel/bk/mysql-4.1
into mysql.com:/home/svoj/devel/mysql/merge/mysql-4.1-engines
Diffstat (limited to 'mysys')
-rw-r--r--mysys/my_seek.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/mysys/my_seek.c b/mysys/my_seek.c
index a9ae68cd5f0..805a5654ffc 100644
--- a/mysys/my_seek.c
+++ b/mysys/my_seek.c
@@ -24,7 +24,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
@@ -51,7 +53,16 @@ my_off_t my_seek(File fd, my_off_t pos, int whence,
whence, MyFlags));
DBUG_ASSERT(pos != MY_FILEPOS_ERROR); /* safety check */
- 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;