From 11fa293e41a9c1c0a9ddaa7455b0fffc1e69ba65 Mon Sep 17 00:00:00 2001 From: Ron Pedde Date: Sun, 14 May 2006 04:14:50 +0000 Subject: [PATCH] buffer output on web pages, make safari faster --- src/configfile.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/configfile.c b/src/configfile.c index 8770d9a8..c468c416 100644 --- a/src/configfile.c +++ b/src/configfile.c @@ -198,9 +198,15 @@ void config_subst_stream(WS_CONNINFO *pwsc, int fd_src) { CONFIGELEMENT *pce; char *first, *last; + char outbuffer[1024]; + int out_index; + + + /* now throw out the file, with replacements */ in_arg=0; argptr=argbuffer; + out_index=0; while(1) { if(r_read(fd_src,&next,1) <= 0) @@ -240,12 +246,27 @@ void config_subst_stream(WS_CONNINFO *pwsc, int fd_src) { argptr=argbuffer; memset(argbuffer,0,sizeof(argbuffer)); in_arg=1; + + /* flush whatever is in the buffer */ + if(out_index) { + r_write(pwsc->fd,outbuffer,out_index); + out_index=0; + } } else { - if(r_write(pwsc->fd,&next,1) == -1) - break; + outbuffer[out_index] = next; + out_index++; + + if(out_index == sizeof(outbuffer)) { + r_write(pwsc->fd,outbuffer,out_index); + out_index=0; + } } } } + if(out_index) { + r_write(pwsc->fd,outbuffer,out_index); + out_index=0; + } } /**