You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by jp...@apache.org on 2013/04/25 01:33:20 UTC
git commit: TS-1851: Remove HostDBInfo constructor so it becomes a POD
Updated Branches:
refs/heads/master bb2fcaad3 -> 2915206c7
TS-1851: Remove HostDBInfo constructor so it becomes a POD
Somewhere down the line HostDBInfo grew enough constructor complexity
that it became a non-POD type. The allocation treats it like a POD
type, so we should make sure that the compiler agrees.
Rename HostDBRoundRobin::n to HostDBRoundRobin::rrcount. Remove
unused HostDBInfo::set_from
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/2915206c
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/2915206c
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/2915206c
Branch: refs/heads/master
Commit: 2915206c73f08dcb9d262dfa0f19967f20eaabdf
Parents: bb2fcaa
Author: James Peach <jp...@apache.org>
Authored: Wed Apr 3 15:36:53 2013 -0700
Committer: James Peach <jp...@apache.org>
Committed: Wed Apr 24 16:31:06 2013 -0700
----------------------------------------------------------------------
CHANGES | 2 +
iocore/dns/DNS.cc | 2 +-
iocore/dns/SRV.h | 6 ++--
iocore/hostdb/HostDB.cc | 44 ++++++++++++++------------
iocore/hostdb/I_HostDBProcessor.h | 52 +++++---------------------------
iocore/hostdb/P_HostDBProcessor.h | 8 ++--
proxy/http/HttpSM.cc | 2 +-
proxy/http/HttpTransact.h | 2 +-
8 files changed, 44 insertions(+), 74 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/2915206c/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index d75f00d..9720edb 100644
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,8 @@
Changes with Apache Traffic Server 3.3.3
+ *) [TS-1851] Turn HostDBInfo back into a POD type.
+
*) [TS-1850] Improve SSL certificate error reporting.
*) [TS-1848] Fix MIMEHdr::field_value_set_int64() wrapper.
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/2915206c/iocore/dns/DNS.cc
----------------------------------------------------------------------
diff --git a/iocore/dns/DNS.cc b/iocore/dns/DNS.cc
index 3efd938..2d99eea 100644
--- a/iocore/dns/DNS.cc
+++ b/iocore/dns/DNS.cc
@@ -1360,7 +1360,7 @@ dns_process(DNSHandler *handler, HostEnt *buf, int len)
ink_assert(buf->srv_hosts.srv_host_count == 0 && buf->srv_hosts.srv_hosts_length == 0);
buf->srv_hosts.srv_host_count = 0;
buf->srv_hosts.srv_hosts_length = 0;
- int &num_srv = buf->srv_hosts.srv_host_count;
+ unsigned& num_srv = buf->srv_hosts.srv_host_count;
int rname_len = -1;
//
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/2915206c/iocore/dns/SRV.h
----------------------------------------------------------------------
diff --git a/iocore/dns/SRV.h b/iocore/dns/SRV.h
index 4393d7e..8e3e697 100644
--- a/iocore/dns/SRV.h
+++ b/iocore/dns/SRV.h
@@ -58,11 +58,11 @@ operator<(const SRV &left, const SRV &right)
struct SRVHosts
{
- int srv_host_count;
- int srv_hosts_length;
+ unsigned srv_host_count;
+ unsigned srv_hosts_length;
SRV hosts[HOST_DB_MAX_ROUND_ROBIN_INFO];
- ~SRVHosts()
+ ~SRVHosts()
{
}
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/2915206c/iocore/hostdb/HostDB.cc
----------------------------------------------------------------------
diff --git a/iocore/hostdb/HostDB.cc b/iocore/hostdb/HostDB.cc
index 52075d6..6221885 100644
--- a/iocore/hostdb/HostDB.cc
+++ b/iocore/hostdb/HostDB.cc
@@ -82,7 +82,7 @@ HostDBInfo::srvname(HostDBRoundRobin *rr)
{
if (!is_srv || !data.srv.srv_offset)
return NULL;
- ink_assert(this - rr->info >= 0 && this - rr->info < rr->n && data.srv.srv_offset < rr->length);
+ ink_assert(this - rr->info >= 0 && this - rr->info < rr->rrcount && data.srv.srv_offset < rr->length);
return (char *) rr + data.srv.srv_offset;
}
@@ -239,8 +239,8 @@ HostDBCache::rebuild_callout(HostDBInfo * e, RebuildMC & r)
HostDBRoundRobin *rr = (HostDBRoundRobin *) ptr(&e->app.rr.offset, r.partition);
if (!rr)
return corrupt_debugging_callout(e, r);
- if (rr->n > HOST_DB_MAX_ROUND_ROBIN_INFO || rr->n <= 0 ||
- rr->good > HOST_DB_MAX_ROUND_ROBIN_INFO || rr->good <= 0 || rr->good > rr->n)
+ if (rr->rrcount > HOST_DB_MAX_ROUND_ROBIN_INFO || rr->rrcount <= 0 ||
+ rr->good > HOST_DB_MAX_ROUND_ROBIN_INFO || rr->good <= 0 || rr->good > rr->rrcount)
return corrupt_debugging_callout(e, r);
for (int i = 0; i < rr->good; i++) {
if (!valid_heap_pointer(((char *) &rr->info[i + 1]) - 1))
@@ -601,7 +601,7 @@ reply_to_cont(Continuation * cont, HostDBInfo * ar, bool is_srv = false)
goto Lerror;
}
ip_text_buffer ipb;
- Debug("hostdb", "RR of %d with %d good, 1st IP = %s", r->rr()->n, r->rr()->good, ats_ip_ntop(r->ip(), ipb, sizeof ipb));
+ Debug("hostdb", "RR of %d with %d good, 1st IP = %s", r->rr()->rrcount, r->rr()->good, ats_ip_ntop(r->ip(), ipb, sizeof ipb));
}
cont->handleEvent(is_srv ? EVENT_SRV_LOOKUP : EVENT_HOST_DB_LOOKUP, r);
@@ -1045,7 +1045,7 @@ do_setby(HostDBInfo * r, HostDBApplicationInfo * app, const char *hostname, IpAd
if (rr) {
if (is_srv) {
uint32_t key = makeHostHash(hostname);
- for (int i = 0; i < rr->n; i++) {
+ for (int i = 0; i < rr->rrcount; i++) {
if (key == rr->info[i].data.srv.key && !strcmp(hostname, rr->info[i].srvname(rr))) {
Debug("hostdb", "immediate setby for %s", hostname);
rr->info[i].app.allotment.application1 = app->allotment.application1;
@@ -1054,7 +1054,7 @@ do_setby(HostDBInfo * r, HostDBApplicationInfo * app, const char *hostname, IpAd
}
}
} else
- for (int i = 0; i < rr->n; i++) {
+ for (int i = 0; i < rr->rrcount; i++) {
if (rr->info[i].ip() == ip) {
Debug("hostdb", "immediate setby for %s", hostname ? hostname : "<addr>");
rr->info[i].app.allotment.application1 = app->allotment.application1;
@@ -1389,7 +1389,7 @@ static int
restore_info(HostDBInfo * r, HostDBInfo * old_r, HostDBInfo & old_info, HostDBRoundRobin * old_rr_data)
{
if (old_rr_data) {
- for (int j = 0; j < old_rr_data->n; j++)
+ for (int j = 0; j < old_rr_data->rrcount; j++)
if (ats_ip_addr_eq(old_rr_data->info[j].ip(), r->ip())) {
r->app = old_rr_data->info[j].app;
return true;
@@ -1459,7 +1459,7 @@ HostDBContinuation::dnsEvent(int event, HostEnt * e)
HostDBRoundRobin *old_rr_data = old_r ? old_r->rr() : NULL;
#ifdef DEBUG
if (old_rr_data) {
- for (int i = 0; i < old_rr_data->n; ++i) {
+ for (int i = 0; i < old_rr_data->rrcount; ++i) {
if (old_r->md5_high != old_rr_data->info[i].md5_high ||
old_r->md5_low != old_rr_data->info[i].md5_low ||
old_r->md5_low_low != old_rr_data->info[i].md5_low_low)
@@ -1522,11 +1522,13 @@ HostDBContinuation::dnsEvent(int event, HostEnt * e)
ink_assert(!r || (r->app.allotment.application1 == 0 && r->app.allotment.application2 == 0));
if (rr) {
- int s = HostDBRoundRobin::size(n, e->srv_hosts.srv_hosts_length);
- HostDBRoundRobin *rr_data = (HostDBRoundRobin *) hostDB.alloc(&r->app.rr.offset, s);
- Debug("hostdb", "allocating %d bytes for %d RR at %p %d", s, n, rr_data, r->app.rr.offset);
+ const int rrsize = HostDBRoundRobin::size(n, e->srv_hosts.srv_hosts_length);
+ HostDBRoundRobin *rr_data = (HostDBRoundRobin *) hostDB.alloc(&r->app.rr.offset, rrsize);
+
+ Debug("hostdb", "allocating %d bytes for %d RR at %p %d", rrsize, n, rr_data, r->app.rr.offset);
+
if (rr_data) {
- rr_data->length = s;
+ rr_data->length = rrsize;
int i = 0, ii = 0;
if (is_srv()) {
int skip = 0;
@@ -1550,6 +1552,8 @@ HostDBContinuation::dnsEvent(int event, HostEnt * e)
for (i = 0; i < n; ++i) {
SRV *t = q[i];
HostDBInfo& item = rr_data->info[i];
+
+ memset(&item, 0, sizeof(item));
item.round_robin = 0;
item.reverse_dns = 0;
item.is_srv = 1;
@@ -1558,7 +1562,7 @@ HostDBContinuation::dnsEvent(int event, HostEnt * e)
item.data.srv.srv_port = t->port;
item.data.srv.key = t->key;
- ink_assert (skip + (int) t->host_len <= e->srv_hosts.srv_hosts_length);
+ ink_assert((skip + t->host_len) <= e->srv_hosts.srv_hosts_length);
memcpy(pos + skip, t->host, t->host_len);
item.data.srv.srv_offset = (pos - (char *) rr_data) + skip;
@@ -1574,13 +1578,13 @@ HostDBContinuation::dnsEvent(int event, HostEnt * e)
item.app.allotment.application2 = 0;
Debug("dns_srv", "inserted SRV RR record [%s] into HostDB with TTL: %d seconds", t->host, ttl_seconds);
}
- rr_data->good = rr_data->n = n;
+ rr_data->good = rr_data->rrcount = n;
rr_data->current = 0;
// restore
if (old_rr_data) {
- for (i = 0; i < rr_data->n; ++i) {
- for (ii = 0; ii < old_rr_data->n; ++ii) {
+ for (i = 0; i < rr_data->rrcount; ++i) {
+ for (ii = 0; ii < old_rr_data->rrcount; ++ii) {
if (rr_data->info[i].data.srv.key == old_rr_data->info[ii].data.srv.key) {
char *new_host = rr_data->info[i].srvname(rr_data);
char *old_host = old_rr_data->info[ii].srvname(old_rr_data);
@@ -1610,7 +1614,7 @@ HostDBContinuation::dnsEvent(int event, HostEnt * e)
++i;
}
}
- rr_data->good = rr_data->n = n;
+ rr_data->good = rr_data->rrcount = n;
rr_data->current = 0;
}
} else {
@@ -2233,7 +2237,7 @@ HostDBInfo::rr()
HostDBRoundRobin *r = (HostDBRoundRobin *) hostDB.ptr(&app.rr.offset, hostDB.ptr_to_partition((char *) this));
- if (r && (r->n > HOST_DB_MAX_ROUND_ROBIN_INFO || r->n <= 0 || r->good > HOST_DB_MAX_ROUND_ROBIN_INFO || r->good <= 0)) {
+ if (r && (r->rrcount > HOST_DB_MAX_ROUND_ROBIN_INFO || r->rrcount <= 0 || r->good > HOST_DB_MAX_ROUND_ROBIN_INFO || r->good <= 0)) {
ink_assert(!"bad round-robin");
return NULL;
}
@@ -2359,12 +2363,12 @@ struct ShowHostDB: public ShowCont
HostDBRoundRobin *rr_data = r->rr();
if (rr_data) {
CHECK_SHOW(show("<table border=1>\n"));
- CHECK_SHOW(show("<tr><td>%s</td><td>%d</td></tr>\n", "Total", rr_data->n));
+ CHECK_SHOW(show("<tr><td>%s</td><td>%d</td></tr>\n", "Total", rr_data->rrcount));
CHECK_SHOW(show("<tr><td>%s</td><td>%d</td></tr>\n", "Good", rr_data->good));
CHECK_SHOW(show("<tr><td>%s</td><td>%d</td></tr>\n", "Current", rr_data->current));
CHECK_SHOW(show("</table>\n"));
- for (int i = 0; i < rr_data->n; i++)
+ for (int i = 0; i < rr_data->rrcount; i++)
showOne(&rr_data->info[i], true, event, e);
}
}
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/2915206c/iocore/hostdb/I_HostDBProcessor.h
----------------------------------------------------------------------
diff --git a/iocore/hostdb/I_HostDBProcessor.h b/iocore/hostdb/I_HostDBProcessor.h
index 9029d80..a1fd949 100644
--- a/iocore/hostdb/I_HostDBProcessor.h
+++ b/iocore/hostdb/I_HostDBProcessor.h
@@ -217,25 +217,6 @@ struct HostDBInfo
}
- /**
- These are the only fields which will be inserted into the
- database. Any new user fields must be added to this function.
-
- */
- void set_from(HostDBInfo const& that)
- {
- memcpy(&data, &that.data, sizeof data);
- ip_timestamp = that.ip_timestamp;
- ip_timeout_interval = that.ip_timeout_interval;
- is_srv = that.is_srv;
- round_robin = that.round_robin;
- reverse_dns = that.reverse_dns;
-
- app.allotment.application1 = that.app.allotment.application1;
- app.allotment.application2 = that.app.allotment.application2;
- }
-
-
//
// Private
//
@@ -321,32 +302,13 @@ struct HostDBInfo
bool match(INK_MD5 &, int, int);
int heap_size();
int *heap_offset_ptr();
-
-HostDBInfo()
- : ip_timestamp(0)
- , ip_timeout_interval(0)
- , full(0)
- , backed(0)
- , deleted(0)
- , hits(0)
- , is_srv(0)
- , round_robin(0)
- , reverse_dns(0)
- , md5_low_low(0)
- , md5_low(0), md5_high(0) {
- app.allotment.application1 = 0;
- app.allotment.application2 = 0;
- ats_ip_invalidate(ip());
-
- return;
- }
};
struct HostDBRoundRobin
{
/** Total number (to compute space used). */
- short n;
+ short rrcount;
/** Number which have not failed a connect. */
short good;
@@ -355,12 +317,14 @@ struct HostDBRoundRobin
unsigned short length;
ink_time_t timed_rr_ctime;
- HostDBInfo info[1];
+ HostDBInfo info[];
- static int size(int nn, int srv_len = 0)
+ // Return the allocation size of a HostDBRoundRobin struct suitable for storing
+ // "count" HostDBInfo records.
+ static unsigned size(unsigned count, unsigned srv_len = 0)
{
- ink_assert(nn > 0);
- return INK_ALIGN((int) (sizeof(HostDBRoundRobin) + (nn-1) * sizeof(HostDBInfo) + srv_len), 8);
+ ink_assert(count > 0);
+ return INK_ALIGN((sizeof(HostDBRoundRobin) + (count * sizeof(HostDBInfo)) + srv_len), 8);
}
/** Find the index of @a addr in member @a info.
@@ -378,7 +342,7 @@ struct HostDBRoundRobin
HostDBInfo *select_best_http(sockaddr const* client_ip, ink_time_t now, int32_t fail_window);
HostDBInfo *select_best_srv(char *target, InkRand *rand, ink_time_t now, int32_t fail_window);
HostDBRoundRobin()
- : n(0), good(0), current(0), length(0), timed_rr_ctime(0)
+ : rrcount(0), good(0), current(0), length(0), timed_rr_ctime(0)
{ }
};
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/2915206c/iocore/hostdb/P_HostDBProcessor.h
----------------------------------------------------------------------
diff --git a/iocore/hostdb/P_HostDBProcessor.h b/iocore/hostdb/P_HostDBProcessor.h
index 9691392..1920c2e 100644
--- a/iocore/hostdb/P_HostDBProcessor.h
+++ b/iocore/hostdb/P_HostDBProcessor.h
@@ -184,7 +184,7 @@ struct HostDBCache: public MultiCache<HostDBInfo>
inline int
HostDBRoundRobin::index_of(sockaddr const* ip) {
- bool bad = (n <= 0 || n > HOST_DB_MAX_ROUND_ROBIN_INFO || good <= 0 || good > HOST_DB_MAX_ROUND_ROBIN_INFO);
+ bool bad = (rrcount <= 0 || rrcount > HOST_DB_MAX_ROUND_ROBIN_INFO || good <= 0 || good > HOST_DB_MAX_ROUND_ROBIN_INFO);
if (bad) {
ink_assert(!"bad round robin size");
return -1;
@@ -220,7 +220,7 @@ HostDBRoundRobin::select_next(sockaddr const* ip) {
inline HostDBInfo *
HostDBRoundRobin::find_target(const char *target) {
- bool bad = (n <= 0 || n > HOST_DB_MAX_ROUND_ROBIN_INFO || good <= 0 || good > HOST_DB_MAX_ROUND_ROBIN_INFO);
+ bool bad = (rrcount <= 0 || rrcount > HOST_DB_MAX_ROUND_ROBIN_INFO || good <= 0 || good > HOST_DB_MAX_ROUND_ROBIN_INFO);
if (bad) {
ink_assert(!"bad round robin size");
return NULL;
@@ -237,7 +237,7 @@ HostDBRoundRobin::find_target(const char *target) {
inline HostDBInfo *
HostDBRoundRobin::select_best_http(sockaddr const* client_ip, ink_time_t now, int32_t fail_window)
{
- bool bad = (n <= 0 || n > HOST_DB_MAX_ROUND_ROBIN_INFO || good <= 0 || good > HOST_DB_MAX_ROUND_ROBIN_INFO);
+ bool bad = (rrcount <= 0 || rrcount > HOST_DB_MAX_ROUND_ROBIN_INFO || good <= 0 || good > HOST_DB_MAX_ROUND_ROBIN_INFO);
if (bad) {
ink_assert(!"bad round robin size");
@@ -314,7 +314,7 @@ HostDBRoundRobin::select_best_http(sockaddr const* client_ip, ink_time_t now, in
inline HostDBInfo *
HostDBRoundRobin::select_best_srv(char *target, InkRand *rand, ink_time_t now, int32_t fail_window)
{
- bool bad = (n <= 0 || n > HOST_DB_MAX_ROUND_ROBIN_INFO || good <= 0 || good > HOST_DB_MAX_ROUND_ROBIN_INFO);
+ bool bad = (rrcount <= 0 || rrcount > HOST_DB_MAX_ROUND_ROBIN_INFO || good <= 0 || good > HOST_DB_MAX_ROUND_ROBIN_INFO);
if (bad) {
ink_assert(!"bad round robin size");
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/2915206c/proxy/http/HttpSM.cc
----------------------------------------------------------------------
diff --git a/proxy/http/HttpSM.cc b/proxy/http/HttpSM.cc
index 300b890..db3a415 100644
--- a/proxy/http/HttpSM.cc
+++ b/proxy/http/HttpSM.cc
@@ -2026,7 +2026,7 @@ HttpSM::process_hostdb_info(HostDBInfo * r)
// set the srv target`s last_failure
if (t_state.dns_info.srv_lookup_success) {
uint32_t last_failure = 0xFFFFFFFF;
- for (int i = 0; i < rr->n && last_failure != 0; ++i) {
+ for (int i = 0; i < rr->rrcount && last_failure != 0; ++i) {
if (last_failure > rr->info[i].app.http_data.last_failure)
last_failure = rr->info[i].app.http_data.last_failure;
}
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/2915206c/proxy/http/HttpTransact.h
----------------------------------------------------------------------
diff --git a/proxy/http/HttpTransact.h b/proxy/http/HttpTransact.h
index 2e53b2d..21383fe 100644
--- a/proxy/http/HttpTransact.h
+++ b/proxy/http/HttpTransact.h
@@ -1035,7 +1035,6 @@ public:
next_hop_scheme(scheme),
orig_scheme(scheme),
method(0),
- host_db_info(),
cause_of_death_errno(-UNKNOWN_INTERNAL_ERROR),
client_request_time(UNDEFINED_TIME),
request_sent_time(UNDEFINED_TIME),
@@ -1116,6 +1115,7 @@ public:
memset(return_xbuf, 0, sizeof(return_xbuf));
memset(user_args, 0, sizeof(user_args));
+ memset(&host_db_info, 0, sizeof(host_db_info));
}
void
Re: git commit: TS-1851: Remove HostDBInfo constructor so it becomes a POD
Posted by James Peach <jp...@apache.org>.
On Apr 24, 2013, at 4:44 PM, Igor Galić <i....@brainsware.org> wrote:
>
>
> ----- Original Message -----
>> Updated Branches:
>> refs/heads/master bb2fcaad3 -> 2915206c7
>>
>>
>> TS-1851: Remove HostDBInfo constructor so it becomes a POD
>>
>> Somewhere down the line HostDBInfo grew enough constructor complexity
>> that it became a non-POD type. The allocation treats it like a POD
>> type, so we should make sure that the compiler agrees.
>>
>> Rename HostDBRoundRobin::n to HostDBRoundRobin::rrcount. Remove
>> unused HostDBInfo::set_from
> [snip]
>> Commit: 2915206c73f08dcb9d262dfa0f19967f20eaabdf
>> Parents: bb2fcaa
> [snip]
>> http://git-wip-us.apache.org/repos/asf/trafficserver/blob/2915206c/iocore/hostdb/HostDB.cc
>> ----------------------------------------------------------------------
>> diff --git a/iocore/hostdb/HostDB.cc b/iocore/hostdb/HostDB.cc
>> index 52075d6..6221885 100644
>> --- a/iocore/hostdb/HostDB.cc
>> +++ b/iocore/hostdb/HostDB.cc
> [snip]
>> @@ -2233,7 +2237,7 @@ HostDBInfo::rr()
>>
>> HostDBRoundRobin *r = (HostDBRoundRobin *)
>> hostDB.ptr(&app.rr.offset, hostDB.ptr_to_partition((char *)
>> this));
>>
>> - if (r && (r->n > HOST_DB_MAX_ROUND_ROBIN_INFO || r->n <= 0 ||
>> r->good > HOST_DB_MAX_ROUND_ROBIN_INFO || r->good <= 0)) {
>> + if (r && (r->rrcount > HOST_DB_MAX_ROUND_ROBIN_INFO || r->rrcount
>> <= 0 || r->good > HOST_DB_MAX_ROUND_ROBIN_INFO || r->good <= 0)) {
>> ink_assert(!"bad round-robin");
>> return NULL;
>> }
>> @@ -2359,12 +2363,12 @@ struct ShowHostDB: public ShowCont
>> HostDBRoundRobin *rr_data = r->rr();
>> if (rr_data) {
>> CHECK_SHOW(show("<table border=1>\n"));
>> - CHECK_SHOW(show("<tr><td>%s</td><td>%d</td></tr>\n",
>> "Total", rr_data->n));
>> + CHECK_SHOW(show("<tr><td>%s</td><td>%d</td></tr>\n",
>> "Total", rr_data->rrcount));
>> CHECK_SHOW(show("<tr><td>%s</td><td>%d</td></tr>\n",
>> "Good", rr_data->good));
>> CHECK_SHOW(show("<tr><td>%s</td><td>%d</td></tr>\n",
>> "Current", rr_data->current));
>> CHECK_SHOW(show("</table>\n"));
>>
>> - for (int i = 0; i < rr_data->n; i++)
>> + for (int i = 0; i < rr_data->rrcount; i++)
>> showOne(&rr_data->info[i], true, event, e);
>> }
>> }
>
>
> This code (ugly mix of HTML and C) is surrounded by #ifdef NON_MODULAR
> which is #defined in lib/ts/ink_config.h if TS_HAS_STANDALONE_IOCORE
Sure, but it would be weird to not rename the variable in some of the places.
J
Re: git commit: TS-1851: Remove HostDBInfo constructor so it
becomes a POD
Posted by Igor Galić <i....@brainsware.org>.
----- Original Message -----
> Updated Branches:
> refs/heads/master bb2fcaad3 -> 2915206c7
>
>
> TS-1851: Remove HostDBInfo constructor so it becomes a POD
>
> Somewhere down the line HostDBInfo grew enough constructor complexity
> that it became a non-POD type. The allocation treats it like a POD
> type, so we should make sure that the compiler agrees.
>
> Rename HostDBRoundRobin::n to HostDBRoundRobin::rrcount. Remove
> unused HostDBInfo::set_from
[snip]
> Commit: 2915206c73f08dcb9d262dfa0f19967f20eaabdf
> Parents: bb2fcaa
[snip]
> http://git-wip-us.apache.org/repos/asf/trafficserver/blob/2915206c/iocore/hostdb/HostDB.cc
> ----------------------------------------------------------------------
> diff --git a/iocore/hostdb/HostDB.cc b/iocore/hostdb/HostDB.cc
> index 52075d6..6221885 100644
> --- a/iocore/hostdb/HostDB.cc
> +++ b/iocore/hostdb/HostDB.cc
[snip]
> @@ -2233,7 +2237,7 @@ HostDBInfo::rr()
>
> HostDBRoundRobin *r = (HostDBRoundRobin *)
> hostDB.ptr(&app.rr.offset, hostDB.ptr_to_partition((char *)
> this));
>
> - if (r && (r->n > HOST_DB_MAX_ROUND_ROBIN_INFO || r->n <= 0 ||
> r->good > HOST_DB_MAX_ROUND_ROBIN_INFO || r->good <= 0)) {
> + if (r && (r->rrcount > HOST_DB_MAX_ROUND_ROBIN_INFO || r->rrcount
> <= 0 || r->good > HOST_DB_MAX_ROUND_ROBIN_INFO || r->good <= 0)) {
> ink_assert(!"bad round-robin");
> return NULL;
> }
> @@ -2359,12 +2363,12 @@ struct ShowHostDB: public ShowCont
> HostDBRoundRobin *rr_data = r->rr();
> if (rr_data) {
> CHECK_SHOW(show("<table border=1>\n"));
> - CHECK_SHOW(show("<tr><td>%s</td><td>%d</td></tr>\n",
> "Total", rr_data->n));
> + CHECK_SHOW(show("<tr><td>%s</td><td>%d</td></tr>\n",
> "Total", rr_data->rrcount));
> CHECK_SHOW(show("<tr><td>%s</td><td>%d</td></tr>\n",
> "Good", rr_data->good));
> CHECK_SHOW(show("<tr><td>%s</td><td>%d</td></tr>\n",
> "Current", rr_data->current));
> CHECK_SHOW(show("</table>\n"));
>
> - for (int i = 0; i < rr_data->n; i++)
> + for (int i = 0; i < rr_data->rrcount; i++)
> showOne(&rr_data->info[i], true, event, e);
> }
> }
This code (ugly mix of HTML and C) is surrounded by #ifdef NON_MODULAR
which is #defined in lib/ts/ink_config.h if TS_HAS_STANDALONE_IOCORE
--
Igor Galić
Tel: +43 (0) 664 886 22 883
Mail: i.galic@brainsware.org
URL: http://brainsware.org/
GPG: 6880 4155 74BD FD7C B515 2EA5 4B1D 9E08 A097 C9AE