72static const char *
const crlf =
"\r\n";
100 debugs(52, 3,
"urnFindMinRtt");
103 for (i = 0;
nullptr != urls[i].
url; ++i)
106 debugs(53, 3,
"urnFindMinRtt: Counted " << i <<
" URLs");
109 debugs(52, 3,
"urnFindMinRtt: Only one URL - return it!");
113 for (i = 0; i < urlcnt; ++i) {
115 debugs(52, 3,
"urnFindMinRtt: " << u->
host <<
" rtt=" << u->
rtt);
120 if (u->
rtt > min_rtt && min_rtt != 0)
132 (min_u ? min_u->
url :
"NONE") <<
"' RTT " <<
142 const auto host = r->
url.
host();
150 debugs(52, 3,
"Bad uri-res URL " << local_urlres);
152 err->url =
xstrdup(local_urlres);
164 debugs(52, 3,
"urnStart: '" << e->
url() <<
"'" );
178 if (!urlEntry || (urlEntry->hittingRequiresCollapsing() && !
startCollapsingOn(*urlEntry,
false))) {
183 urlEntry->abandon(__func__);
208 const auto anUrn =
new UrnState(ale);
220 else if (0 == u1->
rtt)
222 else if (0 == u2->
rtt)
242 debugs(52, 3, result <<
" with " << *e);
250 debugs(52, 3,
"terminating due to bad " << *e);
262 if (!remainingSpace.length) {
263 debugs(52, 3,
"ran out of buffer space after " << bufferedBytes <<
" bytes");
277 debugs(52, 3,
"got reply, code=" << peerReply.sline.status());
279 debugs(52, 3,
"urnHandleReply: failed.");
292 debugs(52, 3,
"urnTranslateDone: unknown URN " << e->
url());
300 for (i = 0; urls[i].
url; ++i)
303 debugs(53, 3,
"urnFindMinRtt: Counted " << i <<
" URLs");
306 char *min_url =
nullptr;
315 mb->
appendf(
"<TITLE>Select URL for %s</TITLE>\n"
316 "<STYLE type=\"text/css\"><!--BODY{background-color:#ffffff;font-family:verdana,sans-serif}--></STYLE>\n"
317 "<H2>Select URL for %s</H2>\n"
318 "<TABLE BORDER=\"0\" WIDTH=\"100%%\">\n", e->
url(), e->
url());
320 for (i = 0; i < urlcnt; ++i) {
324 "<TR><TD><A HREF=\"%s\">%s</A></TD>", u->
url, u->
url);
328 "<TD align=\"right\">%4d <it>ms</it></TD>", u->
rtt);
330 mb->
appendf(
"<TD align=\"right\">Unknown</TD>");
337 "<HR noshade size=\"1px\">\n"
339 "Generated by %s@%s\n"
354 for (i = 0; i < urlcnt; ++i) {
372 debugs(52, 3,
"urnParseReply");
378 auto buf = allocated;
382 for (token = strtok(buf,
crlf); token; token = strtok(
nullptr,
crlf)) {
383 debugs(52, 3,
"urnParseReply: got '" << token <<
"'");
389 memcpy(list, old, i *
sizeof(*list));
400 if (0 == list[i].rtt) {
416 debugs(52, 3,
"urnParseReply: Found " << i <<
" URLs");
void SBufToCstring(char *d, const SBuf &s)
#define SQUIDSBUFPRINT(s)
void(void *, StoreIOBuffer) STCB
#define SWALLOW_EXCEPTIONS(code)
#define CBDATA_CLASS_INIT(type)
#define CBDATA_CLASS(type)
void setRequest(HttpRequest *)
configure client request-related fields for the first time
AccessLogEntry::Pointer al
info for the future access.log, and external ACL
class AccessLogEntry::CacheDetails cache
void host(const char *src)
bool parse(const HttpRequestMethod &, const SBuf &url)
static void Start(const Comm::ConnectionPointer &client, StoreEntry *, HttpRequest *, const AccessLogEntryPointer &alp)
Initiates request forwarding to a peer or origin server.
void setHeaders(Http::StatusCode status, const char *reason, const char *ctype, int64_t clen, time_t lmt, time_t expires)
MasterXaction::Pointer masterXaction
the master transaction this request belongs to. Never nil.
static HttpRequest * FromUrlXXX(const char *url, const MasterXaction::Pointer &, const HttpRequestMethod &method=Http::METHOD_GET)
AnyP::Uri url
the request URI
const HttpReply & baseReply() const
size_type length() const
Returns the number of bytes stored in SBuf.
SBuf & appendf(const char *fmt,...) PRINTF_FORMAT_ARG2
a storeGetPublic*() caller
bool startCollapsingOn(const StoreEntry &, const bool doingRevalidation) const
int unlock(const char *context)
void lock(const char *context)
void replaceHttpReply(const HttpReplyPointer &, const bool andStartWriting=true)
StoreIOBuffer & positionAt(const int64_t newOffset)
convenience method for changing the offset of a being-configured buffer
struct StoreIOBuffer::@123 flags
size_t contentSize() const
the total number of append()ed bytes that were not consume()d
SBuf toSBuf() const
export content() into SBuf, avoiding content copying when possible
StoreIOBuffer makeInitialSpace()
void appended(const char *, size_t)
remember the new bytes received into the previously provided space()
AccessLogEntry::Pointer ale
details of the requesting transaction
void setUriResFromRequest(HttpRequest *)
HttpRequest::Pointer urlres_r
void start(HttpRequest *, StoreEntry *)
Store::ParsingBuffer parsingBuffer
for receiving a URN resolver reply body from Store and interpreting it
UrnState(const AccessLogEntry::Pointer &anAle)
LogTags * loggingTags() const override
void fillChecklist(ACLFilledChecklist &) const override
configure the given checklist (to reflect the current transaction state)
HttpRequest::Pointer request
#define debugs(SECTION, LEVEL, CONTENT)
#define EBIT_TEST(flag, bit)
char const * visible_appname_string
void errorAppendEntry(StoreEntry *entry, ErrorState *err)
void netdbPingSite(const char *hostname)
int netdbHostRtt(const char *host)
#define LOCAL_ARRAY(type, name, size)
StoreEntry * storeCreateEntry(const char *url, const char *logUrl, const RequestFlags &flags, const HttpRequestMethod &method)
StoreEntry * storeGetPublic(const char *uri, const HttpRequestMethod &method)
int storeUnregister(store_client *sc, StoreEntry *e, void *data)
void storeClientCopy(store_client *sc, StoreEntry *e, StoreIOBuffer copyInto, STCB *callback, void *data)
store_client * storeClientListAdd(StoreEntry *e, void *data)
struct url_entry::@127 flags
static const char *const crlf
void urnStart(HttpRequest *r, StoreEntry *e, const AccessLogEntryPointer &ale)
static url_entry * urnParseReply(const SBuf &, const HttpRequestMethod &)
static int url_entry_sort(const void *A, const void *B)
static url_entry * urnFindMinRtt(url_entry *urls, const HttpRequestMethod &, int *rtt_ret)
static STCB urnHandleReply
void * xcalloc(size_t n, size_t sz)