diff options
author | unknown <thek@kpdesk.mysql.com> | 2006-11-01 17:01:51 +0100 |
---|---|---|
committer | unknown <thek@kpdesk.mysql.com> | 2006-11-01 17:01:51 +0100 |
commit | 35f18203585d569a6df941536159b0806a19f8ff (patch) | |
tree | 36dd8def41b63e03f75b1fb10d60480b38fd981e /mysys/my_lock.c | |
parent | 73a7995b029ba5bd2ad9d9b32ee89fb383a68a10 (diff) | |
parent | 2d1215f4c6d1ddb4dc7da21a9af0a8e1af6fbfca (diff) | |
download | mariadb-git-35f18203585d569a6df941536159b0806a19f8ff.tar.gz |
Merge kpdesk.mysql.com:/home/thek/dev/mysql-4.1-maint
into kpdesk.mysql.com:/home/thek/dev/mysql-5.0-maint
mysys/my_chsize.c:
Auto merged
mysys/my_seek.c:
Auto merged
mysys/mf_iocache.c:
Merged patch:
- Moved comments
- Moved check on return value of my_seek.
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 8f915d6003a..c9641f46f5c 100644 --- a/mysys/my_lock.c +++ b/mysys/my_lock.c @@ -35,7 +35,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) @@ -104,10 +111,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) @@ -145,7 +164,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 */ |