Non-optimal lseek usage & caching lseek
David Collier-Brown
David.Collier-Brown at canada.sun.com
Thu Oct 12 20:03:33 GMT 2000
David Collier-Brown wrote:
> [stuff]
Jean Francois Micouleau wondered if one of the idioms
Im was seeing was a check that the file hadn't shrunk out from
under us... [my phrasing]
I don't know: can one of the authors recollect?
If we know the intention of the callers, we could also
add a cache to sys_fstat:
--
@@ -98,6 +98,15 @@
int sys_fstat(int fd,SMB_STRUCT_STAT *sbuf)
{
int ret;
+ /* Cache: very dangerous if being used to poll a file for
changes. */
+ static int last_fd = 0;
+ static SMB_STRUCT_STAT last_sbuf = NULL;
+
+ if (fd == last_fd && last_sbuf == sbuf) {
+ return 0;
+ }
+ last_fd = fd;
+ last_sbuf = sbuf;
#if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_OFF64_T)
&& defined(HAVE_FSTAT64)
ret = fstat64(fd, sbuf);
#else
--
Optionally we could add a "ignore cache" flag to the interfaces,
to deal with this issue.
--dave
--
David Collier-Brown, | Always do right. This will gratify some people
185 Ellerslie Ave., | and astonish the rest. -- Mark Twain
Willowdale, Ontario | //www.oreilly.com/catalog/samba/author.html
Work: (905) 415-2849 Home: (416) 223-8968 Email: davecb at canada.sun.com
More information about the samba-technical
mailing list