From 438fc1e324c5758438a7b52bbe5487aa60a37ded Mon Sep 17 00:00:00 2001 From: wessels <> Date: Tue, 18 Nov 1997 08:02:37 +0000 Subject: [PATCH] Replaced gross EBIT_SET(..., DELAY_SENDING) and EBIT_CLR(..., DELAY_SENDING) with storeBuffer() and storeBufferFlush(). --- src/ftp.cc | 14 +++++++++----- src/gopher.cc | 16 ++++++++-------- src/protos.h | 2 ++ src/stat.cc | 10 +++++----- src/store.cc | 17 ++++++++++++++++- 5 files changed, 40 insertions(+), 19 deletions(-) diff --git a/src/ftp.cc b/src/ftp.cc index 1cfeb4edbc..6ff24389d2 100644 --- a/src/ftp.cc +++ b/src/ftp.cc @@ -1,5 +1,5 @@ /* - * $Id: ftp.cc,v 1.170 1997/11/18 00:48:23 wessels Exp $ + * $Id: ftp.cc,v 1.171 1997/11/18 01:02:37 wessels Exp $ * * DEBUG: section 9 File Transfer Protocol (FTP) * AUTHOR: Harvest Derived @@ -258,6 +258,7 @@ ftpListingStart(FtpStateData * ftpState) { StoreEntry *e = ftpState->entry; wordlist *w; + storeBuffer(e); storeAppendPrintf(e, "\n", version_string); storeAppendPrintf(e, "\n", mkrfc1123(squid_curtime)); @@ -281,6 +282,7 @@ ftpListingStart(FtpStateData * ftpState) storeAppendPrintf(e, "FTP Directory: %s\n", ftpState->title_url); storeAppendPrintf(e, "\n"); storeAppendPrintf(e, "
\n");
+    storeBufferFlush(e);
     EBIT_SET(ftpState->flags, FTP_HTML_HEADER_SENT);
 }
 
@@ -288,6 +290,7 @@ static void
 ftpListingFinish(FtpStateData * ftpState)
 {
     StoreEntry *e = ftpState->entry;
+    storeBuffer(e);
     storeAppendPrintf(e, "
\n"); storeAppendPrintf(e, "
\n"); storeAppendPrintf(e, "
\n"); @@ -297,6 +300,7 @@ ftpListingFinish(FtpStateData * ftpState) version_string, getMyHostname()); storeAppendPrintf(e, "
\n"); + storeBufferFlush(e); } static const char *Month[] = @@ -608,6 +612,7 @@ ftpParseListing(FtpStateData * ftpState, int len) end++; /* XXX there is an ABR bug here. We need to make sure buf is * NULL terminated */ + storeBuffer(e); for (s = buf; s < end; s += strcspn(s, crlf), s += strspn(s, crlf)) { linelen = strcspn(s, crlf) + 1; if (linelen > 4096) @@ -620,6 +625,7 @@ ftpParseListing(FtpStateData * ftpState, int len) assert(t != NULL); storeAppend(e, t, strlen(t)); } + storeBufferFlush(e); assert(usable <= len); if (usable < len) { /* must copy partial line to beginning of buf */ @@ -710,9 +716,7 @@ ftpReadData(int fd, void *data) ftpReadComplete(ftpState); } else { if (EBIT_TEST(ftpState->flags, FTP_ISDIR)) { - EBIT_SET(entry->flag, DELAY_SENDING); ftpParseListing(ftpState, len); - EBIT_CLR(entry->flag, DELAY_SENDING); InvokeHandlers(entry); } else { assert(ftpState->data.offset == 0); @@ -1553,7 +1557,7 @@ ftpAppendSuccessHeader(FtpStateData * ftpState) mime_type = mimeGetContentType(filename); mime_enc = mimeGetContentEncoding(filename); } - EBIT_SET(e->flag, DELAY_SENDING); + storeBuffer(e); storeAppendPrintf(e, "HTTP/1.0 200 Gatewaying\r\n"); reply->code = 200; reply->version = 1.0; @@ -1575,8 +1579,8 @@ ftpAppendSuccessHeader(FtpStateData * ftpState) storeAppendPrintf(e, "Last-Modified: %s\r\n", mkrfc1123(ftpState->mdtm)); reply->last_modified = ftpState->mdtm; } - EBIT_CLR(e->flag, DELAY_SENDING); storeAppendPrintf(e, "\r\n"); + storeBufferFlush(e); reply->hdr_sz = e->mem_obj->inmem_hi; storeTimestampsSet(e); storeSetPublicKey(e); diff --git a/src/gopher.cc b/src/gopher.cc index 4c91f6a421..277cd9eb18 100644 --- a/src/gopher.cc +++ b/src/gopher.cc @@ -1,6 +1,6 @@ /* - * $Id: gopher.cc,v 1.113 1997/11/14 17:21:19 wessels Exp $ + * $Id: gopher.cc,v 1.114 1997/11/18 01:02:38 wessels Exp $ * * DEBUG: section 10 Gopher * AUTHOR: Harvest Derived @@ -371,7 +371,7 @@ gopherToHTML(GopherStateData * gopherState, char *inbuf, int len) "\n", storeUrl(entry), storeUrl(entry)); storeAppend(entry, outbuf, strlen(outbuf)); /* now let start sending stuff to client */ - EBIT_CLR(entry->flag, DELAY_SENDING); + storeBufferFlush(entry); gopherState->data_in = 1; return; @@ -387,7 +387,7 @@ gopherToHTML(GopherStateData * gopherState, char *inbuf, int len) storeAppend(entry, outbuf, strlen(outbuf)); /* now let start sending stuff to client */ - EBIT_CLR(entry->flag, DELAY_SENDING); + storeBufferFlush(entry); gopherState->data_in = 1; return; @@ -635,7 +635,7 @@ gopherToHTML(GopherStateData * gopherState, char *inbuf, int len) if ((int) strlen(outbuf) > 0) { storeAppend(entry, outbuf, strlen(outbuf)); /* now let start sending stuff to client */ - EBIT_CLR(entry->flag, DELAY_SENDING); + storeBufferFlush(entry); } return; } @@ -715,7 +715,7 @@ gopherReadReply(int fd, void *data) if (gopherState->conversion != NORMAL) gopherEndHTML(data); storeTimestampsSet(entry); - EBIT_CLR(entry->flag, DELAY_SENDING); + storeBufferFlush(entry); storeComplete(entry); comm_close(fd); } else { @@ -765,19 +765,19 @@ gopherSendComplete(int fd, char *buf, size_t size, int errflag, void *data) switch (gopherState->type_id) { case GOPHER_DIRECTORY: /* we got to convert it first */ - EBIT_SET(entry->flag, DELAY_SENDING); + storeBuffer(entry); gopherState->conversion = HTML_DIR; gopherState->HTML_header_added = 0; break; case GOPHER_INDEX: /* we got to convert it first */ - EBIT_SET(entry->flag, DELAY_SENDING); + storeBuffer(entry); gopherState->conversion = HTML_INDEX_RESULT; gopherState->HTML_header_added = 0; break; case GOPHER_CSO: /* we got to convert it first */ - EBIT_SET(entry->flag, DELAY_SENDING); + storeBuffer(entry); gopherState->conversion = HTML_CSO_RESULT; gopherState->cso_recno = 0; gopherState->HTML_header_added = 0; diff --git a/src/protos.h b/src/protos.h index 6ea2b80f07..200471252d 100644 --- a/src/protos.h +++ b/src/protos.h @@ -441,6 +441,8 @@ extern void storeMemObjectDump(MemObject * mem); extern const char *storeUrl(const StoreEntry *); extern void storeCreateMemObject(StoreEntry *, const char *, const char *); extern void storeCopyNotModifiedReplyHeaders(MemObject * O, MemObject * N); +extern void storeBuffer(StoreEntry *); +extern void storeBufferFlush(StoreEntry *); /* storeKey stuff */ extern const cache_key *storeKeyDup(const cache_key *); diff --git a/src/stat.cc b/src/stat.cc index dca48ba85b..911cf7ec0b 100644 --- a/src/stat.cc +++ b/src/stat.cc @@ -1,6 +1,6 @@ /* - * $Id: stat.cc,v 1.173 1997/11/15 06:36:36 wessels Exp $ + * $Id: stat.cc,v 1.174 1997/11/18 01:02:40 wessels Exp $ * * DEBUG: section 18 Cache Manager Statistics * AUTHOR: Harvest Derived @@ -329,7 +329,7 @@ statObjects(StoreEntry * sentry, int vm_or_not) if ((++N & 0xFF) == 0) { debug(18, 3) ("stat_objects_get: Processed %d objects...\n", N); } - EBIT_SET(sentry->flag, DELAY_SENDING); + storeBuffer(sentry); storeAppendPrintf(sentry, "KEY %s\n", storeKeyText(entry->key)); storeAppendPrintf(sentry, "\t%s %s\n", RequestMethodStr[entry->method], storeUrl(entry)); @@ -364,8 +364,8 @@ statObjects(StoreEntry * sentry, int vm_or_not) storeAppendPrintf(sentry, "\t\tswapin_fd: %d\n", (int) sc->swapin_fd); } - EBIT_CLR(sentry->flag, DELAY_SENDING); storeAppendPrintf(sentry, "\n"); + storeBufferFlush(sentry); } } @@ -975,7 +975,7 @@ statAvgDump(StoreEntry * sentry) A.select_loops /= N; A.cputime /= N; } - EBIT_SET(sentry->flag, DELAY_SENDING); + storeBuffer(sentry); storeAppendPrintf(sentry, "client_http.requests = %d\n", A.client_http.requests); storeAppendPrintf(sentry, "client_http.hits = %d\n", A.client_http.hits); storeAppendPrintf(sentry, "client_http.errors = %d\n", A.client_http.errors); @@ -988,6 +988,6 @@ statAvgDump(StoreEntry * sentry) storeAppendPrintf(sentry, "unlink.requests = %d\n", A.unlink.requests); storeAppendPrintf(sentry, "page_faults = %d\n", A.page_faults); storeAppendPrintf(sentry, "select_loops = %d\n", A.select_loops); - EBIT_CLR(sentry->flag, DELAY_SENDING); storeAppendPrintf(sentry, "cputime = %f seconds\n", A.cputime); + storeBufferFlush(sentry); } diff --git a/src/store.cc b/src/store.cc index dd8787a236..33e95135e6 100644 --- a/src/store.cc +++ b/src/store.cc @@ -1,6 +1,6 @@ /* - * $Id: store.cc,v 1.345 1997/11/18 00:48:46 wessels Exp $ + * $Id: store.cc,v 1.346 1997/11/18 01:02:42 wessels Exp $ * * DEBUG: section 20 Storeage Manager * AUTHOR: Harvest Derived @@ -2375,3 +2375,18 @@ storeCopyNotModifiedReplyHeaders(MemObject * oldmem, MemObject * newmem) if (newreply->expires > -1) oldreply->expires = newreply->expires; } + +/* this just sets DELAY_SENDING */ +void +storeBuffer(StoreEntry *e) +{ + EBIT_SET(e->flag, DELAY_SENDING); +} + +/* this just clears DELAY_SENDING and Invokes the handlers */ +void +storeBufferFlush(StoreEntry *e) +{ + EBIT_CLR(e->flag, DELAY_SENDING); + InvokeHandlers(e); +} -- 2.47.2