Skip to content

Commit

Permalink
Don't fsync() read-only filehandles (thanks, Andreas!).
Browse files Browse the repository at this point in the history
This sounds harmless, but it actually forces a write of the inode's atime,
 which means a lot of painful and unnecessary disk i/o on some filesystems.

Should be a good speedup on games that read a lot of small files on Unix.
  • Loading branch information
icculus committed Aug 22, 2013
1 parent 26f5eb4 commit 09baf99
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions docs/CREDITS.txt
Expand Up @@ -136,6 +136,9 @@ SLB archiver:
Bug fixes:
Dmitry Marakasov

Bug fixes:
Andreas Karlsson

Other stuff:
Your name here! Patches go to icculus@icculus.org ...

Expand Down
3 changes: 2 additions & 1 deletion src/platform_posix.c
Expand Up @@ -279,7 +279,8 @@ PHYSFS_sint64 __PHYSFS_platformFileLength(void *opaque)
int __PHYSFS_platformFlush(void *opaque)
{
const int fd = *((int *) opaque);
BAIL_IF_MACRO(fsync(fd) == -1, errcodeFromErrno(), 0);
if ((fcntl(fd, F_GETFL) & O_ACCMODE) != O_RDONLY)
BAIL_IF_MACRO(fsync(fd) == -1, errcodeFromErrno(), 0);
return 1;
} /* __PHYSFS_platformFlush */

Expand Down

0 comments on commit 09baf99

Please sign in to comment.