summaryrefslogtreecommitdiff
path: root/innobase/os
diff options
context:
space:
mode:
authormonty@mysql.com <>2004-05-05 17:05:24 +0300
committermonty@mysql.com <>2004-05-05 17:05:24 +0300
commitd21d49a32a1689d2c486a449574e120d7a2f60c4 (patch)
tree3238bd16530e02dbfef96513749a73b7294880f8 /innobase/os
parent104fdf607d312bb13f24063d28d993243bf24ca2 (diff)
parente51887b05082622a1882217b7f8ec8ae7f6b4598 (diff)
downloadmariadb-git-d21d49a32a1689d2c486a449574e120d7a2f60c4.tar.gz
Merge with 4.0.19
Diffstat (limited to 'innobase/os')
-rw-r--r--innobase/os/os0file.c55
1 files changed, 48 insertions, 7 deletions
diff --git a/innobase/os/os0file.c b/innobase/os/os0file.c
index 92e7f1e4fc3..ff5b30bec0d 100644
--- a/innobase/os/os0file.c
+++ b/innobase/os/os0file.c
@@ -312,7 +312,7 @@ os_file_handle_error(
/* out: TRUE if we should retry the
operation */
os_file_t file, /* in: file pointer */
- char* name, /* in: name of a file or NULL */
+ const char* name, /* in: name of a file or NULL */
const char* operation)/* in: operation */
{
ulint err;
@@ -369,6 +369,32 @@ os_file_handle_error(
return(FALSE);
}
+#if !defined(__WIN__) && !defined(UNIV_HOTBACKUP)
+/********************************************************************
+Obtain an exclusive lock on a file. */
+static
+int
+os_file_lock(
+/*=========*/
+ /* out: 0 on success */
+ int fd, /* in: file descriptor */
+ const char* name) /* in: file name */
+{
+ struct flock lk;
+ 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", name);
+ perror (": fcntl");
+ close(fd);
+ return(-1);
+ }
+ return 0;
+}
+#endif /* !defined(__WIN__) && !defined(UNIV_HOTBACKUP) */
+
/********************************************************************
Does error handling when a file operation fails. */
static
@@ -781,7 +807,7 @@ try_again:
}
return(file);
-#else
+#else /* __WIN__ */
os_file_t file;
int create_flag;
ibool retry;
@@ -826,12 +852,17 @@ try_again:
if (retry) {
goto try_again;
}
+#ifndef UNIV_HOTBACKUP
+ } else if (os_file_lock(file, name)) {
+ *success = FALSE;
+ file = -1;
+#endif
} else {
*success = TRUE;
}
return(file);
-#endif
+#endif /* __WIN__ */
}
/********************************************************************
@@ -902,7 +933,7 @@ os_file_create_simple_no_error_handling(
}
return(file);
-#else
+#else /* __WIN__ */
os_file_t file;
int create_flag;
@@ -930,12 +961,17 @@ os_file_create_simple_no_error_handling(
if (file == -1) {
*success = FALSE;
+#ifndef UNIV_HOTBACKUP
+ } else if (os_file_lock(file, name)) {
+ *success = FALSE;
+ file = -1;
+#endif
} else {
*success = TRUE;
}
return(file);
-#endif
+#endif /* __WIN__ */
}
/********************************************************************
@@ -1056,7 +1092,7 @@ try_again:
}
return(file);
-#else
+#else /* __WIN__ */
os_file_t file;
int create_flag;
ibool retry;
@@ -1136,12 +1172,17 @@ try_again:
if (retry) {
goto try_again;
}
+#ifndef UNIV_HOTBACKUP
+ } else if (os_file_lock(file, name)) {
+ *success = FALSE;
+ file = -1;
+#endif
} else {
*success = TRUE;
}
return(file);
-#endif
+#endif /* __WIN__ */
}
/***************************************************************************