You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2015/03/23 21:33:17 UTC
[44/52] [partial] trafficserver git commit: TS-3419 Fix some enum's
such that clang-format can handle it the way we want. Basically this means
having a trailing ,
on short enum's. TS-3419 Run clang-format over most of the source
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/iocore/cache/CachePages.cc
----------------------------------------------------------------------
diff --git a/iocore/cache/CachePages.cc b/iocore/cache/CachePages.cc
index 5aa8bc5..13f2b2a 100644
--- a/iocore/cache/CachePages.cc
+++ b/iocore/cache/CachePages.cc
@@ -28,11 +28,11 @@
#include "I_Tasks.h"
#include "CacheControl.h"
-struct ShowCache: public ShowCont {
+struct ShowCache : public ShowCont {
enum scan_type {
scan_type_lookup,
scan_type_delete,
- scan_type_invalidate
+ scan_type_invalidate,
};
int vol_index;
@@ -65,9 +65,9 @@ struct ShowCache: public ShowCont {
int handleCacheDeleteComplete(int event, Event *e);
int handleCacheScanCallback(int event, Event *e);
- ShowCache(Continuation *c, HTTPHdr *h):
- ShowCont(c, h), vol_index(0), seg_index(0), scan_flag(scan_type_lookup),
- cache_vc(0), buffer(0), buffer_reader(0), content_length(0), cvio(0)
+ ShowCache(Continuation *c, HTTPHdr *h)
+ : ShowCont(c, h), vol_index(0), seg_index(0), scan_flag(scan_type_lookup), cache_vc(0), buffer(0), buffer_reader(0),
+ content_length(0), cvio(0)
{
urlstrs_index = 0;
linecount = 0;
@@ -93,7 +93,7 @@ struct ShowCache: public ShowCont {
unsigned l, m;
for (l = 0, m = 0; l < (unsigned)query_len; l++) {
if (query[l] != '\015') {
- query[m++] = query[l];
+ query[m++] = query[l];
}
}
query[m] = '\0';
@@ -104,7 +104,7 @@ struct ShowCache: public ShowCont {
if (p) {
while ((p = strstr(p, "\n"))) {
nstrings++;
- if ((size_t) (p - query) >= strlen(query) - 1)
+ if ((size_t)(p - query) >= strlen(query) - 1)
break;
else
p++;
@@ -112,22 +112,22 @@ struct ShowCache: public ShowCont {
}
// initialize url array
show_cache_urlstrs = new char[nstrings + 1][500];
- memset(show_cache_urlstrs, '\0', (nstrings + 1) * 500 * sizeof (char));
+ memset(show_cache_urlstrs, '\0', (nstrings + 1) * 500 * sizeof(char));
char *q, *t;
p = strstr(unescapedQuery, "url=");
if (p) {
- p += 4; // 4 ==> strlen("url=")
+ p += 4; // 4 ==> strlen("url=")
t = strchr(p, '&');
if (!t)
- t = (char *) unescapedQuery + strlen(unescapedQuery);
+ t = (char *)unescapedQuery + strlen(unescapedQuery);
for (int s = 0; p < t; s++) {
show_cache_urlstrs[s][0] = '\0';
- q = strstr(p, "%0D%0A" /* \r\n */); // we used this in the JS to separate urls
+ q = strstr(p, "%0D%0A" /* \r\n */); // we used this in the JS to separate urls
if (!q)
q = t;
ink_strlcpy(show_cache_urlstrs[s], p, sizeof(show_cache_urlstrs[s]));
- p = q + 6; // +6 ==> strlen(%0D%0A)
+ p = q + 6; // +6 ==> strlen(%0D%0A)
}
}
@@ -141,27 +141,27 @@ struct ShowCache: public ShowCont {
unescapifyStr(show_cache_urlstrs[i]);
Debug("cache_inspector", "URL %d: '%s'", i + 1, show_cache_urlstrs[i]);
}
-
}
SET_HANDLER(&ShowCache::showMain);
}
- ~ShowCache() {
+ ~ShowCache()
+ {
if (show_cache_urlstrs)
- delete[]show_cache_urlstrs;
+ delete[] show_cache_urlstrs;
url.destroy();
}
-
};
-#define STREQ_PREFIX(_x,_s) (!strncasecmp(_x,_s,sizeof(_s)-1))
-#define STREQ_LEN_PREFIX(_x,_l,_s) (path_len < sizeof(_s) && !strncasecmp(_x,_s,sizeof(_s)-1))
+#define STREQ_PREFIX(_x, _s) (!strncasecmp(_x, _s, sizeof(_s) - 1))
+#define STREQ_LEN_PREFIX(_x, _l, _s) (path_len < sizeof(_s) && !strncasecmp(_x, _s, sizeof(_s) - 1))
Action *
-register_ShowCache(Continuation *c, HTTPHdr *h) {
- ShowCache * theshowcache = new ShowCache(c, h);
+register_ShowCache(Continuation *c, HTTPHdr *h)
+{
+ ShowCache *theshowcache = new ShowCache(c, h);
URL *u = h->url_get();
int path_len;
const char *path = u->path_get(&path_len);
@@ -201,7 +201,8 @@ register_ShowCache(Continuation *c, HTTPHdr *h) {
}
int
-ShowCache::showMain(int event, Event *e) {
+ShowCache::showMain(int event, Event *e)
+{
CHECK_SHOW(begin("Cache"));
CHECK_SHOW(show("<H3><A HREF=\"./lookup_url_form\">Lookup url</A></H3>\n"
"<H3><A HREF=\"./delete_url_form\">Delete url</A></H3>\n"
@@ -218,19 +219,24 @@ ShowCache::lookup_url_form(int event, Event *e)
CHECK_SHOW(show("<FORM METHOD=\"GET\" ACTION=\"./lookup_url\">\n"
"<H3>Lookup</H3>\n"
"<INPUT TYPE=\"TEXT\" NAME=\"url\" value=\"http://\">\n"
- "<INPUT TYPE=\"SUBMIT\" value=\"Lookup\">\n" "</FORM>\n\n"));
+ "<INPUT TYPE=\"SUBMIT\" value=\"Lookup\">\n"
+ "</FORM>\n\n"));
return complete(event, e);
}
int
-ShowCache::delete_url_form(int event, Event *e) {
+ShowCache::delete_url_form(int event, Event *e)
+{
CHECK_SHOW(begin("Cache Delete"));
CHECK_SHOW(show("<FORM METHOD=\"GET\" ACTION=\"./delete_url\">\n"
"<P><B>Type the list urls that you want to delete\n"
"in the box below. The urls MUST be separated by\n"
"new lines</B></P>\n\n"
"<TEXTAREA NAME=\"url\" rows=10 cols=50>"
- "http://" "</TEXTAREA>\n" "<INPUT TYPE=\"SUBMIT\" value=\"Delete\">\n" "</FORM>\n\n"));
+ "http://"
+ "</TEXTAREA>\n"
+ "<INPUT TYPE=\"SUBMIT\" value=\"Delete\">\n"
+ "</FORM>\n\n"));
return complete(event, e);
}
@@ -243,171 +249,187 @@ ShowCache::lookup_regex_form(int event, Event *e)
"in the box below. The regular expressions MUST be separated by\n"
"new lines</B></P>\n\n"
"<TEXTAREA NAME=\"url\" rows=10 cols=50>"
- "http://" "</TEXTAREA>\n" "<INPUT TYPE=\"SUBMIT\" value=\"Lookup\">\n" "</FORM>\n\n"));
+ "http://"
+ "</TEXTAREA>\n"
+ "<INPUT TYPE=\"SUBMIT\" value=\"Lookup\">\n"
+ "</FORM>\n\n"));
return complete(event, e);
}
int
-ShowCache::delete_regex_form(int event, Event *e) {
+ShowCache::delete_regex_form(int event, Event *e)
+{
CHECK_SHOW(begin("Cache Regex delete"));
CHECK_SHOW(show("<FORM METHOD=\"GET\" ACTION=\"./delete_regex\">\n"
"<P><B>Type the list of regular expressions that you want to delete\n"
"in the box below. The regular expressions MUST be separated by\n"
"new lines</B></P>\n\n"
"<TEXTAREA NAME=\"url\" rows=10 cols=50>"
- "http://" "</TEXTAREA>\n" "<INPUT TYPE=\"SUBMIT\" value=\"Delete\">\n" "</FORM>\n\n"));
+ "http://"
+ "</TEXTAREA>\n"
+ "<INPUT TYPE=\"SUBMIT\" value=\"Delete\">\n"
+ "</FORM>\n\n"));
return complete(event, e);
}
int
-ShowCache::invalidate_regex_form(int event, Event *e) {
+ShowCache::invalidate_regex_form(int event, Event *e)
+{
CHECK_SHOW(begin("Cache Regex Invalidate"));
CHECK_SHOW(show("<FORM METHOD=\"GET\" ACTION=\"./invalidate_regex\">\n"
"<P><B>Type the list of regular expressions that you want to invalidate\n"
"in the box below. The regular expressions MUST be separated by\n"
"new lines</B></P>\n\n"
"<TEXTAREA NAME=\"url\" rows=10 cols=50>"
- "http://" "</TEXTAREA>\n" "<INPUT TYPE=\"SUBMIT\" value=\"Invalidate\">\n" "</FORM>\n"));
+ "http://"
+ "</TEXTAREA>\n"
+ "<INPUT TYPE=\"SUBMIT\" value=\"Invalidate\">\n"
+ "</FORM>\n"));
return complete(event, e);
}
int
-ShowCache::handleCacheEvent(int event, Event *e) {
+ShowCache::handleCacheEvent(int event, Event *e)
+{
// we use VC_EVENT_xxx to finish the cluster read in cluster mode
switch (event) {
- case VC_EVENT_EOS:
- case VC_EVENT_READ_COMPLETE: {
- // cluster read done, we just print hit in cluster
+ case VC_EVENT_EOS:
+ case VC_EVENT_READ_COMPLETE: {
+ // cluster read done, we just print hit in cluster
+ CHECK_SHOW(show("<P><TABLE border=1 width=100%%>"));
+ CHECK_SHOW(show("<TR><TH bgcolor=\"#FFF0E0\" colspan=2>Doc Hit from Cluster</TH></TR>\n"));
+ CHECK_SHOW(show("<tr><td>Size</td><td>%" PRId64 "</td>\n", content_length));
+
+ // delete button
+ CHECK_SHOW(show("<tr><td>Action</td>\n"
+ "<td><FORM action=\"./delete_url\" method=get>\n"
+ "<Input type=HIDDEN name=url value=\"%s\">\n"
+ "<input type=submit value=\"Delete URL\">\n"
+ "</FORM></td></tr>\n",
+ show_cache_urlstrs[0]));
+ CHECK_SHOW(show("</TABLE></P>"));
+
+ if (buffer_reader) {
+ buffer->dealloc_reader(buffer_reader);
+ buffer_reader = 0;
+ }
+ if (buffer) {
+ free_MIOBuffer(buffer);
+ buffer = 0;
+ }
+ cvio = 0;
+ cache_vc->do_io_close(-1);
+ cache_vc = 0;
+ return complete(event, e);
+ }
+ case CACHE_EVENT_OPEN_READ: {
+ // get the vector
+ cache_vc = (CacheVC *)e;
+ CacheHTTPInfoVector *vec = &(cache_vc->vector);
+ int alt_count = vec->count();
+ if (alt_count) {
+ Doc *d = (Doc *)(cache_vc->first_buf->data());
+ time_t t;
+ char tmpstr[4096];
+
+ // print the Doc
CHECK_SHOW(show("<P><TABLE border=1 width=100%%>"));
- CHECK_SHOW(show("<TR><TH bgcolor=\"#FFF0E0\" colspan=2>Doc Hit from Cluster</TH></TR>\n"));
- CHECK_SHOW(show("<tr><td>Size</td><td>%" PRId64 "</td>\n", content_length));
+ CHECK_SHOW(show("<TR><TH bgcolor=\"#FFF0E0\" colspan=2>Doc</TH></TR>\n"));
+ CHECK_SHOW(
+ show("<TR><TD>Volume</td> <td>#%d - store='%s'</td></tr>\n", cache_vc->vol->cache_vol->vol_number, cache_vc->vol->path));
+ CHECK_SHOW(show("<TR><TD>first key</td> <td>%s</td></tr>\n", d->first_key.toHexStr(tmpstr)));
+ CHECK_SHOW(show("<TR><TD>key</td> <td>%s</td></tr>\n", d->key.toHexStr(tmpstr)));
+ CHECK_SHOW(show("<tr><td>sync_serial</td><td>%lu</tr>\n", d->sync_serial));
+ CHECK_SHOW(show("<tr><td>write_serial</td><td>%lu</tr>\n", d->write_serial));
+ CHECK_SHOW(show("<tr><td>header length</td><td>%lu</tr>\n", d->hlen));
+ CHECK_SHOW(show("<tr><td>fragment type</td><td>%lu</tr>\n", d->doc_type));
+ CHECK_SHOW(show("<tr><td>No of Alternates</td><td>%d</td></tr>\n", alt_count));
- // delete button
CHECK_SHOW(show("<tr><td>Action</td>\n"
"<td><FORM action=\"./delete_url\" method=get>\n"
"<Input type=HIDDEN name=url value=\"%s\">\n"
- "<input type=submit value=\"Delete URL\">\n" "</FORM></td></tr>\n",
+ "<input type=submit value=\"Delete URL\">\n"
+ "</FORM></td></tr>\n",
show_cache_urlstrs[0]));
CHECK_SHOW(show("</TABLE></P>"));
- if (buffer_reader) {
- buffer->dealloc_reader(buffer_reader);
- buffer_reader = 0;
- }
- if (buffer) {
- free_MIOBuffer(buffer);
- buffer = 0;
+ for (int i = 0; i < alt_count; i++) {
+ // unmarshal the alternate??
+ CHECK_SHOW(show("<p><table border=1>\n"));
+ CHECK_SHOW(show("<tr><th bgcolor=\"#FFF0E0\" colspan=2>Alternate %d</th></tr>\n", i + 1));
+ CacheHTTPInfo *obj = vec->get(i);
+ CacheKey obj_key = obj->object_key_get();
+ HTTPHdr *cached_request = obj->request_get();
+ HTTPHdr *cached_response = obj->response_get();
+ int64_t obj_size = obj->object_size_get();
+ int offset, tmp, used, done;
+ char b[4096];
+
+ // print request header
+ CHECK_SHOW(show("<tr><td>Request Header</td><td><PRE>"));
+ offset = 0;
+ do {
+ used = 0;
+ tmp = offset;
+ done = cached_request->print(b, 4095, &used, &tmp);
+ offset += used;
+ b[used] = '\0';
+ CHECK_SHOW(show("%s", b));
+ } while (!done);
+ CHECK_SHOW(show("</PRE></td><tr>\n"));
+
+ // print response header
+ CHECK_SHOW(show("<tr><td>Response Header</td><td><PRE>"));
+ offset = 0;
+ do {
+ used = 0;
+ tmp = offset;
+ done = cached_response->print(b, 4095, &used, &tmp);
+ offset += used;
+ b[used] = '\0';
+ CHECK_SHOW(show("%s", b));
+ } while (!done);
+ CHECK_SHOW(show("</PRE></td></tr>\n"));
+ CHECK_SHOW(show("<tr><td>Size</td><td>%" PRId64 "</td>\n", obj_size));
+ CHECK_SHOW(show("<tr><td>Key</td><td>%s</td>\n", obj_key.toHexStr(tmpstr)));
+ t = obj->request_sent_time_get();
+ ink_ctime_r(&t, tmpstr);
+ CHECK_SHOW(show("<tr><td>Request sent time</td><td>%s</td></tr>\n", tmpstr));
+ t = obj->response_received_time_get();
+ ink_ctime_r(&t, tmpstr);
+
+ CHECK_SHOW(show("<tr><td>Response received time</td><td>%s</td></tr>\n", tmpstr));
+ CHECK_SHOW(show("</TABLE></P>"));
}
- cvio = 0;
+
cache_vc->do_io_close(-1);
- cache_vc = 0;
return complete(event, e);
}
- case CACHE_EVENT_OPEN_READ: {
- // get the vector
- cache_vc = (CacheVC *) e;
- CacheHTTPInfoVector *vec = &(cache_vc->vector);
- int alt_count = vec->count();
- if (alt_count) {
- Doc *d = (Doc *) (cache_vc->first_buf->data());
- time_t t;
- char tmpstr[4096];
-
- // print the Doc
- CHECK_SHOW(show("<P><TABLE border=1 width=100%%>"));
- CHECK_SHOW(show("<TR><TH bgcolor=\"#FFF0E0\" colspan=2>Doc</TH></TR>\n"));
- CHECK_SHOW(show("<TR><TD>Volume</td> <td>#%d - store='%s'</td></tr>\n", cache_vc->vol->cache_vol->vol_number, cache_vc->vol->path));
- CHECK_SHOW(show("<TR><TD>first key</td> <td>%s</td></tr>\n", d->first_key.toHexStr(tmpstr)));
- CHECK_SHOW(show("<TR><TD>key</td> <td>%s</td></tr>\n", d->key.toHexStr(tmpstr)));
- CHECK_SHOW(show("<tr><td>sync_serial</td><td>%lu</tr>\n", d->sync_serial));
- CHECK_SHOW(show("<tr><td>write_serial</td><td>%lu</tr>\n", d->write_serial));
- CHECK_SHOW(show("<tr><td>header length</td><td>%lu</tr>\n", d->hlen));
- CHECK_SHOW(show("<tr><td>fragment type</td><td>%lu</tr>\n", d->doc_type));
- CHECK_SHOW(show("<tr><td>No of Alternates</td><td>%d</td></tr>\n", alt_count));
-
- CHECK_SHOW(show("<tr><td>Action</td>\n"
- "<td><FORM action=\"./delete_url\" method=get>\n"
- "<Input type=HIDDEN name=url value=\"%s\">\n"
- "<input type=submit value=\"Delete URL\">\n" "</FORM></td></tr>\n",
- show_cache_urlstrs[0]));
- CHECK_SHOW(show("</TABLE></P>"));
-
- for (int i = 0; i < alt_count; i++) {
- // unmarshal the alternate??
- CHECK_SHOW(show("<p><table border=1>\n"));
- CHECK_SHOW(show("<tr><th bgcolor=\"#FFF0E0\" colspan=2>Alternate %d</th></tr>\n", i + 1));
- CacheHTTPInfo *obj = vec->get(i);
- CacheKey obj_key = obj->object_key_get();
- HTTPHdr *cached_request = obj->request_get();
- HTTPHdr *cached_response = obj->response_get();
- int64_t obj_size = obj->object_size_get();
- int offset, tmp, used, done;
- char b[4096];
-
- // print request header
- CHECK_SHOW(show("<tr><td>Request Header</td><td><PRE>"));
- offset = 0;
- do {
- used = 0;
- tmp = offset;
- done = cached_request->print(b, 4095, &used, &tmp);
- offset += used;
- b[used] = '\0';
- CHECK_SHOW(show("%s", b));
- } while (!done);
- CHECK_SHOW(show("</PRE></td><tr>\n"));
-
- // print response header
- CHECK_SHOW(show("<tr><td>Response Header</td><td><PRE>"));
- offset = 0;
- do {
- used = 0;
- tmp = offset;
- done = cached_response->print(b, 4095, &used, &tmp);
- offset += used;
- b[used] = '\0';
- CHECK_SHOW(show("%s", b));
- } while (!done);
- CHECK_SHOW(show("</PRE></td></tr>\n"));
- CHECK_SHOW(show("<tr><td>Size</td><td>%" PRId64 "</td>\n", obj_size));
- CHECK_SHOW(show("<tr><td>Key</td><td>%s</td>\n", obj_key.toHexStr(tmpstr)));
- t = obj->request_sent_time_get();
- ink_ctime_r(&t, tmpstr);
- CHECK_SHOW(show("<tr><td>Request sent time</td><td>%s</td></tr>\n", tmpstr));
- t = obj->response_received_time_get();
- ink_ctime_r(&t, tmpstr);
-
- CHECK_SHOW(show("<tr><td>Response received time</td><td>%s</td></tr>\n", tmpstr));
- CHECK_SHOW(show("</TABLE></P>"));
- }
-
- cache_vc->do_io_close(-1);
- return complete(event, e);
- }
- // open success but no vector, that is the Cluster open read, pass through
- }
- case VC_EVENT_READ_READY:
- if (!cvio) {
- buffer = new_empty_MIOBuffer();
- buffer_reader = buffer->alloc_reader();
- content_length = cache_vc->get_object_size();
- cvio = cache_vc->do_io_read(this, content_length, buffer);
- } else
- buffer_reader->consume(buffer_reader->read_avail());
- return EVENT_DONE;
- case CACHE_EVENT_OPEN_READ_FAILED:
- // something strange happen, or cache miss in cluster mode.
- CHECK_SHOW(show("<H3>Cache Lookup Failed, or missing in cluster</H3>\n"));
- return complete(event, e);
- default:
- CHECK_SHOW(show("<H3>Cache Miss</H3>\n"));
- return complete(event, e);
+ // open success but no vector, that is the Cluster open read, pass through
+ }
+ case VC_EVENT_READ_READY:
+ if (!cvio) {
+ buffer = new_empty_MIOBuffer();
+ buffer_reader = buffer->alloc_reader();
+ content_length = cache_vc->get_object_size();
+ cvio = cache_vc->do_io_read(this, content_length, buffer);
+ } else
+ buffer_reader->consume(buffer_reader->read_avail());
+ return EVENT_DONE;
+ case CACHE_EVENT_OPEN_READ_FAILED:
+ // something strange happen, or cache miss in cluster mode.
+ CHECK_SHOW(show("<H3>Cache Lookup Failed, or missing in cluster</H3>\n"));
+ return complete(event, e);
+ default:
+ CHECK_SHOW(show("<H3>Cache Miss</H3>\n"));
+ return complete(event, e);
}
}
int
-ShowCache::lookup_url(int event, Event *e) {
+ShowCache::lookup_url(int event, Event *e)
+{
char header_str[300];
snprintf(header_str, sizeof(header_str), "<font color=red>%s</font>", show_cache_urlstrs[0]);
@@ -421,16 +443,17 @@ ShowCache::lookup_url(int event, Event *e) {
url.hash_get(&md5);
const char *hostname = url.host_get(&len);
SET_HANDLER(&ShowCache::handleCacheEvent);
- Action *lookup_result = cacheProcessor.open_read(this, &md5, getClusterCacheLocal(&url, (char *)hostname), CACHE_FRAG_TYPE_HTTP, (char *) hostname, len);
+ Action *lookup_result =
+ cacheProcessor.open_read(this, &md5, getClusterCacheLocal(&url, (char *)hostname), CACHE_FRAG_TYPE_HTTP, (char *)hostname, len);
if (!lookup_result)
lookup_result = ACTION_IO_ERROR;
if (lookup_result == ACTION_RESULT_DONE)
- return EVENT_DONE; // callback complete
+ return EVENT_DONE; // callback complete
else if (lookup_result == ACTION_IO_ERROR) {
handleEvent(CACHE_EVENT_OPEN_READ_FAILED, 0);
- return EVENT_DONE; // callback complete
+ return EVENT_DONE; // callback complete
} else
- return EVENT_CONT; // callback pending, will be a cluster read.
+ return EVENT_CONT; // callback pending, will be a cluster read.
}
@@ -468,14 +491,12 @@ ShowCache::delete_url(int event, Event *e)
int
ShowCache::handleCacheDeleteComplete(int event, Event *e)
{
-
if (event == CACHE_EVENT_REMOVE) {
CHECK_SHOW(show("<td>Delete <font color=green>succeeded</font></td></tr>\n"));
} else {
CHECK_SHOW(show("<td>Delete <font color=red>failed</font></td></tr>\n"));
}
return delete_url(event, e);
-
}
@@ -511,12 +532,16 @@ ShowCache::lookup_regex(int event, Event *e)
" return true;\n"
"}\n"
" srcfile=\"./delete_url?url=\" + form.elements[0].value;\n"
- " document.location=srcfile;\n " " return true;\n" "}\n" "</SCRIPT>\n"));
+ " document.location=srcfile;\n "
+ " return true;\n"
+ "}\n"
+ "</SCRIPT>\n"));
CHECK_SHOW(show("<FORM NAME=\"f\" ACTION=\"./delete_url\" METHOD=GET> \n"
- "<INPUT TYPE=HIDDEN NAME=\"url\">\n" "<B><TABLE border=1>\n"));
+ "<INPUT TYPE=HIDDEN NAME=\"url\">\n"
+ "<B><TABLE border=1>\n"));
- scan_flag = scan_type_lookup; //lookup
+ scan_flag = scan_type_lookup; // lookup
SET_HANDLER(&ShowCache::handleCacheScanCallback);
cacheProcessor.scan(this);
return EVENT_DONE;
@@ -527,11 +552,10 @@ ShowCache::delete_regex(int event, Event *e)
{
CHECK_SHOW(begin("Regex Delete"));
CHECK_SHOW(show("<B><TABLE border=1>\n"));
- scan_flag = scan_type_delete; // delete
+ scan_flag = scan_type_delete; // delete
SET_HANDLER(&ShowCache::handleCacheScanCallback);
cacheProcessor.scan(this);
return EVENT_DONE;
-
}
@@ -540,93 +564,98 @@ ShowCache::invalidate_regex(int event, Event *e)
{
CHECK_SHOW(begin("Regex Invalidate"));
CHECK_SHOW(show("<B><TABLE border=1>\n"));
- scan_flag = scan_type_invalidate; // invalidate
+ scan_flag = scan_type_invalidate; // invalidate
SET_HANDLER(&ShowCache::handleCacheScanCallback);
cacheProcessor.scan(this);
return EVENT_DONE;
-
}
-
int
ShowCache::handleCacheScanCallback(int event, Event *e)
{
switch (event) {
- case CACHE_EVENT_SCAN:{
- cache_vc = (CacheVC *) e;
- return EVENT_CONT;
- }
- case CACHE_EVENT_SCAN_OBJECT:{
- HTTPInfo *alt = (HTTPInfo *) e;
- char xx[501], m[501];
- int ib = 0, xd = 0, ml = 0;
-
- alt->request_get()->url_print(xx, 500, &ib, &xd);
- xx[ib] = '\0';
-
- const char *mm = alt->request_get()->method_get(&ml);
-
- memcpy(m, mm, ml);
- m[ml] = 0;
-
- int res = CACHE_SCAN_RESULT_CONTINUE;
-
- for (unsigned s = 0; show_cache_urlstrs[s][0] != '\0'; s++) {
- const char* error;
- int erroffset;
- pcre* preq = pcre_compile(show_cache_urlstrs[s], 0, &error, &erroffset, NULL);
-
- Debug("cache_inspector", "matching url '%s' '%s' with regex '%s'\n", m, xx, show_cache_urlstrs[s]);
-
- if (preq) {
- int r = pcre_exec(preq, NULL, xx, ib, 0, 0, NULL, 0);
-
- pcre_free(preq);
- if (r != -1) {
- linecount++;
- if ((linecount % 5) == 0) {
- CHECK_SHOW(show("<TR bgcolor=\"#FFF0E0\">"));
- } else {
- CHECK_SHOW(show("<TR>"));
- }
-
- switch (scan_flag) {
- case scan_type_lookup:
- /*Y! Bug: 2249781: using onClick() because i need encodeURIComponent() and YTS doesn't have something like that */
- CHECK_SHOW(show("<TD><INPUT TYPE=CHECKBOX NAME=\"%s\" "
- "onClick=\"addToUrlList(this)\"></TD>"
- "<TD><A onClick='window.location.href=\"./lookup_url?url=\"+ encodeURIComponent(\"%s\");' HREF=\"#\">"
- "<B>%s</B></A></br></TD></TR>\n", xx, xx, xx));
- break;
- case scan_type_delete:
- CHECK_SHOW(show("<TD><B>%s</B></TD>" "<TD><font color=red>deleted</font></TD></TR>\n", xx));
- res = CACHE_SCAN_RESULT_DELETE;
- break;
- case scan_type_invalidate:
- HTTPInfo new_info;
- res = CACHE_SCAN_RESULT_UPDATE;
- new_info.copy(alt);
- new_info.response_get()->set_cooked_cc_need_revalidate_once();
- CHECK_SHOW(show("<TD><B>%s</B></TD>" "<TD><font color=red>Invalidate</font></TD>" "</TR>\n", xx));
- cache_vc->set_http_info(&new_info);
- }
+ case CACHE_EVENT_SCAN: {
+ cache_vc = (CacheVC *)e;
+ return EVENT_CONT;
+ }
+ case CACHE_EVENT_SCAN_OBJECT: {
+ HTTPInfo *alt = (HTTPInfo *)e;
+ char xx[501], m[501];
+ int ib = 0, xd = 0, ml = 0;
+ alt->request_get()->url_print(xx, 500, &ib, &xd);
+ xx[ib] = '\0';
+
+ const char *mm = alt->request_get()->method_get(&ml);
+
+ memcpy(m, mm, ml);
+ m[ml] = 0;
+
+ int res = CACHE_SCAN_RESULT_CONTINUE;
+
+ for (unsigned s = 0; show_cache_urlstrs[s][0] != '\0'; s++) {
+ const char *error;
+ int erroffset;
+ pcre *preq = pcre_compile(show_cache_urlstrs[s], 0, &error, &erroffset, NULL);
+
+ Debug("cache_inspector", "matching url '%s' '%s' with regex '%s'\n", m, xx, show_cache_urlstrs[s]);
+
+ if (preq) {
+ int r = pcre_exec(preq, NULL, xx, ib, 0, 0, NULL, 0);
+
+ pcre_free(preq);
+ if (r != -1) {
+ linecount++;
+ if ((linecount % 5) == 0) {
+ CHECK_SHOW(show("<TR bgcolor=\"#FFF0E0\">"));
+ } else {
+ CHECK_SHOW(show("<TR>"));
+ }
+
+ switch (scan_flag) {
+ case scan_type_lookup:
+ /*Y! Bug: 2249781: using onClick() because i need encodeURIComponent() and YTS doesn't have something like that */
+ CHECK_SHOW(show("<TD><INPUT TYPE=CHECKBOX NAME=\"%s\" "
+ "onClick=\"addToUrlList(this)\"></TD>"
+ "<TD><A onClick='window.location.href=\"./lookup_url?url=\"+ encodeURIComponent(\"%s\");' HREF=\"#\">"
+ "<B>%s</B></A></br></TD></TR>\n",
+ xx, xx, xx));
+ break;
+ case scan_type_delete:
+ CHECK_SHOW(show("<TD><B>%s</B></TD>"
+ "<TD><font color=red>deleted</font></TD></TR>\n",
+ xx));
+ res = CACHE_SCAN_RESULT_DELETE;
break;
+ case scan_type_invalidate:
+ HTTPInfo new_info;
+ res = CACHE_SCAN_RESULT_UPDATE;
+ new_info.copy(alt);
+ new_info.response_get()->set_cooked_cc_need_revalidate_once();
+ CHECK_SHOW(show("<TD><B>%s</B></TD>"
+ "<TD><font color=red>Invalidate</font></TD>"
+ "</TR>\n",
+ xx));
+ cache_vc->set_http_info(&new_info);
}
- } else {
- // TODO: Regex didn't compile, show errors ?
- Debug("cache_inspector", "regex '%s' didn't compile", show_cache_urlstrs[s]);
+
+ break;
}
+ } else {
+ // TODO: Regex didn't compile, show errors ?
+ Debug("cache_inspector", "regex '%s' didn't compile", show_cache_urlstrs[s]);
}
- return res;
}
+ return res;
+ }
case CACHE_EVENT_SCAN_DONE:
CHECK_SHOW(show("</TABLE></B>\n"));
if (scan_flag == 0)
if (linecount) {
CHECK_SHOW(show("<P><INPUT TYPE=button value=\"Delete\" "
- "onClick=\"setUrls(window.document.f)\"></P>" "</FORM>\n"));
+ "onClick=\"setUrls(window.document.f)\"></P>"
+ "</FORM>\n"));
}
CHECK_SHOW(show("<H3>Done</H3>\n"));
Debug("cache_inspector", "scan done");
@@ -638,4 +667,3 @@ ShowCache::handleCacheScanCallback(int event, Event *e)
return EVENT_DONE;
}
}
-
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/iocore/cache/CachePagesInternal.cc
----------------------------------------------------------------------
diff --git a/iocore/cache/CachePagesInternal.cc b/iocore/cache/CachePagesInternal.cc
index 0d7b191..080decc 100644
--- a/iocore/cache/CachePagesInternal.cc
+++ b/iocore/cache/CachePagesInternal.cc
@@ -26,40 +26,34 @@
#include "Show.h"
#include "I_Tasks.h"
-struct ShowCacheInternal: public ShowCont
-{
+struct ShowCacheInternal : public ShowCont {
int vol_index;
int seg_index;
CacheKey show_cache_key;
CacheVC *cache_vc;
- int showMain(int event, Event * e);
- int showEvacuations(int event, Event * e);
- int showVolEvacuations(int event, Event * e);
- int showVolumes(int event, Event * e);
- int showVolVolumes(int event, Event * e);
- int showSegments(int event, Event * e);
- int showSegSegment(int event, Event * e);
+ int showMain(int event, Event *e);
+ int showEvacuations(int event, Event *e);
+ int showVolEvacuations(int event, Event *e);
+ int showVolumes(int event, Event *e);
+ int showVolVolumes(int event, Event *e);
+ int showSegments(int event, Event *e);
+ int showSegSegment(int event, Event *e);
#ifdef CACHE_STAT_PAGES
- int showConnections(int event, Event * e);
- int showVolConnections(int event, Event * e);
+ int showConnections(int event, Event *e);
+ int showVolConnections(int event, Event *e);
#endif
- ShowCacheInternal(Continuation * c, HTTPHdr * h)
- : ShowCont(c, h), vol_index(0), seg_index(0)
+ ShowCacheInternal(Continuation *c, HTTPHdr *h) : ShowCont(c, h), vol_index(0), seg_index(0)
{
SET_HANDLER(&ShowCacheInternal::showMain);
}
- ~ShowCacheInternal() {
- }
-
+ ~ShowCacheInternal() {}
};
extern ShowCacheInternal *theshowcacheInternal;
-Action *register_ShowCacheInternal(Continuation * c, HTTPHdr * h);
-
-
+Action *register_ShowCacheInternal(Continuation *c, HTTPHdr *h);
extern Vol **gvol;
@@ -70,12 +64,12 @@ extern volatile int gnvol;
ShowCacheInternal *theshowcacheInternal = NULL;
-#define STREQ_PREFIX(_x,_s) (!strncasecmp(_x,_s,sizeof(_s)-1))
-#define STREQ_LEN_PREFIX(_x,_l,_s) (path_len < sizeof(_s) && !strncasecmp(_x,_s,sizeof(_s)-1))
+#define STREQ_PREFIX(_x, _s) (!strncasecmp(_x, _s, sizeof(_s) - 1))
+#define STREQ_LEN_PREFIX(_x, _l, _s) (path_len < sizeof(_s) && !strncasecmp(_x, _s, sizeof(_s) - 1))
Action *
-register_ShowCacheInternal(Continuation * c, HTTPHdr * h)
+register_ShowCacheInternal(Continuation *c, HTTPHdr *h)
{
theshowcacheInternal = new ShowCacheInternal(c, h);
URL *u = h->url_get();
@@ -105,7 +99,7 @@ register_ShowCacheInternal(Continuation * c, HTTPHdr * h)
int
-ShowCacheInternal::showMain(int event, Event * e)
+ShowCacheInternal::showMain(int event, Event *e)
{
CHECK_SHOW(begin("Cache"));
#ifdef CACHE_STAT_PAGES
@@ -121,14 +115,18 @@ ShowCacheInternal::showMain(int event, Event * e)
#ifdef CACHE_STAT_PAGES
int
-ShowCacheInternal::showConnections(int event, Event * e)
+ShowCacheInternal::showConnections(int event, Event *e)
{
CHECK_SHOW(begin("Cache VConnections"));
CHECK_SHOW(show("<H3>Cache Connections</H3>\n"
"<table border=1><tr>"
"<th>Operation</th>"
"<th>Volume</th>"
- "<th>URL/Hash</th>" "<th>Bytes Done</th>" "<th>Total Bytes</th>" "<th>Bytes Todo</th>" "</tr>\n"));
+ "<th>URL/Hash</th>"
+ "<th>Bytes Done</th>"
+ "<th>Total Bytes</th>"
+ "<th>Bytes Todo</th>"
+ "</tr>\n"));
SET_HANDLER(&ShowCacheInternal::showVolConnections);
CONT_SCHED_LOCK_RETRY_RET(this);
@@ -136,14 +134,13 @@ ShowCacheInternal::showConnections(int event, Event * e)
int
-ShowCacheInternal::showVolConnections(int event, Event * e)
+ShowCacheInternal::showVolConnections(int event, Event *e)
{
CACHE_TRY_LOCK(lock, gvol[vol_index]->mutex, mutex->thread_holding);
if (!lock) {
CONT_SCHED_LOCK_RETRY_RET(this);
}
- for (CacheVC * vc = (CacheVC *) gvol[vol_index]->stat_cache_vcs.head; vc; vc = vc->stat_link.next) {
-
+ for (CacheVC *vc = (CacheVC *)gvol[vol_index]->stat_cache_vcs.head; vc; vc = vc->stat_link.next) {
char nbytes[60], todo[60], url[81092];
int ib = 0, xd = 0;
URL uu;
@@ -165,17 +162,15 @@ ShowCacheInternal::showVolConnections(int event, Event * e)
url[ib] = 0;
} else
vc->key.string(url);
- CHECK_SHOW(show("<tr>" "<td>%s</td>" // operation
- "<td>%s</td>" // Vol
- "<td>%s</td>" // URL/Hash
+ CHECK_SHOW(show("<tr>"
+ "<td>%s</td>" // operation
+ "<td>%s</td>" // Vol
+ "<td>%s</td>" // URL/Hash
"<td>%d</td>"
"<td>%s</td>"
"<td>%s</td>"
"</tr>\n",
- ((vc->vio.op == VIO::READ) ? "Read" : "Write"),
- vc->vol->hash_id,
- url,
- vc->vio.ndone,
+ ((vc->vio.op == VIO::READ) ? "Read" : "Write"), vc->vol->hash_id, url, vc->vio.ndone,
vc->vio.nbytes == INT64_MAX ? "all" : nbytes, vc->vio.nbytes == INT64_MAX ? "all" : todo));
}
vol_index++;
@@ -192,12 +187,16 @@ ShowCacheInternal::showVolConnections(int event, Event * e)
int
-ShowCacheInternal::showEvacuations(int event, Event * e)
+ShowCacheInternal::showEvacuations(int event, Event *e)
{
CHECK_SHOW(begin("Cache Pending Evacuations"));
CHECK_SHOW(show("<H3>Cache Evacuations</H3>\n"
"<table border=1><tr>"
- "<th>Offset</th>" "<th>Estimated Size</th>" "<th>Reader Count</th>" "<th>Done</th>" "</tr>\n"));
+ "<th>Offset</th>"
+ "<th>Estimated Size</th>"
+ "<th>Reader Count</th>"
+ "<th>Done</th>"
+ "</tr>\n"));
SET_HANDLER(&ShowCacheInternal::showVolEvacuations);
CONT_SCHED_LOCK_RETRY_RET(this);
@@ -205,7 +204,7 @@ ShowCacheInternal::showEvacuations(int event, Event * e)
int
-ShowCacheInternal::showVolEvacuations(int event, Event * e)
+ShowCacheInternal::showVolEvacuations(int event, Event *e)
{
Vol *p = gvol[vol_index];
CACHE_TRY_LOCK(lock, p->mutex, mutex->thread_holding);
@@ -217,12 +216,14 @@ ShowCacheInternal::showVolEvacuations(int event, Event * e)
for (int i = 0; i < last; i++) {
for (b = p->evacuate[i].head; b; b = b->link.next) {
char offset[60];
- sprintf(offset, "%" PRIu64 "", (uint64_t) vol_offset(p, &b->dir));
- CHECK_SHOW(show("<tr>" "<td>%s</td>" // offset
- "<td>%d</td>" // estimated size
- "<td>%d</td>" // reader count
- "<td>%s</td>" // done
- "</tr>\n", offset, (int) dir_approx_size(&b->dir), b->readers, b->f.done ? "yes" : "no"));
+ sprintf(offset, "%" PRIu64 "", (uint64_t)vol_offset(p, &b->dir));
+ CHECK_SHOW(show("<tr>"
+ "<td>%s</td>" // offset
+ "<td>%d</td>" // estimated size
+ "<td>%d</td>" // reader count
+ "<td>%s</td>" // done
+ "</tr>\n",
+ offset, (int)dir_approx_size(&b->dir), b->readers, b->f.done ? "yes" : "no"));
}
}
vol_index++;
@@ -236,7 +237,7 @@ ShowCacheInternal::showVolEvacuations(int event, Event * e)
}
int
-ShowCacheInternal::showVolumes(int event, Event * e)
+ShowCacheInternal::showVolumes(int event, Event *e)
{
CHECK_SHOW(begin("Cache Volumes"));
CHECK_SHOW(show("<H3>Cache Volumes</H3>\n"
@@ -248,7 +249,11 @@ ShowCacheInternal::showVolumes(int event, Event * e)
"<th>Write Agg Todo</th>"
"<th>Write Agg Todo Size</th>"
"<th>Write Agg Done</th>"
- "<th>Phase</th>" "<th>Create Time</th>" "<th>Sync Serial</th>" "<th>Write Serial</th>" "</tr>\n"));
+ "<th>Phase</th>"
+ "<th>Create Time</th>"
+ "<th>Sync Serial</th>"
+ "<th>Write Serial</th>"
+ "</tr>\n"));
SET_HANDLER(&ShowCacheInternal::showVolVolumes);
CONT_SCHED_LOCK_RETRY_RET(this);
@@ -256,7 +261,7 @@ ShowCacheInternal::showVolumes(int event, Event * e)
int
-ShowCacheInternal::showVolVolumes(int event, Event * e)
+ShowCacheInternal::showVolVolumes(int event, Event *e)
{
Vol *p = gvol[vol_index];
CACHE_TRY_LOCK(lock, p->mutex, mutex->thread_holding);
@@ -269,40 +274,42 @@ ShowCacheInternal::showVolVolumes(int event, Event * e)
int agg_todo = 0;
int agg_done = p->agg_buf_pos;
CacheVC *c = 0;
- for (c = p->agg.head; c; c = (CacheVC *) c->link.next)
+ for (c = p->agg.head; c; c = (CacheVC *)c->link.next)
agg_todo++;
- CHECK_SHOW(show("<tr>" "<td>%s</td>" // ID
+ CHECK_SHOW(show("<tr>"
+ "<td>%s</td>" // ID
"<td>%" PRId64 "</td>" // blocks
"<td>%" PRId64 "</td>" // directory entries
"<td>%" PRId64 "</td>" // write position
- "<td>%d</td>" // write agg to do
- "<td>%d</td>" // write agg to do size
- "<td>%d</td>" // write agg done
- "<td>%d</td>" // phase
- "<td>%s</td>" // create time
- "<td>%u</td>" // sync serial
- "<td>%u</td>" // write serial
+ "<td>%d</td>" // write agg to do
+ "<td>%d</td>" // write agg to do size
+ "<td>%d</td>" // write agg done
+ "<td>%d</td>" // phase
+ "<td>%s</td>" // create time
+ "<td>%u</td>" // sync serial
+ "<td>%u</td>" // write serial
"</tr>\n",
- p->hash_text.get(),
- (uint64_t)((p->len - (p->start - p->skip)) / CACHE_BLOCK_SIZE),
+ p->hash_text.get(), (uint64_t)((p->len - (p->start - p->skip)) / CACHE_BLOCK_SIZE),
(uint64_t)(p->buckets * DIR_DEPTH * p->segments),
- (uint64_t)((p->header->write_pos - p->start) / CACHE_BLOCK_SIZE),
- agg_todo,
- p->agg_todo_size,
- agg_done, p->header->phase, ctime, p->header->sync_serial, p->header->write_serial));
+ (uint64_t)((p->header->write_pos - p->start) / CACHE_BLOCK_SIZE), agg_todo, p->agg_todo_size, agg_done,
+ p->header->phase, ctime, p->header->sync_serial, p->header->write_serial));
CHECK_SHOW(show("</table>\n"));
SET_HANDLER(&ShowCacheInternal::showSegments);
return showSegments(event, e);
}
int
-ShowCacheInternal::showSegments(int event, Event * e)
+ShowCacheInternal::showSegments(int event, Event *e)
{
CHECK_SHOW(show("<H3>Cache Volume Segments</H3>\n"
"<table border=1><tr>"
"<th>Free</th>"
"<th>Used</th>"
- "<th>Empty</th>" "<th>Valid</th>" "<th>Agg Valid</th>" "<th>Avg Size</th>" "</tr>\n"));
+ "<th>Empty</th>"
+ "<th>Valid</th>"
+ "<th>Agg Valid</th>"
+ "<th>Avg Size</th>"
+ "</tr>\n"));
SET_HANDLER(&ShowCacheInternal::showSegSegment);
seg_index = 0;
@@ -310,7 +317,7 @@ ShowCacheInternal::showSegments(int event, Event * e)
}
int
-ShowCacheInternal::showSegSegment(int event, Event * e)
+ShowCacheInternal::showSegSegment(int event, Event *e)
{
Vol *p = gvol[vol_index];
CACHE_TRY_LOCK(lock, p->mutex, mutex->thread_holding);
@@ -322,7 +329,11 @@ ShowCacheInternal::showSegSegment(int event, Event * e)
"<td>%d</td>"
"<td>%d</td>"
"<td>%d</td>"
- "<td>%d</td>" "<td>%d</td>" "<td>%d</td>" "</tr>\n", free, used, empty, valid, agg_valid, avg_size));
+ "<td>%d</td>"
+ "<td>%d</td>"
+ "<td>%d</td>"
+ "</tr>\n",
+ free, used, empty, valid, agg_valid, avg_size));
seg_index++;
if (seg_index < p->segments)
CONT_SCHED_LOCK_RETRY(this);
@@ -337,4 +348,3 @@ ShowCacheInternal::showSegSegment(int event, Event * e)
}
return EVENT_CONT;
}
-
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/iocore/cache/CacheRead.cc
----------------------------------------------------------------------
diff --git a/iocore/cache/CacheRead.cc b/iocore/cache/CacheRead.cc
index a20737e..4ba02f4 100644
--- a/iocore/cache/CacheRead.cc
+++ b/iocore/cache/CacheRead.cc
@@ -24,17 +24,17 @@
#include "P_Cache.h"
#ifdef HTTP_CACHE
-#include "HttpCacheSM.h" //Added to get the scope of HttpCacheSM object.
+#include "HttpCacheSM.h" //Added to get the scope of HttpCacheSM object.
#endif
#define READ_WHILE_WRITER 1
extern int cache_config_compatibility_4_2_0_fixup;
Action *
-Cache::open_read(Continuation * cont, CacheKey * key, CacheFragType type, char *hostname, int host_len)
+Cache::open_read(Continuation *cont, CacheKey *key, CacheFragType type, char *hostname, int host_len)
{
if (!CacheProcessor::IsCacheReady(type)) {
- cont->handleEvent(CACHE_EVENT_OPEN_READ_FAILED, (void *) -ECACHE_NOT_READY);
+ cont->handleEvent(CACHE_EVENT_OPEN_READ_FAILED, (void *)-ECACHE_NOT_READY);
return ACTION_RESULT_DONE;
}
ink_assert(caches[type] == this);
@@ -67,15 +67,18 @@ Cache::open_read(Continuation * cont, CacheKey * key, CacheFragType type, char *
goto Lwriter;
c->dir = result;
c->last_collision = last_collision;
- switch(c->do_read_call(&c->key)) {
- case EVENT_DONE: return ACTION_RESULT_DONE;
- case EVENT_RETURN: goto Lcallreturn;
- default: return &c->_action;
+ switch (c->do_read_call(&c->key)) {
+ case EVENT_DONE:
+ return ACTION_RESULT_DONE;
+ case EVENT_RETURN:
+ goto Lcallreturn;
+ default:
+ return &c->_action;
}
}
Lmiss:
CACHE_INCREMENT_DYN_STAT(cache_read_failure_stat);
- cont->handleEvent(CACHE_EVENT_OPEN_READ_FAILED, (void *) -ECACHE_NO_DOC);
+ cont->handleEvent(CACHE_EVENT_OPEN_READ_FAILED, (void *)-ECACHE_NO_DOC);
return ACTION_RESULT_DONE;
Lwriter:
SET_CONTINUATION_HANDLER(c, &CacheVC::openReadFromWriter);
@@ -90,12 +93,11 @@ Lcallreturn:
#ifdef HTTP_CACHE
Action *
-Cache::open_read(Continuation * cont, CacheKey * key, CacheHTTPHdr * request,
- CacheLookupHttpConfig * params, CacheFragType type, char *hostname, int host_len)
+Cache::open_read(Continuation *cont, CacheKey *key, CacheHTTPHdr *request, CacheLookupHttpConfig *params, CacheFragType type,
+ char *hostname, int host_len)
{
-
if (!CacheProcessor::IsCacheReady(type)) {
- cont->handleEvent(CACHE_EVENT_OPEN_READ_FAILED, (void *) -ECACHE_NOT_READY);
+ cont->handleEvent(CACHE_EVENT_OPEN_READ_FAILED, (void *)-ECACHE_NOT_READY);
return ACTION_RESULT_DONE;
}
ink_assert(caches[type] == this);
@@ -133,15 +135,18 @@ Cache::open_read(Continuation * cont, CacheKey * key, CacheHTTPHdr * request,
c->dir = c->first_dir = result;
c->last_collision = last_collision;
SET_CONTINUATION_HANDLER(c, &CacheVC::openReadStartHead);
- switch(c->do_read_call(&c->key)) {
- case EVENT_DONE: return ACTION_RESULT_DONE;
- case EVENT_RETURN: goto Lcallreturn;
- default: return &c->_action;
+ switch (c->do_read_call(&c->key)) {
+ case EVENT_DONE:
+ return ACTION_RESULT_DONE;
+ case EVENT_RETURN:
+ goto Lcallreturn;
+ default:
+ return &c->_action;
}
}
Lmiss:
CACHE_INCREMENT_DYN_STAT(cache_read_failure_stat);
- cont->handleEvent(CACHE_EVENT_OPEN_READ_FAILED, (void *) -ECACHE_NO_DOC);
+ cont->handleEvent(CACHE_EVENT_OPEN_READ_FAILED, (void *)-ECACHE_NO_DOC);
return ACTION_RESULT_DONE;
Lwriter:
// this is a horrible violation of the interface and should be fixed (FIXME)
@@ -158,14 +163,13 @@ Lcallreturn:
#endif
uint32_t
-CacheVC::load_http_info(CacheHTTPInfoVector* info, Doc* doc, RefCountObj * block_ptr)
+CacheVC::load_http_info(CacheHTTPInfoVector *info, Doc *doc, RefCountObj *block_ptr)
{
uint32_t zret = info->get_handles(doc->hdr(), doc->hlen, block_ptr);
if (cache_config_compatibility_4_2_0_fixup && // manual override not engaged
- ! this->f.doc_from_ram_cache && // it's already been done for ram cache fragments
- vol->header->version.ink_major == 23 && vol->header->version.ink_minor == 0
- ) {
- for ( int i = info->xcount - 1 ; i >= 0 ; --i ) {
+ !this->f.doc_from_ram_cache && // it's already been done for ram cache fragments
+ vol->header->version.ink_major == 23 && vol->header->version.ink_minor == 0) {
+ for (int i = info->xcount - 1; i >= 0; --i) {
info->data(i).alternate.m_alt->m_response_hdr.m_mime->recompute_accelerators_and_presence_bits();
info->data(i).alternate.m_alt->m_request_hdr.m_mime->recompute_accelerators_and_presence_bits();
}
@@ -174,9 +178,8 @@ CacheVC::load_http_info(CacheHTTPInfoVector* info, Doc* doc, RefCountObj * block
}
int
-CacheVC::openReadFromWriterFailure(int event, Event * e)
+CacheVC::openReadFromWriterFailure(int event, Event *e)
{
-
od = NULL;
vector.clear(false);
CACHE_INCREMENT_DYN_STAT(cache_read_failure_stat);
@@ -216,7 +219,7 @@ CacheVC::openReadChooseWriter(int /* event ATS_UNUSED */, Event * /* e ATS_UNUSE
vector.insert(write_vector->get(c));
// check if all the writers who came before this reader have
// set the http_info.
- for (w = (CacheVC *) od->writers.head; w; w = (CacheVC *) w->opendir_link.next) {
+ for (w = (CacheVC *)od->writers.head; w; w = (CacheVC *)w->opendir_link.next) {
if (w->start_time > start_time || w->closed < 0)
continue;
if (!w->closed && !cache_config_read_while_writer) {
@@ -250,7 +253,7 @@ CacheVC::openReadChooseWriter(int /* event ATS_UNUSED */, Event * /* e ATS_UNUSE
if (!vector.count()) {
if (od->reading_vec) {
- // the writer(s) are reading the vector, so there is probably
+ // the writer(s) are reading the vector, so there is probably
// an old vector. Since this reader came before any of the
// current writers, we should return the old data
od = NULL;
@@ -265,7 +268,7 @@ CacheVC::openReadChooseWriter(int /* event ATS_UNUSED */, Event * /* e ATS_UNUSE
} else
alternate_index = 0;
CacheHTTPInfo *obj = vector.get(alternate_index);
- for (w = (CacheVC *) od->writers.head; w; w = (CacheVC *) w->opendir_link.next) {
+ for (w = (CacheVC *)od->writers.head; w; w = (CacheVC *)w->opendir_link.next) {
if (obj->m_alt == w->alternate.m_alt) {
write_vc = w;
break;
@@ -278,17 +281,15 @@ CacheVC::openReadChooseWriter(int /* event ATS_UNUSED */, Event * /* e ATS_UNUSE
return EVENT_RETURN;
}
- DDebug("cache_read_agg",
- "%p: key: %X eKey: %d # alts: %d, ndx: %d, # writers: %d writer: %p",
- this, first_key.slice32(1), write_vc->earliest_key.slice32(1),
- vector.count(), alternate_index, od->num_writers, write_vc);
+ DDebug("cache_read_agg", "%p: key: %X eKey: %d # alts: %d, ndx: %d, # writers: %d writer: %p", this, first_key.slice32(1),
+ write_vc->earliest_key.slice32(1), vector.count(), alternate_index, od->num_writers, write_vc);
}
-#endif //HTTP_CACHE
+#endif // HTTP_CACHE
return EVENT_NONE;
}
int
-CacheVC::openReadFromWriter(int event, Event * e)
+CacheVC::openReadFromWriter(int event, Event *e)
{
if (!f.read_from_writer_called) {
// The assignment to last_collision as NULL was
@@ -306,7 +307,7 @@ CacheVC::openReadFromWriter(int event, Event * e)
intptr_t err = ECACHE_DOC_BUSY;
DDebug("cache_read_agg", "%p: key: %X In openReadFromWriter", this, first_key.slice32(1));
#ifndef READ_WHILE_WRITER
- return openReadFromWriterFailure(CACHE_EVENT_OPEN_READ_FAILED, (Event *) -err);
+ return openReadFromWriterFailure(CACHE_EVENT_OPEN_READ_FAILED, (Event *)-err);
#else
if (_action.cancelled) {
od = NULL; // only open for read so no need to close
@@ -328,7 +329,7 @@ CacheVC::openReadFromWriter(int event, Event * e)
if (ret < 0) {
MUTEX_RELEASE(lock);
SET_HANDLER(&CacheVC::openReadFromWriterFailure);
- return openReadFromWriterFailure(CACHE_EVENT_OPEN_READ_FAILED, reinterpret_cast<Event *> (ret));
+ return openReadFromWriterFailure(CACHE_EVENT_OPEN_READ_FAILED, reinterpret_cast<Event *>(ret));
} else if (ret == EVENT_RETURN) {
MUTEX_RELEASE(lock);
SET_HANDLER(&CacheVC::openReadStartHead);
@@ -341,8 +342,7 @@ CacheVC::openReadFromWriter(int event, Event * e)
} else {
if (writer_done()) {
MUTEX_RELEASE(lock);
- DDebug("cache_read_agg",
- "%p: key: %X writer %p has left, continuing as normal read", this, first_key.slice32(1), write_vc);
+ DDebug("cache_read_agg", "%p: key: %X writer %p has left, continuing as normal read", this, first_key.slice32(1), write_vc);
od = NULL;
write_vc = NULL;
SET_HANDLER(&CacheVC::openReadStartHead);
@@ -357,7 +357,7 @@ CacheVC::openReadFromWriter(int event, Event * e)
if (write_vc->closed < 0) {
MUTEX_RELEASE(lock);
write_vc = NULL;
- //writer aborted, continue as if there is no writer
+ // writer aborted, continue as if there is no writer
SET_HANDLER(&CacheVC::openReadStartHead);
return openReadStartHead(EVENT_IMMEDIATE, 0);
}
@@ -366,11 +366,10 @@ CacheVC::openReadFromWriter(int event, Event * e)
if (!write_vc->closed && !write_vc->fragment) {
if (!cache_config_read_while_writer || frag_type != CACHE_FRAG_TYPE_HTTP) {
MUTEX_RELEASE(lock);
- return openReadFromWriterFailure(CACHE_EVENT_OPEN_READ_FAILED, (Event *) - err);
+ return openReadFromWriterFailure(CACHE_EVENT_OPEN_READ_FAILED, (Event *)-err);
}
- DDebug("cache_read_agg",
- "%p: key: %X writer: closed:%d, fragment:%d, retry: %d",
- this, first_key.slice32(1), write_vc->closed, write_vc->fragment, writer_lock_retry);
+ DDebug("cache_read_agg", "%p: key: %X writer: closed:%d, fragment:%d, retry: %d", this, first_key.slice32(1), write_vc->closed,
+ write_vc->fragment, writer_lock_retry);
VC_SCHED_WRITER_RETRY();
}
@@ -382,14 +381,13 @@ CacheVC::openReadFromWriter(int event, Event * e)
MUTEX_RELEASE(lock);
if (!write_vc->io.ok())
- return openReadFromWriterFailure(CACHE_EVENT_OPEN_READ_FAILED, (Event *) - err);
+ return openReadFromWriterFailure(CACHE_EVENT_OPEN_READ_FAILED, (Event *)-err);
#ifdef HTTP_CACHE
if (frag_type == CACHE_FRAG_TYPE_HTTP) {
- DDebug("cache_read_agg",
- "%p: key: %X http passed stage 1, closed: %d, frag: %d",
- this, first_key.slice32(1), write_vc->closed, write_vc->fragment);
+ DDebug("cache_read_agg", "%p: key: %X http passed stage 1, closed: %d, frag: %d", this, first_key.slice32(1), write_vc->closed,
+ write_vc->fragment);
if (!write_vc->alternate.valid())
- return openReadFromWriterFailure(CACHE_EVENT_OPEN_READ_FAILED, (Event *) - err);
+ return openReadFromWriterFailure(CACHE_EVENT_OPEN_READ_FAILED, (Event *)-err);
alternate.copy(&write_vc->alternate);
vector.insert(&alternate);
alternate.object_key_get(&key);
@@ -406,12 +404,12 @@ CacheVC::openReadFromWriter(int event, Event * e)
DDebug("cache_read_agg", "%p: key: %X writer header update", this, first_key.slice32(1));
// Update case (b) : grab doc_len from the writer's alternate
doc_len = alternate.object_size_get();
- if (write_vc->update_key == cod->single_doc_key &&
- (cod->move_resident_alt || write_vc->f.rewrite_resident_alt) && write_vc->first_buf._ptr()) {
+ if (write_vc->update_key == cod->single_doc_key && (cod->move_resident_alt || write_vc->f.rewrite_resident_alt) &&
+ write_vc->first_buf._ptr()) {
// the resident alternate is being updated and its a
// header only update. The first_buf of the writer has the
// document body.
- Doc *doc = (Doc *) write_vc->first_buf->data();
+ Doc *doc = (Doc *)write_vc->first_buf->data();
writer_buf = new_IOBufferBlock(write_vc->first_buf, doc->data_len(), doc->prefix_len());
MUTEX_RELEASE(writer_lock);
ink_assert(doc_len == doc->data_len());
@@ -433,7 +431,7 @@ CacheVC::openReadFromWriter(int event, Event * e)
return openReadStartEarliest(event, e);
}
} else {
-#endif //HTTP_CACHE
+#endif // HTTP_CACHE
DDebug("cache_read_agg", "%p: key: %X non-http passed stage 1", this, first_key.slice32(1));
key = write_vc->earliest_key;
#ifdef HTTP_CACHE
@@ -442,9 +440,8 @@ CacheVC::openReadFromWriter(int event, Event * e)
if (write_vc->fragment) {
doc_len = write_vc->vio.nbytes;
last_collision = NULL;
- DDebug("cache_read_agg",
- "%p: key: %X closed: %d, fragment: %d, len: %d starting first fragment",
- this, first_key.slice32(1), write_vc->closed, write_vc->fragment, (int)doc_len);
+ DDebug("cache_read_agg", "%p: key: %X closed: %d, fragment: %d, len: %d starting first fragment", this, first_key.slice32(1),
+ write_vc->closed, write_vc->fragment, (int)doc_len);
MUTEX_RELEASE(writer_lock);
// either a header + body update or a new document
SET_HANDLER(&CacheVC::openReadStartEarliest);
@@ -454,7 +451,7 @@ CacheVC::openReadFromWriter(int event, Event * e)
writer_offset = write_vc->offset;
length = write_vc->length;
// copy the vector
- f.single_fragment = !write_vc->fragment; // single fragment doc
+ f.single_fragment = !write_vc->fragment; // single fragment doc
doc_pos = 0;
earliest_key = write_vc->earliest_key;
ink_assert(earliest_key == key);
@@ -466,7 +463,7 @@ CacheVC::openReadFromWriter(int event, Event * e)
SET_HANDLER(&CacheVC::openReadFromWriterMain);
CACHE_INCREMENT_DYN_STAT(cache_read_busy_success_stat);
return callcont(CACHE_EVENT_OPEN_READ);
-#endif //READ_WHILE_WRITER
+#endif // READ_WHILE_WRITER
}
int
@@ -538,7 +535,7 @@ CacheVC::openReadClose(int event, Event * /* e ATS_UNUSED */)
}
int
-CacheVC::openReadReadDone(int event, Event * e)
+CacheVC::openReadReadDone(int event, Event *e)
{
Doc *doc = NULL;
@@ -554,10 +551,10 @@ CacheVC::openReadReadDone(int event, Event * e)
dir_delete(&earliest_key, vol, &earliest_dir);
goto Lerror;
}
- if (last_collision && // no missed lock
- dir_valid(vol, &dir)) // object still valid
+ if (last_collision && // no missed lock
+ dir_valid(vol, &dir)) // object still valid
{
- doc = (Doc *) buf->data();
+ doc = (Doc *)buf->data();
if (doc->magic != DOC_MAGIC) {
char tmpstring[100];
if (doc->magic == DOC_CORRUPT)
@@ -576,18 +573,18 @@ CacheVC::openReadReadDone(int event, Event * e)
goto LreadMain;
#if TS_USE_INTERIM_CACHE == 1
else if (dir_ininterim(&dir)) {
- dir_delete(&key, vol, &dir);
- last_collision = NULL;
- }
+ dir_delete(&key, vol, &dir);
+ last_collision = NULL;
+ }
#endif
}
#if TS_USE_INTERIM_CACHE == 1
if (last_collision && dir_get_offset(&dir) != dir_get_offset(last_collision))
last_collision = 0;
-Lread:
+ Lread:
#else
if (last_collision && dir_offset(&dir) != dir_offset(last_collision))
- last_collision = 0; // object has been/is being overwritten
+ last_collision = 0; // object has been/is being overwritten
#endif
if (dir_probe(&key, vol, &dir, &last_collision)) {
int ret = do_read_call(&key);
@@ -603,14 +600,12 @@ Lread:
#else
if (dir_offset(&dir) == dir_offset(&earliest_dir)) {
#endif
- DDebug("cache_read_agg", "%p: key: %X ReadRead complete: %d",
- this, first_key.slice32(1), (int)vio.ndone);
+ DDebug("cache_read_agg", "%p: key: %X ReadRead complete: %d", this, first_key.slice32(1), (int)vio.ndone);
doc_len = vio.ndone;
goto Ldone;
}
}
- DDebug("cache_read_agg", "%p: key: %X ReadRead writer aborted: %d",
- this, first_key.slice32(1), (int)vio.ndone);
+ DDebug("cache_read_agg", "%p: key: %X ReadRead writer aborted: %d", this, first_key.slice32(1), (int)vio.ndone);
goto Lerror;
}
DDebug("cache_read_agg", "%p: key: %X ReadRead retrying: %d", this, first_key.slice32(1), (int)vio.ndone);
@@ -638,7 +633,7 @@ int
CacheVC::openReadMain(int /* event ATS_UNUSED */, Event * /* e ATS_UNUSED */)
{
cancel_trigger();
- Doc *doc = (Doc *) buf->data();
+ Doc *doc = (Doc *)buf->data();
int64_t ntodo = vio.ntodo();
int64_t bytes = doc->len - doc_pos;
IOBufferBlock *b = NULL;
@@ -648,11 +643,11 @@ CacheVC::openReadMain(int /* event ATS_UNUSED */, Event * /* e ATS_UNUSED */)
return calluser(VC_EVENT_EOS);
}
#ifdef HTTP_CACHE
- HTTPInfo::FragOffset* frags = alternate.get_frag_table();
+ HTTPInfo::FragOffset *frags = alternate.get_frag_table();
if (is_debug_tag_set("cache_seek")) {
char b[33], c[33];
- Debug("cache_seek", "Seek @ %" PRId64" in %s from #%d @ %" PRId64"/%d:%s",
- seek_to, first_key.toHexStr(b), fragment, doc_pos, doc->len, doc->key.toHexStr(c));
+ Debug("cache_seek", "Seek @ %" PRId64 " in %s from #%d @ %" PRId64 "/%d:%s", seek_to, first_key.toHexStr(b), fragment,
+ doc_pos, doc->len, doc->key.toHexStr(c));
}
/* Because single fragment objects can migrate to hang off an alt vector
they can appear to the VC as multi-fragment when they are not really.
@@ -670,15 +665,13 @@ CacheVC::openReadMain(int /* event ATS_UNUSED */, Event * /* e ATS_UNUSED */)
more than the fragment table length, the start of the last
fragment being the last offset in the table.
*/
- if (fragment == 0 ||
- seek_to < frags[fragment-1] ||
- (fragment <= lfi && frags[fragment] <= seek_to)
- ) {
+ if (fragment == 0 || seek_to < frags[fragment - 1] || (fragment <= lfi && frags[fragment] <= seek_to)) {
// search from frag 0 on to find the proper frag
while (seek_to >= next_off && target < lfi) {
next_off = frags[++target];
}
- if (target == lfi && seek_to >= next_off) ++target;
+ if (target == lfi && seek_to >= next_off)
+ ++target;
} else { // shortcut if we are in the fragment already
target = fragment;
}
@@ -699,13 +692,14 @@ CacheVC::openReadMain(int /* event ATS_UNUSED */, Event * /* e ATS_UNUSED */)
if (is_debug_tag_set("cache_seek")) {
char target_key_str[33];
key.toHexStr(target_key_str);
- Debug("cache_seek", "Seek #%d @ %" PRId64" -> #%d @ %" PRId64":%s", cfi, doc_pos, target, seek_to, target_key_str);
+ Debug("cache_seek", "Seek #%d @ %" PRId64 " -> #%d @ %" PRId64 ":%s", cfi, doc_pos, target, seek_to, target_key_str);
}
goto Lread;
}
}
doc_pos = doc->prefix_len() + seek_to;
- if (fragment) doc_pos -= static_cast<int64_t>(frags[fragment-1]);
+ if (fragment)
+ doc_pos -= static_cast<int64_t>(frags[fragment - 1]);
vio.ndone = 0;
seek_to = 0;
ntodo = vio.ntodo();
@@ -713,7 +707,7 @@ CacheVC::openReadMain(int /* event ATS_UNUSED */, Event * /* e ATS_UNUSED */)
if (is_debug_tag_set("cache_seek")) {
char target_key_str[33];
key.toHexStr(target_key_str);
- Debug("cache_seek", "Read # %d @ %" PRId64"/%d for %" PRId64, fragment, doc_pos, doc->len, bytes);
+ Debug("cache_seek", "Read # %d @ %" PRId64 "/%d for %" PRId64, fragment, doc_pos, doc->len, bytes);
}
#endif
}
@@ -741,53 +735,52 @@ CacheVC::openReadMain(int /* event ATS_UNUSED */, Event * /* e ATS_UNUSED */)
goto Lread;
return EVENT_CONT;
}
-Lread: {
- if (vio.ndone >= (int64_t)doc_len)
- // reached the end of the document and the user still wants more
- return calluser(VC_EVENT_EOS);
- last_collision = 0;
- writer_lock_retry = 0;
- // if the state machine calls reenable on the callback from the cache,
- // we set up a schedule_imm event. The openReadReadDone discards
- // EVENT_IMMEDIATE events. So, we have to cancel that trigger and set
- // a new EVENT_INTERVAL event.
- cancel_trigger();
- CACHE_TRY_LOCK(lock, vol->mutex, mutex->thread_holding);
- if (!lock.is_locked()) {
- SET_HANDLER(&CacheVC::openReadMain);
- VC_SCHED_LOCK_RETRY();
- }
- if (dir_probe(&key, vol, &dir, &last_collision)) {
- SET_HANDLER(&CacheVC::openReadReadDone);
- int ret = do_read_call(&key);
- if (ret == EVENT_RETURN)
- goto Lcallreturn;
- return EVENT_CONT;
- } else if (write_vc) {
- if (writer_done()) {
- last_collision = NULL;
- while (dir_probe(&earliest_key, vol, &dir, &last_collision)) {
- if (dir_offset(&dir) == dir_offset(&earliest_dir)) {
- DDebug("cache_read_agg", "%p: key: %X ReadMain complete: %d",
- this, first_key.slice32(1), (int)vio.ndone);
- doc_len = vio.ndone;
- goto Leos;
- }
+Lread : {
+ if (vio.ndone >= (int64_t)doc_len)
+ // reached the end of the document and the user still wants more
+ return calluser(VC_EVENT_EOS);
+ last_collision = 0;
+ writer_lock_retry = 0;
+ // if the state machine calls reenable on the callback from the cache,
+ // we set up a schedule_imm event. The openReadReadDone discards
+ // EVENT_IMMEDIATE events. So, we have to cancel that trigger and set
+ // a new EVENT_INTERVAL event.
+ cancel_trigger();
+ CACHE_TRY_LOCK(lock, vol->mutex, mutex->thread_holding);
+ if (!lock.is_locked()) {
+ SET_HANDLER(&CacheVC::openReadMain);
+ VC_SCHED_LOCK_RETRY();
+ }
+ if (dir_probe(&key, vol, &dir, &last_collision)) {
+ SET_HANDLER(&CacheVC::openReadReadDone);
+ int ret = do_read_call(&key);
+ if (ret == EVENT_RETURN)
+ goto Lcallreturn;
+ return EVENT_CONT;
+ } else if (write_vc) {
+ if (writer_done()) {
+ last_collision = NULL;
+ while (dir_probe(&earliest_key, vol, &dir, &last_collision)) {
+ if (dir_offset(&dir) == dir_offset(&earliest_dir)) {
+ DDebug("cache_read_agg", "%p: key: %X ReadMain complete: %d", this, first_key.slice32(1), (int)vio.ndone);
+ doc_len = vio.ndone;
+ goto Leos;
}
- DDebug("cache_read_agg", "%p: key: %X ReadMain writer aborted: %d",
- this, first_key.slice32(1), (int)vio.ndone);
- goto Lerror;
}
- DDebug("cache_read_agg", "%p: key: %X ReadMain retrying: %d", this, first_key.slice32(1), (int)vio.ndone);
- SET_HANDLER(&CacheVC::openReadMain);
- VC_SCHED_WRITER_RETRY();
+ DDebug("cache_read_agg", "%p: key: %X ReadMain writer aborted: %d", this, first_key.slice32(1), (int)vio.ndone);
+ goto Lerror;
}
- if (is_action_tag_set("cache"))
- ink_release_assert(false);
- Warning("Document %X truncated at %d of %d, missing fragment %X", first_key.slice32(1), (int)vio.ndone, (int)doc_len, key.slice32(1));
- // remove the directory entry
- dir_delete(&earliest_key, vol, &earliest_dir);
+ DDebug("cache_read_agg", "%p: key: %X ReadMain retrying: %d", this, first_key.slice32(1), (int)vio.ndone);
+ SET_HANDLER(&CacheVC::openReadMain);
+ VC_SCHED_WRITER_RETRY();
}
+ if (is_action_tag_set("cache"))
+ ink_release_assert(false);
+ Warning("Document %X truncated at %d of %d, missing fragment %X", first_key.slice32(1), (int)vio.ndone, (int)doc_len,
+ key.slice32(1));
+ // remove the directory entry
+ dir_delete(&earliest_key, vol, &earliest_dir);
+}
Lerror:
return calluser(VC_EVENT_ERROR);
Leos:
@@ -825,7 +818,7 @@ CacheVC::openReadStartEarliest(int /* event ATS_UNUSED */, Event * /* e ATS_UNUS
last_collision = NULL;
goto Lread;
}
- doc = (Doc *) buf->data();
+ doc = (Doc *)buf->data();
if (doc->magic != DOC_MAGIC) {
char tmpstring[100];
if (is_action_tag_set("cache")) {
@@ -856,16 +849,14 @@ CacheVC::openReadStartEarliest(int /* event ATS_UNUSED */, Event * /* e ATS_UNUS
#if TS_USE_INTERIM_CACHE == 1
&& !dir_ininterim(&dir)
#endif
- ) {
- DDebug("cache_hit_evac", "dir: %" PRId64", write: %" PRId64", phase: %d",
- dir_offset(&earliest_dir), offset_to_vol_offset(vol, vol->header->write_pos), vol->header->phase);
+ ) {
+ DDebug("cache_hit_evac", "dir: %" PRId64 ", write: %" PRId64 ", phase: %d", dir_offset(&earliest_dir),
+ offset_to_vol_offset(vol, vol->header->write_pos), vol->header->phase);
f.hit_evacuate = 1;
}
goto Lsuccess;
-Lread:
- if (dir_probe(&key, vol, &earliest_dir, &last_collision) ||
- dir_lookaside_probe(&key, vol, &earliest_dir, NULL))
- {
+ Lread:
+ if (dir_probe(&key, vol, &earliest_dir, &last_collision) || dir_lookaside_probe(&key, vol, &earliest_dir, NULL)) {
dir = earliest_dir;
#if TS_USE_INTERIM_CACHE == 1
if (dir_ininterim(&dir) && alternate.get_frag_offset_count() > 1) {
@@ -878,13 +869,13 @@ Lread:
goto Lcallreturn;
return ret;
}
- // read has detected that alternate does not exist in the cache.
- // rewrite the vector.
+// read has detected that alternate does not exist in the cache.
+// rewrite the vector.
#ifdef HTTP_CACHE
if (!f.read_from_writer_called && frag_type == CACHE_FRAG_TYPE_HTTP) {
// don't want any writers while we are evacuating the vector
if (!vol->open_write(this, false, 1)) {
- Doc *doc1 = (Doc *) first_buf->data();
+ Doc *doc1 = (Doc *)first_buf->data();
uint32_t len = this->load_http_info(write_vector, doc1);
ink_assert(len == doc1->hlen && write_vector->count() > 0);
write_vector->remove(alternate_index, true);
@@ -938,13 +929,13 @@ Lread:
}
}
#endif
- // open write failure - another writer, so don't modify the vector
+ // open write failure - another writer, so don't modify the vector
Ldone:
if (od)
vol->close_write(this);
}
CACHE_INCREMENT_DYN_STAT(cache_read_failure_stat);
- _action.continuation->handleEvent(CACHE_EVENT_OPEN_READ_FAILED, (void *) -ECACHE_NO_DOC);
+ _action.continuation->handleEvent(CACHE_EVENT_OPEN_READ_FAILED, (void *)-ECACHE_NO_DOC);
return free_CacheVC(this);
Lcallreturn:
return handleEvent(AIO_EVENT_DONE, 0); // hopefully a tail call
@@ -998,7 +989,7 @@ CacheVC::openReadVecWrite(int /* event ATS_UNUSED */, Event * /* e ATS_UNUSED */
}
CACHE_INCREMENT_DYN_STAT(cache_read_failure_stat);
- _action.continuation->handleEvent(CACHE_EVENT_OPEN_READ_FAILED, (void *) -ECACHE_ALT_MISS);
+ _action.continuation->handleEvent(CACHE_EVENT_OPEN_READ_FAILED, (void *)-ECACHE_ALT_MISS);
return free_CacheVC(this);
Lrestart:
SET_HANDLER(&CacheVC::openReadStartHead);
@@ -1011,7 +1002,7 @@ Lrestart:
if you change this you might have to change that.
*/
int
-CacheVC::openReadStartHead(int event, Event * e)
+CacheVC::openReadStartHead(int event, Event *e)
{
intptr_t err = ECACHE_NO_DOC;
Doc *doc = NULL;
@@ -1041,7 +1032,7 @@ CacheVC::openReadStartHead(int event, Event * e)
#endif
goto Lread;
}
- doc = (Doc *) buf->data();
+ doc = (Doc *)buf->data();
if (doc->magic != DOC_MAGIC) {
char tmpstring[100];
if (is_action_tag_set("cache")) {
@@ -1084,28 +1075,23 @@ CacheVC::openReadStartHead(int event, Event * e)
goto Ldone;
if ((uml = this->load_http_info(&vector, doc)) != doc->hlen) {
if (buf) {
- HTTPCacheAlt* alt = reinterpret_cast<HTTPCacheAlt*>(doc->hdr());
+ HTTPCacheAlt *alt = reinterpret_cast<HTTPCacheAlt *>(doc->hdr());
int32_t alt_length = 0;
// count should be reasonable, as vector is initialized and unlikly to be too corrupted
// by bad disk data - count should be the number of successfully unmarshalled alts.
- for ( int32_t i = 0 ; i < vector.count() ; ++i ) {
- CacheHTTPInfo* info = vector.get(i);
- if (info && info->m_alt) alt_length += info->m_alt->m_unmarshal_len;
+ for (int32_t i = 0; i < vector.count(); ++i) {
+ CacheHTTPInfo *info = vector.get(i);
+ if (info && info->m_alt)
+ alt_length += info->m_alt->m_unmarshal_len;
}
Note("OpenReadHead failed for cachekey %X : vector inconsistency - "
"unmarshalled %d expecting %d in %d (base=%d, ver=%d:%d) "
"- vector n=%d size=%d"
- "first alt=%d[%s]"
- , key.slice32(0)
- , uml, doc->hlen, doc->len, sizeofDoc
- , doc->v_major, doc->v_minor
- , vector.count(), alt_length
- , alt->m_magic
- , (CACHE_ALT_MAGIC_ALIVE == alt->m_magic ? "alive"
- : CACHE_ALT_MAGIC_MARSHALED == alt->m_magic ? "serial"
- : CACHE_ALT_MAGIC_DEAD == alt->m_magic ? "dead"
- : "bogus")
- );
+ "first alt=%d[%s]",
+ key.slice32(0), uml, doc->hlen, doc->len, sizeofDoc, doc->v_major, doc->v_minor, vector.count(), alt_length,
+ alt->m_magic, (CACHE_ALT_MAGIC_ALIVE == alt->m_magic ? "alive" : CACHE_ALT_MAGIC_MARSHALED == alt->m_magic ?
+ "serial" :
+ CACHE_ALT_MAGIC_DEAD == alt->m_magic ? "dead" : "bogus"));
dir_delete(&key, vol, &dir);
}
err = ECACHE_BAD_META_DATA;
@@ -1131,9 +1117,9 @@ CacheVC::openReadStartHead(int event, Event * e)
alternate.copy_shallow(alternate_tmp);
alternate.object_key_get(&key);
doc_len = alternate.object_size_get();
- if (key == doc->key) { // is this my data?
+ if (key == doc->key) { // is this my data?
f.single_fragment = doc->single_fragment();
- ink_assert(f.single_fragment); // otherwise need to read earliest
+ ink_assert(f.single_fragment); // otherwise need to read earliest
ink_assert(doc->hlen);
doc_pos = doc->prefix_len();
next_CacheKey(&key, &doc->key);
@@ -1150,17 +1136,15 @@ CacheVC::openReadStartHead(int event, Event * e)
}
if (is_debug_tag_set("cache_read")) { // amc debug
- char xt[33],yt[33];
- Debug("cache_read", "CacheReadStartHead - read %s target %s - %s %d of %" PRId64" bytes, %d fragments",
- doc->key.toHexStr(xt), key.toHexStr(yt),
- f.single_fragment ? "single" : "multi",
- doc->len, doc->total_len,
+ char xt[33], yt[33];
+ Debug("cache_read", "CacheReadStartHead - read %s target %s - %s %d of %" PRId64 " bytes, %d fragments",
+ doc->key.toHexStr(xt), key.toHexStr(yt), f.single_fragment ? "single" : "multi", doc->len, doc->total_len,
#ifdef HTTP_CACHE
alternate.get_frag_offset_count()
#else
0
#endif
- );
+ );
}
// the first fragment might have been gc'ed. Make sure the first
// fragment is there before returning CACHE_EVENT_OPEN_READ
@@ -1173,8 +1157,8 @@ CacheVC::openReadStartHead(int event, Event * e)
&& !f.read_from_interim
#endif
) {
- DDebug("cache_hit_evac", "dir: %" PRId64", write: %" PRId64", phase: %d",
- dir_offset(&dir), offset_to_vol_offset(vol, vol->header->write_pos), vol->header->phase);
+ DDebug("cache_hit_evac", "dir: %" PRId64 ", write: %" PRId64 ", phase: %d", dir_offset(&dir),
+ offset_to_vol_offset(vol, vol->header->write_pos), vol->header->phase);
f.hit_evacuate = 1;
}
@@ -1211,10 +1195,10 @@ CacheVC::openReadStartHead(int event, Event * e)
Ldone:
if (!f.lookup) {
CACHE_INCREMENT_DYN_STAT(cache_read_failure_stat);
- _action.continuation->handleEvent(CACHE_EVENT_OPEN_READ_FAILED, (void *) -err);
+ _action.continuation->handleEvent(CACHE_EVENT_OPEN_READ_FAILED, (void *)-err);
} else {
CACHE_INCREMENT_DYN_STAT(cache_lookup_failure_stat);
- _action.continuation->handleEvent(CACHE_EVENT_LOOKUP_FAILED, (void *) -err);
+ _action.continuation->handleEvent(CACHE_EVENT_LOOKUP_FAILED, (void *)-err);
}
return free_CacheVC(this);
Lcallreturn: