Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: PATCH: check deleted .zwc files



On Jun 8,  3:04pm, Clint Adams wrote:
> Subject: Re: PATCH: check deleted .zwc files
> 
> > What happens if the file has been deleted and re-created?  zwcstat()
> > will return the stat info for the newly-created file, but what will
> > autoloading do with the now-obsolete (?) file handle?
> 
> Oops.  It will do nothing with it, just as it did nothing with it before.

Maybe this is a flaw in the whole .zwc loading scheme, then.

What I'm getting at is this scenario:

I have a .zwc file for several functions.  I update one of those functions.
I then remove and rebuild the .zwc file.  Now, stat() of the .zwc shows
that it is newer than the function file, but any running zsh still has a
mapped descriptor on the removed file.  With this code:

>      if (stat(filename, buf)) {
>  #ifdef HAVE_FSTAT
>  	for (f = dumps; f; f = f->next) {
> +	    if (!strncmp(filename, f->filename, strlen(f->filename)) &&
> +		!fstat(f->fd, buf))
> +		return 0;
>  	}
>  #endif
>  	return 1;

zwcstat() will cause zsh to decide that it can keep using the mapped copy,
even though the function file is actually newer than the mapped copy.

The only safe thing to do is to try the fstat() first, then stat().  To be
really complete, if fstat() and stat() disagree zsh should throw out the
mapped file and reload it, but that could get pretty tricky.



Messages sorted by: Reverse Date, Date, Thread, Author