summaryrefslogtreecommitdiff
path: root/mysys
diff options
context:
space:
mode:
authorsvoj@mysql.com/june.mysql.com <>2007-05-23 12:39:33 +0500
committersvoj@mysql.com/june.mysql.com <>2007-05-23 12:39:33 +0500
commit122167bb4bbaa1867faa6aff44e6f1dac8ae785b (patch)
tree710ce2b32e46d79e575a971e8497c752fd5b09fa /mysys
parentb78945274314300cbba604c10cba1feb538d85d4 (diff)
parent8a809def0a550018005e956332b9b80f09e27c5f (diff)
downloadmariadb-git-122167bb4bbaa1867faa6aff44e6f1dac8ae785b.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.c17
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;