remove fallocate hack (in master)

This commit is contained in:
arvidn 2015-09-21 14:58:20 -07:00
parent dc77da5630
commit 5bdb583162
3 changed files with 10 additions and 36 deletions

View File

@ -73,7 +73,7 @@
* almost completely changed the storage interface (for custom storage)
* added support for hashing pieces in multiple threads
* fix fallocate hack on linux (fixes corruption on some architectures)
* fix auto-manage bug with announce to tracker/lsd/dht limits
* improve DHT routing table to not create an unbalanced tree
* fix bug in uTP that would cause any connection taking more than one second

View File

@ -224,6 +224,14 @@ POSSIBILITY OF SUCH DAMAGE.
#define TORRENT_USE_IFADDRS 1
#define TORRENT_USE_POSIX_MEMALIGN 1
#define TORRENT_USE_FDATASYNC 1
// posix_fallocate() is available under this condition
#if _XOPEN_SOURCE >= 600 || _POSIX_C_SOURCE >= 200112L
#define TORRENT_HAS_FALLOCATE 1
#else
#define TORRENT_HAS_FALLOCATE 0
#endif
#endif // ANDROID
#if defined __GLIBC__ && ( defined __x86_64__ || defined __i386 \

View File

@ -131,23 +131,6 @@ POSSIBILITY OF SUCH DAMAGE.
#define lseek lseek64
#endif
#include <asm/unistd.h> // For __NR_fallocate
// circumvent the lack of support in glibc
static int my_fallocate(int fd, int mode, loff_t offset, loff_t len)
{
#ifdef __NR_fallocate
// the man page on fallocate differes between versions of linux.
// it appears that fallocate in fact sets errno and returns -1
// on failure.
return syscall(__NR_fallocate, fd, mode, offset, len);
#else
// pretend that the system call doesn't exist
errno = ENOSYS;
return -1;
#endif
}
#elif defined __APPLE__ && defined __MACH__ && MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
// mac specifics
@ -2136,23 +2119,6 @@ typedef struct _FILE_ALLOCATED_RANGE_BUFFER {
int ret;
#endif
#if defined TORRENT_LINUX
ret = my_fallocate(native_handle(), 0, 0, s);
// if we return 0, everything went fine
// the fallocate call succeeded
if (ret == 0) return true;
// otherwise, something went wrong. If the error
// is ENOSYS, just keep going and do it the old-fashioned
// way. If fallocate failed with some other error, it
// probably means the user should know about it, error out
// and report it.
if (errno != ENOSYS && errno != EOPNOTSUPP && errno != EINVAL)
{
ec.assign(errno, generic_category());
return false;
}
#endif // TORRENT_LINUX
#if TORRENT_HAS_FALLOCATE
// if fallocate failed, we have to use posix_fallocate
// which can be painfully slow
@ -2160,7 +2126,7 @@ typedef struct _FILE_ALLOCATED_RANGE_BUFFER {
// define TORRENT_HAS_FALLOCATE to 0.
ret = posix_fallocate(native_handle(), 0, s);
// posix_allocate fails with EINVAL in case the underlying
// filesystem does bot support this operation
// filesystem does not support this operation
if (ret != 0 && ret != EINVAL)
{
ec.assign(ret, generic_category());