const cache_key * icpGetCacheKey(const char *url, int reqnum) { if (neighbors_do_private_keys && reqnum) return queried_keys[reqnum & N_QUERIED_KEYS_MASK]; return storeKeyPublic(url, METHOD_GET); }
/* ask store for a digest */ static void peerDigestRequest(PeerDigest * pd) { peer *p = pd->peer; StoreEntry *e, *old_e; char *url; const cache_key *key; request_t *req; DigestFetchState *fetch = NULL; pd->req_result = NULL; pd->flags.requested = 1; /* compute future request components */ if (p->digest_url) url = xstrdup(p->digest_url); else url = internalRemoteUri(p->host, p->http_port, "/squid-internal-periodic/", StoreDigestFileName); key = storeKeyPublic(url, METHOD_GET); debug(72, 2) ("peerDigestRequest: %s key: %s\n", url, storeKeyText(key)); req = urlParse(METHOD_GET, url); assert(req); /* add custom headers */ assert(!req->header.len); httpHeaderPutStr(&req->header, HDR_ACCEPT, StoreDigestMimeStr); httpHeaderPutStr(&req->header, HDR_ACCEPT, "text/html"); if (p->login) xstrncpy(req->login, p->login, MAX_LOGIN_SZ); /* create fetch state structure */ fetch = memAllocate(MEM_DIGEST_FETCH_STATE); cbdataAdd(fetch, memFree, MEM_DIGEST_FETCH_STATE); fetch->request = requestLink(req); fetch->pd = pd; fetch->offset = 0; /* update timestamps */ fetch->start_time = squid_curtime; pd->times.requested = squid_curtime; pd_last_req_time = squid_curtime; req->flags.cachable = 1; /* the rest is based on clientProcessExpired() */ req->flags.refresh = 1; old_e = fetch->old_entry = storeGet(key); if (old_e) { debug(72, 5) ("peerDigestRequest: found old entry\n"); storeLockObject(old_e); storeCreateMemObject(old_e, url, url); storeClientListAdd(old_e, fetch); } e = fetch->entry = storeCreateEntry(url, url, req->flags, req->method); assert(EBIT_TEST(e->flags, KEY_PRIVATE)); storeClientListAdd(e, fetch); /* set lastmod to trigger IMS request if possible */ if (old_e) e->lastmod = old_e->lastmod; /* push towards peer cache */ debug(72, 3) ("peerDigestRequest: forwarding to fwdStart...\n"); fwdStart(-1, e, req); cbdataLock(fetch); cbdataLock(fetch->pd); storeClientCopy(e, 0, 0, 4096, memAllocate(MEM_4K_BUF), peerDigestFetchReply, fetch); }
static fr_result accessLogReader(FileIterator * fi) { static char buf[4096]; RawAccessLogEntry *entry; char *url; char *method; int method_id = METHOD_NONE; char *hier = NULL; assert(fi); if (!fi->entry) fi->entry = xcalloc(1, sizeof(RawAccessLogEntry)); else memset(fi->entry, 0, sizeof(RawAccessLogEntry)); entry = fi->entry; if (!fgets(buf, sizeof(buf), fi->file)) return frEof; /* eof */ entry->timestamp = fi->inner_time = (time_t) atoi(buf); url = strstr(buf, "://"); hier = url ? strstr(url, " - ") : NULL; if (!url || !hier) { /*fprintf(stderr, "%s:%d: strange access log entry '%s'\n", * fname, scanned_count, buf); */ return frError; } method = url; while (!isdigit(*method)) { if (*method == ' ') *method = '\0'; --method; } method += 2; method_id = methodStrToId(method); if (method_id == METHOD_NONE) { /*fprintf(stderr, "%s:%d: invalid method %s in '%s'\n", * fname, scanned_count, method, buf); */ return frError; } while (*url) url--; url++; *hier = '\0'; hier += 3; *strchr(hier, '/') = '\0'; /*fprintf(stdout, "%s:%d: %s %s %s\n", * fname, count, method, url, hier); */ entry->use_icp = strcmp(hier, "NONE"); /* no ICP lookup for these status codes */ /* strcmp(hier, "NONE") && * strcmp(hier, "DIRECT") && * strcmp(hier, "FIREWALL_IP_DIRECT") && * strcmp(hier, "LOCAL_IP_DIRECT") && * strcmp(hier, "NO_DIRECT_FAIL") && * strcmp(hier, "NO_PARENT_DIRECT") && * strcmp(hier, "SINGLE_PARENT") && * strcmp(hier, "PASSTHROUGH_PARENT") && * strcmp(hier, "SSL_PARENT_MISS") && * strcmp(hier, "DEFAULT_PARENT"); */ xmemcpy(entry->key, storeKeyPublic(url, method_id), sizeof(entry->key)); /*fprintf(stdout, "%s:%d: %s %s %s %s\n", * fname, count, method, storeKeyText(entry->key), url, hier); */ return frOk; }