small optimization for history writes

Forrest J. Cavalier III mibsoft at epix.net
Fri Nov 30 16:10:12 UTC 2001


How does this patch work?  It looks like offset will
be uninitialized for the use later in the function....
    r = hisv6_writedbz(h, hash, offset);

Did you leave something out?

> From:          list-inn-workers at news.cistron.nl (Miquel van Smoorenburg)
> Subject:       small optimization for history writes
> Date:          Fri, 30 Nov 2001 15:46:40 +0000 (UTC)
> Organization:  Cistron Internet Services B.V.
> To:            inn-workers at isc.org

> Glibc has the weird property that it fflush()es a FILE when you
> use ftell() / ftello(). This is probably because it uses some sort
> of lseek(fd, 0, SEEK_SET) internally and that incorrectly flushes
> the buffers because buffers need to be flushed on fseek().
> 
> Anyway, the small patch below optimizes writes during expire from
> 90-byte write() to 4K write()s.
> 
> The only thing is that I am not sure if ftello is valid after
> fputs() or fflush() has returned an error. It probably is, though.
> 
> --- history/hisv6/hisv6.c.orig	Fri Nov 30 16:37:55 2001
> +++ history/hisv6/hisv6.c	Fri Nov 30 14:44:04 2001
> @@ -784,10 +784,15 @@
>  	return false;
>      }	
>  
> +#ifndef __GLIBC__
>      offset = ftello(h->writefp);
> +#endif
>      i = fputs(hisline, h->writefp);
>      if (i == EOF ||
>  	(!(h->flags & HIS_INCORE) && fflush(h->writefp) == EOF)) {
> +#ifdef __GLIBC__
> +	offset = ftello(h->writefp);
> +#endif
>  	hisv6_errloc(location, (size_t)-1, offset);
>  	/* The history line is now an orphan... */
>  	hisv6_seterror(h, concat("can't write history ", h->histpath,
> 
> 
> Mike.
> -- 
> "Only two things are infinite, the universe and human stupidity,
>  and I'm not sure about the former" -- Albert Einstein.
> 
> -- 
> The From: and Reply-To: addresses are internal news2mail gateway addresses.
> Reply to the list or to miquels at cistron-office.nl (Miquel van Smoorenburg)
> 
> 



More information about the inn-workers mailing list