summaryrefslogtreecommitdiff
path: root/innobase/os
diff options
context:
space:
mode:
authorunknown <monty@mysql.com>2004-05-05 17:05:24 +0300
committerunknown <monty@mysql.com>2004-05-05 17:05:24 +0300
commit3b887983bfc19585825ec528a80118f2c93f2b04 (patch)
tree3238bd16530e02dbfef96513749a73b7294880f8 /innobase/os
parentf347b37403b7ca828537eaf2cc1d9efb363bf0b7 (diff)
parenta58aa393f2d914e3eb4e422b25fd4ef3665151a3 (diff)
downloadmariadb-git-3b887983bfc19585825ec528a80118f2c93f2b04.tar.gz
Merge with 4.0.19
BitKeeper/etc/logging_ok: auto-union VC++Files/client/mysqlclient.dsp: Auto merged VC++Files/mysql.dsw: Auto merged extra/perror.c: Auto merged extra/replace.c: Auto merged innobase/configure.in: Auto merged innobase/include/lock0lock.h: Auto merged innobase/include/row0mysql.h: Auto merged innobase/include/sync0sync.h: Auto merged innobase/lock/lock0lock.c: Auto merged ltmain.sh: Auto merged BitKeeper/deleted/.del-libmysqld.def~8edf7b8780ce943c: Auto merged innobase/os/os0file.c: Auto merged innobase/pars/lexyy.c: Auto merged innobase/row/row0mysql.c: Auto merged innobase/srv/srv0srv.c: Auto merged innobase/srv/srv0start.c: Auto merged innobase/sync/sync0arr.c: Auto merged innobase/sync/sync0sync.c: Auto merged innobase/trx/trx0trx.c: Auto merged mysql-test/r/alias.result: Auto merged mysql-test/t/system_mysql_db_fix-master.opt: Auto merged mysql-test/r/func_time.result: Automatic merge mysql-test/r/innodb.result: Automatic merge mysql-test/t/alias.test: Automatic merge mysql-test/t/create.test: Automatic merge mysql-test/t/func_time.test: Automatic merge sql/ha_innodb.cc: Automatic merge sql/mysql_priv.h: Automatic merge mysql-test/r/rpl_multi_update.result: Automatic merge mysql-test/t/rpl_error_ignored_table.test: Automatic merge mysql-test/t/rpl_multi_update.test: Automatic merge sql/slave.h: Automatic merge sql/sql_base.cc: Automatic merge sql/sql_db.cc: Automatic merge sql/sql_insert.cc: Automatic merge sql/structs.h: Automatic merge sql/table.cc: Automatic merge strings/longlong2str-x86.s: Automatic merge strings/strings-x86.s: Automatic merge support-files/my-medium.cnf.sh: Automatic merge
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__ */
}
/***************************************************************************