From: Enlightenment S. <no-...@en...> - 2011-10-04 02:04:46
|
Log: eina: add sub-second resolution correctness. Author: cedric Date: 2011-10-03 19:04:40 -0700 (Mon, 03 Oct 2011) New Revision: 63787 Trac: http://trac.enlightenment.org/e/changeset/63787 Modified: trunk/eina/src/lib/eina_file.c Modified: trunk/eina/src/lib/eina_file.c =================================================================== --- trunk/eina/src/lib/eina_file.c 2011-10-04 01:55:41 UTC (rev 63786) +++ trunk/eina/src/lib/eina_file.c 2011-10-04 02:04:40 UTC (rev 63787) @@ -117,6 +117,9 @@ unsigned long long length; time_t mtime; ino_t inode; +#ifdef _STAT_VER_LINUX + unsigned long int mtime_nsec; +#endif int refcount; int global_refcount; @@ -473,6 +476,24 @@ return tmp; } +static Eina_Bool +_eina_file_timestamp_compare(Eina_File *f, struct stat *st) +{ + if (f->mtime != st->st_mtime) return EINA_FALSE; + if (f->length != (unsigned long long) st->st_size) return EINA_FALSE; + if (f->inode != st->st_ino) return EINA_FALSE; +#ifdef _STAT_VER_LINUX +# if (defined __USE_MISC && defined st_mtime) + if (f->mtime_nsec != (unsigned long int)st->st_mtim.tv_nsec) + return EINA_FALSE; +# else + if (f->mtime_nsec != (unsigned long int)st->st_mtimensec) + return EINA_FALSE; +# endif +#endif + return EINA_TRUE; +} + Eina_Bool eina_file_init(void) { @@ -785,11 +806,7 @@ eina_lock_take(&_eina_file_lock_cache); file = eina_hash_find(_eina_file_cache, filename); - if ((file) && - ((file->mtime != file_stat.st_mtime) || - (file->length != (unsigned long long) file_stat.st_size) || - (file->inode != file_stat.st_ino))) - // FIXME: handle sub-second resolution correctness + if ((file) && _eina_file_timestamp_compare(file, &file_stat)) { file->delete_me = EINA_TRUE; eina_hash_del(_eina_file_cache, file->filename, file); |