mirror of https://github.com/BOINC/boinc.git
*** empty log message ***
svn path=/trunk/boinc/; revision=10594
This commit is contained in:
parent
7f00b2fa3f
commit
7005522834
|
@ -7317,3 +7317,12 @@ David 6 July 2006
|
|||
sched/
|
||||
handle_request.C
|
||||
transitioner.C
|
||||
|
||||
David 6 July 2006
|
||||
- core client: use fcntl() instead of lockf() or flock() to lock files.
|
||||
It's POSIX, hence more portable.
|
||||
(from Bruce Allen)
|
||||
|
||||
configure.ac
|
||||
lib/
|
||||
filesys.C
|
||||
|
|
|
@ -423,7 +423,7 @@ AC_LANG_POP
|
|||
dnl Checks for library functions.
|
||||
AC_PROG_GCC_TRADITIONAL
|
||||
AC_FUNC_VPRINTF
|
||||
AC_CHECK_FUNCS(lockf flock alloca _alloca setpriority strlcpy strlcat sigaction getutent setutent)
|
||||
AC_CHECK_FUNCS(alloca _alloca setpriority strlcpy strlcat sigaction getutent setutent)
|
||||
|
||||
dnl Checks for typedefs, structures, and compiler characteristics.
|
||||
AC_C_CONST
|
||||
|
|
|
@ -547,29 +547,32 @@ int boinc_make_dirs(const char* dirpath, const char* filepath) {
|
|||
|
||||
|
||||
int FILE_LOCK::lock(const char* filename) {
|
||||
int retval=0;
|
||||
#if defined(_WIN32) && !defined(__CYGWIN32__)
|
||||
handle = CreateFile(
|
||||
filename, GENERIC_WRITE,
|
||||
0, 0, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0
|
||||
);
|
||||
if (handle == INVALID_HANDLE_VALUE) {
|
||||
retval = 1;
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
|
||||
#else
|
||||
fd = open(
|
||||
filename, O_WRONLY|O_CREAT, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH
|
||||
);
|
||||
if (fd<0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// some systems have both!
|
||||
#elif defined(HAVE_LOCKF) && !defined(__APPLE__)
|
||||
fd = open(filename, O_WRONLY|O_CREAT, 0644);
|
||||
retval = lockf(fd, F_TLOCK, 0);
|
||||
#elif HAVE_FLOCK
|
||||
fd = open(filename, O_WRONLY|O_CREAT, 0644);
|
||||
retval = flock(fd, LOCK_EX|LOCK_NB);
|
||||
// must leave file-handle open
|
||||
#else
|
||||
no file lock mechanism;
|
||||
struct flock fl;
|
||||
fl.l_type=F_WRLCK;
|
||||
fl.l_whence=SEEK_SET;
|
||||
fl.l_start=0;
|
||||
fl.l_len=0;
|
||||
if (-1 != fcntl(fd, F_SETLK, &fl)) return 0;
|
||||
return -1;
|
||||
#endif
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
int FILE_LOCK::unlock(const char* filename) {
|
||||
|
|
Loading…
Reference in New Issue