/*
- * $Id: mime.cc,v 1.34 1997/07/19 07:18:01 wessels Exp $
+ * $Id: mime.cc,v 1.35 1997/07/19 07:20:03 wessels Exp $
*
* DEBUG: section 25 MIME Parsing
* AUTHOR: Harvest Derived
static void
mimeLoadIconFile(const char *icon)
{
- int fd;
- int n;
- int l;
- struct stat sb;
- StoreEntry *e;
- LOCAL_ARRAY(char, path, MAXPATHLEN);
- LOCAL_ARRAY(char, url, MAX_URL);
- char *buf;
- snprintf(url, MAX_URL, "http://internal.squid/icons/%s", icon);
- if (storeGet(url))
- return;
- snprintf(path, MAXPATHLEN, "%s/%s", Config.icons.directory, icon);
- fd = file_open(path, O_RDONLY, NULL, NULL);
- if (fd < 0) {
- debug(25,0)("mimeLoadIconFile: %s: %s\n", path, xstrerror());
- return;
- }
- if (fstat(fd, &sb) < 0) {
- debug(50,0)("mimeLoadIconFile: FD %d: fstat: %s\n", fd, xstrerror());
- return;
- }
- e = storeCreateEntry(url,
- url,
- REQ_CACHABLE,
- METHOD_GET);
- assert(e != NULL);
- e->mem_obj->request = requestLink(urlParse(METHOD_GET, url));
- buf = get_free_4k_page();
- l = 0;
- l += snprintf(buf+l, SM_PAGE_SIZE-l, "HTTP/1.0 200 OK\r\n");
- l += snprintf(buf+l, SM_PAGE_SIZE-l, "Date: %s\r\n", mkrfc1123(squid_curtime));
- l += snprintf(buf+l, SM_PAGE_SIZE-l, "Server: Squid/%s\r\n", version_string);
- l += snprintf(buf+l, SM_PAGE_SIZE-l, "Content-Type: %s\r\n", Config.icons.content_type);
- l += snprintf(buf+l, SM_PAGE_SIZE-l, "Content-Length: %d\r\n", (int) sb.st_size);
- l += snprintf(buf+l, SM_PAGE_SIZE-l, "Last-Modified: %s\r\n", mkrfc1123(sb.st_mtime));
- l += snprintf(buf+l, SM_PAGE_SIZE-l, "Expires: %s\r\n", mkrfc1123(squid_curtime + 86400));
- l += snprintf(buf+l, SM_PAGE_SIZE-l, "\r\n");
- httpParseReplyHeaders(buf, e->mem_obj->reply);
- storeAppend(e, buf, l);
- while ((n = read(fd, buf, SM_PAGE_SIZE)) > 0)
- storeAppend(e, buf, n);
- file_close(fd);
- storeSetPublicKey(e);
- storeComplete(e);
- storeTimestampsSet(e);
- BIT_SET(e->flag, ENTRY_SPECIAL);
- debug(25,1)("Loaded icon %s\n", url);
- put_free_4k_page(buf);
+ int fd;
+ int n;
+ int l;
+ struct stat sb;
+ StoreEntry *e;
+ LOCAL_ARRAY(char, path, MAXPATHLEN);
+ LOCAL_ARRAY(char, url, MAX_URL);
+ char *buf;
+ snprintf(url, MAX_URL, "http://internal.squid/icons/%s", icon);
+ if (storeGet(url))
+ return;
+ snprintf(path, MAXPATHLEN, "%s/%s", Config.icons.directory, icon);
+ fd = file_open(path, O_RDONLY, NULL, NULL);
+ if (fd < 0) {
+ debug(25, 0) ("mimeLoadIconFile: %s: %s\n", path, xstrerror());
+ return;
+ }
+ if (fstat(fd, &sb) < 0) {
+ debug(50, 0) ("mimeLoadIconFile: FD %d: fstat: %s\n", fd, xstrerror());
+ return;
+ }
+ e = storeCreateEntry(url,
+ url,
+ REQ_CACHABLE,
+ METHOD_GET);
+ assert(e != NULL);
+ e->mem_obj->request = requestLink(urlParse(METHOD_GET, url));
+ buf = get_free_4k_page();
+ l = 0;
+ l += snprintf(buf + l, SM_PAGE_SIZE - l, "HTTP/1.0 200 OK\r\n");
+ l += snprintf(buf + l, SM_PAGE_SIZE - l, "Date: %s\r\n", mkrfc1123(squid_curtime));
+ l += snprintf(buf + l, SM_PAGE_SIZE - l, "Server: Squid/%s\r\n", version_string);
+ l += snprintf(buf + l, SM_PAGE_SIZE - l, "Content-Type: %s\r\n", Config.icons.content_type);
+ l += snprintf(buf + l, SM_PAGE_SIZE - l, "Content-Length: %d\r\n", (int) sb.st_size);
+ l += snprintf(buf + l, SM_PAGE_SIZE - l, "Last-Modified: %s\r\n", mkrfc1123(sb.st_mtime));
+ l += snprintf(buf + l, SM_PAGE_SIZE - l, "Expires: %s\r\n", mkrfc1123(squid_curtime + 86400));
+ l += snprintf(buf + l, SM_PAGE_SIZE - l, "\r\n");
+ httpParseReplyHeaders(buf, e->mem_obj->reply);
+ storeAppend(e, buf, l);
+ while ((n = read(fd, buf, SM_PAGE_SIZE)) > 0)
+ storeAppend(e, buf, n);
+ file_close(fd);
+ storeSetPublicKey(e);
+ storeComplete(e);
+ storeTimestampsSet(e);
+ BIT_SET(e->flag, ENTRY_SPECIAL);
+ debug(25, 1) ("Loaded icon %s\n", url);
+ put_free_4k_page(buf);
}
/*
- * $Id: peer_select.cc,v 1.22 1997/07/19 04:01:24 wessels Exp $
+ * $Id: peer_select.cc,v 1.23 1997/07/19 07:20:04 wessels Exp $
*
* DEBUG: section 44 Peer Selection Algorithm
* AUTHOR: Duane Wessels
int timeouts;
} PeerStats;
-static char *DirectStr[] = {
- "DIRECT_NO",
- "DIRECT_MAYBE",
- "DIRECT_YES"
+static char *DirectStr[] =
+{
+ "DIRECT_NO",
+ "DIRECT_MAYBE",
+ "DIRECT_YES"
};
static void peerSelectFoo _PARAMS((ps_state *));
int n;
if (entry == NULL)
return 0;
- debug(44,3)("peerSelectIcpPing: %s\n", entry->url);
+ debug(44, 3) ("peerSelectIcpPing: %s\n", entry->url);
if (entry->ping_status != PING_NONE)
return 0;
if (direct == DIRECT_YES)
if (direct != DIRECT_NO)
return 0;
n = neighborsCount(request);
- debug(44,3)("peerSelectIcpPing: counted %d neighbors\n", n);
+ debug(44, 3) ("peerSelectIcpPing: counted %d neighbors\n", n);
return n;
}
{
ps_state *psstate = xcalloc(1, sizeof(ps_state));
if (entry)
- debug(44,3)("peerSelect: %s\n", entry->url);
+ debug(44, 3) ("peerSelect: %s\n", entry->url);
else
- debug(44,3)("peerSelect: %s\n", RequestMethodStr[request->method]);
+ debug(44, 3) ("peerSelect: %s\n", RequestMethodStr[request->method]);
cbdataAdd(psstate);
psstate->request = requestLink(request);
psstate->entry = entry;
StoreEntry *entry = psstate->entry;
void *data = psstate->callback_data;
if (entry) {
- debug(44, 3) ("peerSelectCallback: %s\n", entry->url);
+ debug(44, 3) ("peerSelectCallback: %s\n", entry->url);
if (entry->ping_status == PING_WAITING)
eventDelete(peerPingTimeout, psstate);
entry->ping_status = PING_DONE;
ps_state *psstate = data;
StoreEntry *entry = psstate->entry;
if (entry)
- debug(44, 3) ("peerPingTimeout: '%s'\n", entry->url);
+ debug(44, 3) ("peerPingTimeout: '%s'\n", entry->url);
entry->ping_status = PING_TIMEOUT;
PeerStats.timeouts++;
psstate->icp.timeout = 1;
ps_state *psstate = data;
int w_rtt;
request_t *request = psstate->request;
- debug(44,3)("peerHandleIcpReply: %s %s\n",
+ debug(44, 3) ("peerHandleIcpReply: %s %s\n",
IcpOpcodeStr[op],
psstate->entry->url);
psstate->icp.n_recv++;