small optimization for history writes
Miquel van Smoorenburg
list-inn-workers at news.cistron.nl
Fri Nov 30 15:46:40 UTC 2001
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