merge F_SETLF change from RC_0_16

This commit is contained in:
Arvid Norberg 2014-04-16 07:43:36 +00:00
parent b0996ef855
commit 2798c8d345
1 changed files with 5 additions and 18 deletions

View File

@ -1164,24 +1164,11 @@ namespace libtorrent
return false;
}
#ifdef F_SETLK
if (mode & lock_file)
{
struct flock l =
{
0, // start offset
0, // length (0 = until EOF)
getpid(), // owner
short((mode != read_only) ? F_WRLCK : F_RDLCK), // lock type
SEEK_SET // whence
};
if (fcntl(m_fd, F_SETLK, &l) != 0)
{
ec.assign(errno, get_posix_category());
return false;
}
}
#endif
// The purpose of the lock_file flag is primarily to prevent other
// processes from corrupting files that are being used by libtorrent.
// the posix file locking mechanism does not prevent others from
// accessing files, unless they also attempt to lock the file. That's
// why the SETLK mechanism is not used here.
#ifdef DIRECTIO_ON
// for solaris