diff options
author | unknown <marko@hundin.mysql.fi> | 2004-06-01 17:30:46 +0300 |
---|---|---|
committer | unknown <marko@hundin.mysql.fi> | 2004-06-01 17:30:46 +0300 |
commit | e6626bdb2d196e3954334bd81b65708e3f839924 (patch) | |
tree | e64307efc1ef9b5c32a86ac61588f84976b28cb3 | |
parent | 389e8bec492a5cf1a8cd8bb54f8d14518aaa925a (diff) | |
download | mariadb-git-e6626bdb2d196e3954334bd81b65708e3f839924.tar.gz |
InnoDB: os0file.c:
Do not lock raw devices or files opened for read only
innobase/os/os0file.c:
Do not lock raw devices or files opened for read only
-rw-r--r-- | innobase/os/os0file.c | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/innobase/os/os0file.c b/innobase/os/os0file.c index caf09ed9f5f..9d428c283a5 100644 --- a/innobase/os/os0file.c +++ b/innobase/os/os0file.c @@ -387,22 +387,19 @@ os_file_lock( /*=========*/ /* out: 0 on success */ int fd, /* in: file descriptor */ - const char* name, /* in: file name */ - uint lock_type) /* in: lock_type */ + const char* name) /* in: file name */ { struct flock lk; - lk.l_type = lock_type; + lk.l_type = F_WRLCK; lk.l_whence = SEEK_SET; lk.l_start = lk.l_len = 0; if (fcntl(fd, F_SETLK, &lk) == -1) { fprintf(stderr, - "InnoDB: Unable to lock %s with lock %d, error: %d", - name, lock_type, errno); - perror (": fcntl"); + "InnoDB: Unable to lock %s, error: %d", name, errno); close(fd); return(-1); } - return 0; + return(0); } #endif /* USE_FILE_LOCK */ @@ -869,7 +866,8 @@ try_again: goto try_again; } #ifdef USE_FILE_LOCK - } else if (os_file_lock(file, name, F_WRLCK)) { + } else if (access_type == OS_FILE_READ_WRITE + && os_file_lock(file, name)) { *success = FALSE; file = -1; #endif @@ -980,7 +978,8 @@ os_file_create_simple_no_error_handling( if (file == -1) { *success = FALSE; #ifdef USE_FILE_LOCK - } else if (os_file_lock(file, name, F_WRLCK)) { + } else if (access_type == OS_FILE_READ_WRITE + && os_file_lock(file, name)) { *success = FALSE; file = -1; #endif @@ -1194,7 +1193,8 @@ try_again: goto try_again; } #ifdef USE_FILE_LOCK - } else if (os_file_lock(file, name, F_WRLCK)) { + } else if (create_mode != OS_FILE_OPEN_RAW + && os_file_lock(file, name)) { *success = FALSE; file = -1; #endif @@ -1395,9 +1395,6 @@ os_file_close( #else int ret; -#ifdef USE_FILE_LOCK - (void) os_file_lock(file, "unknown", F_UNLCK); -#endif ret = close(file); if (ret == -1) { @@ -1434,9 +1431,6 @@ os_file_close_no_error_handling( #else int ret; -#ifdef USE_FILE_LOCK - (void) os_file_lock(file, "unknown", F_UNLCK); -#endif ret = close(file); if (ret == -1) { |