This is the mail archive of the cygwin-developers@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: WriteFile() whacks st_atime patch


On Mon, Sep 17, 2001 at 09:38:33AM -0400, Jason Tishler wrote:
> On Wed, Sep 12, 2001 at 12:24:21AM +1000, Robert Collins wrote:
> > On Tue, 2001-09-11 at 06:22, Corinna Vinschen wrote:
> > > On Mon, Sep 10, 2001 at 03:44:31PM -0400, Jason Tishler wrote: 
> > > > Given the above problems, I have very mixed feelings about this patch.
> > > > Is it worth pursuing or should I dropped it?
> > > 
> > > Frankly, I don't know.  My first guess is to prioritize correctness
> > > over speed and with your patch the functionality seems to be at 
> > > least `more correct'.  Would it perhaps make sense to change
> > > that to something like:
> > 
> > I think correctness in this case is well worth it, as it's obviously
> > causing some problems out there. However, it would be good to bench the
> > difference building cygwin or something, to see the impact.
> 
> I will attempt to benchmark the performance impact using both a
> specialized test program (e.g., writes with and without GetFileTime and
> SetFileTime calls) and a more generalized scenario such as building
> Cygwin (as Rob suggested).
> 
> BTW, while fiddling around, I discovered that an overridden raw_read()
> will be need too:
> 
>     int
>     fhandler_disk_file::raw_read (void *ptr, size_t len)
>     {
>       int bytes_read = fhandler_base::raw_read(ptr, len);
>       if (bytes_read > 0)
>         {
>           FILETIME now;
>           BOOL status = GetSystemTimeAsFileTime (&now);
>           if (status)
>             SetFileTime (get_handle(), 0, &now, 0);
>         }
>       return bytes_read;
>     }
> 
> It appears that Windows does not update the last access time until the
> file is closed or at least not immediately (possibly due to caching?).
> In contract, on Red Linux 7.1, st_atime is updated immediately upon a
> read -- even if the file is still open.

Jason,

since your both patches to set the file time will probably result in a
performance loss and since only a few applications have a problem with
the windows behaviour... what do you think about conditionalize your
patch using a global flag (e.g. force_unix_ftime_behaviour) which is
set to FALSE by default?  If somebody want's to link an application
so that it sets the filetime accordingly, it could be linked against
a `setftime.o' file which we could build in the cygwin source dir
and which is used as the binmode.o/textmode.o/automode.o files. The
setftime.c file would simply look like:

void
cygwin_premain1 (int argc, char **argv, struct per_process *myself)
{
  extern BOOL force_unix_ftime_behaviour;

  force_unix_ftime_behaviour = TRUE;
}


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Developer                                mailto:cygwin@cygwin.com
Red Hat, Inc.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]