summaryrefslogtreecommitdiff
path: root/mysys/my_seek.c
diff options
context:
space:
mode:
authorunknown <svoj@mysql.com/april.(none)>2007-05-17 00:40:26 +0500
committerunknown <svoj@mysql.com/april.(none)>2007-05-17 00:40:26 +0500
commitde0e4e0a2ba46a300b14b7b3e8b362ae3abac325 (patch)
tree8c2fd9efea4fbaa16ecb999f75d73177dfce4a4d /mysys/my_seek.c
parent9cc05ced333a7c60bc0613867f4edeeee9e5e97a (diff)
parente1e83a8b66dc59b1e46cd78db6a20b8ba2ea44ba (diff)
downloadmariadb-git-de0e4e0a2ba46a300b14b7b3e8b362ae3abac325.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 myisam/mi_check.c: Auto merged mysys/my_seek.c: Manual merge.
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;