diff options
author | unknown <thek@kpdesk.mysql.com> | 2006-11-02 08:47:21 +0100 |
---|---|---|
committer | unknown <thek@kpdesk.mysql.com> | 2006-11-02 08:47:21 +0100 |
commit | dfc8d06c186692db815371f05fc53a2bba1eb48f (patch) | |
tree | 0dd1b4b2ac91bb32d567b5e70724f511710ac3c7 /mysys/my_lock.c | |
parent | 5b063712f0cf7d6a11438705b08a0a7c53c8f694 (diff) | |
parent | 35f18203585d569a6df941536159b0806a19f8ff (diff) | |
download | mariadb-git-dfc8d06c186692db815371f05fc53a2bba1eb48f.tar.gz |
Merge kpdesk.mysql.com:/home/thek/dev/mysql-5.0-maint
into kpdesk.mysql.com:/home/thek/dev/mysql-5.1-maint
client/mysqltest.c:
Auto merged
mysql-test/lib/mtr_io.pl:
Auto merged
mysql-test/lib/mtr_process.pl:
Auto merged
mysql-test/mysql-test-run.pl:
Auto merged
mysys/mf_iocache.c:
Auto merged
mysys/my_lock.c:
Auto merged
mysys/my_seek.c:
Auto merged
sql/sql_delete.cc:
Auto merged
sql/sql_show.cc:
Auto merged
Diffstat (limited to 'mysys/my_lock.c')
-rw-r--r-- | mysys/my_lock.c | 39 |
1 files changed, 34 insertions, 5 deletions
diff --git a/mysys/my_lock.c b/mysys/my_lock.c index 919727e03d6..ac91b6ce0ca 100644 --- a/mysys/my_lock.c +++ b/mysys/my_lock.c @@ -30,7 +30,14 @@ #include <nks/fsio.h> #endif - /* Lock a part of a file */ +/* + Lock a part of a file + + RETURN VALUE + 0 Success + -1 An error has occured and 'my_errno' is set + to indicate the actual error code. +*/ int my_lock(File fd, int locktype, my_off_t start, my_off_t length, myf MyFlags) @@ -94,10 +101,22 @@ int my_lock(File fd, int locktype, my_off_t start, my_off_t length, #elif defined(HAVE_LOCKING) /* Windows */ { - my_bool error; + my_bool error= false; pthread_mutex_lock(&my_file_info[fd].mutex); - if (MyFlags & MY_SEEK_NOT_DONE) - VOID(my_seek(fd,start,MY_SEEK_SET,MYF(MyFlags & ~MY_SEEK_NOT_DONE))); + if (MyFlags & MY_SEEK_NOT_DONE) + { + if( my_seek(fd,start,MY_SEEK_SET,MYF(MyFlags & ~MY_SEEK_NOT_DONE)) + == MY_FILEPOS_ERROR ) + { + /* + If my_seek fails my_errno will already contain an error code; + just unlock and return error code. + */ + DBUG_PRINT("error",("my_errno: %d (%d)",my_errno,errno)); + pthread_mutex_unlock(&my_file_info[fd].mutex); + DBUG_RETURN(-1); + } + } error= locking(fd,locktype,(ulong) length) && errno != EINVAL; pthread_mutex_unlock(&my_file_info[fd].mutex); if (!error) @@ -135,7 +154,17 @@ int my_lock(File fd, int locktype, my_off_t start, my_off_t length, } #else if (MyFlags & MY_SEEK_NOT_DONE) - VOID(my_seek(fd,start,MY_SEEK_SET,MYF(MyFlags & ~MY_SEEK_NOT_DONE))); + { + if (my_seek(fd,start,MY_SEEK_SET,MYF(MyFlags & ~MY_SEEK_NOT_DONE)) + == MY_FILEPOS_ERROR) + { + /* + If an error has occured in my_seek then we will already + have an error code in my_errno; Just return error code. + */ + DBUG_RETURN(-1); + } + } if (lockf(fd,locktype,length) != -1) DBUG_RETURN(0); #endif /* HAVE_FCNTL */ |