summaryrefslogtreecommitdiff
path: root/mysys/my_seek.c
diff options
context:
space:
mode:
authorunknown <svoj@april.(none)>2007-05-17 02:16:31 +0500
committerunknown <svoj@april.(none)>2007-05-17 02:16:31 +0500
commit36b9ba4769d96da2a6206bf4418582a15580b361 (patch)
tree9897289be013ff250fa050765ff6e434efb93b0e /mysys/my_seek.c
parent7efe2bcddcebfdd8d66be15e9bf99842bef3d768 (diff)
parentde0e4e0a2ba46a300b14b7b3e8b362ae3abac325 (diff)
downloadmariadb-git-36b9ba4769d96da2a6206bf4418582a15580b361.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 mysys/my_seek.c: Auto merged storage/myisam/mi_check.c: Auto merged
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 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;