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 2016/05/11 20:31:51 UTC
[trafficserver] 27/33: TS-4425: Switch iocore/hostdb and
iocore/utils to Ptr::get().
This is an automated email from the ASF dual-hosted git repository.
jpeach pushed a commit to branch master
in repository https://git-dual.apache.org/repos/asf/trafficserver.git
commit 23cb70f2db31026541705d635df243545212dfb7
Author: James Peach <jp...@apache.org>
AuthorDate: Sat May 7 13:32:30 2016 -0700
TS-4425: Switch iocore/hostdb and iocore/utils to Ptr::get().
---
iocore/hostdb/HostDB.cc | 25 ++++++++++---------------
iocore/hostdb/MultiCache.cc | 4 ++--
iocore/hostdb/P_MultiCache.h | 3 ++-
iocore/utils/OneWayMultiTunnel.cc | 4 ++--
iocore/utils/OneWayTunnel.cc | 8 ++++----
5 files changed, 20 insertions(+), 24 deletions(-)
diff --git a/iocore/hostdb/HostDB.cc b/iocore/hostdb/HostDB.cc
index b83ddff..2eabe2a 100644
--- a/iocore/hostdb/HostDB.cc
+++ b/iocore/hostdb/HostDB.cc
@@ -565,8 +565,9 @@ HostDBContinuation::refresh_MD5()
md5.refresh();
// Update the mutex if it's from the bucket.
// Some call sites modify this after calling @c init so need to check.
- if (old_bucket_mutex == mutex)
+ if (mutex.get() == old_bucket_mutex) {
mutex = hostDB.lock_for_bucket((int)(fold_md5(md5.hash) % hostDB.buckets));
+ }
}
static bool
@@ -1141,7 +1142,7 @@ HostDBProcessor::setby_srv(const char *hostname, int len, const char *target, Ho
int
HostDBContinuation::setbyEvent(int /* event ATS_UNUSED */, Event * /* e ATS_UNUSED */)
{
- HostDBInfo *r = probe(mutex, md5, false);
+ HostDBInfo *r = probe(mutex.get(), md5, false);
if (r)
do_setby(r, &app, md5.host_name, md5.ip, is_srv());
@@ -1232,7 +1233,7 @@ HostDBContinuation::removeEvent(int /* event ATS_UNUSED */, Event *e)
{
Continuation *cont = action.continuation;
- MUTEX_TRY_LOCK(lock, cont ? (ProxyMutex *)cont->mutex : (ProxyMutex *)NULL, e->ethread);
+ MUTEX_TRY_LOCK(lock, cont ? cont->mutex.get() : (ProxyMutex *)NULL, e->ethread);
if (!lock.is_locked()) {
e->schedule_in(HOST_DB_RETRY_PERIOD);
return EVENT_CONT;
@@ -1242,7 +1243,7 @@ HostDBContinuation::removeEvent(int /* event ATS_UNUSED */, Event *e)
if (cont)
cont->handleEvent(EVENT_HOST_DB_IP_REMOVED, (void *)NULL);
} else {
- HostDBInfo *r = probe(mutex, md5, false);
+ HostDBInfo *r = probe(mutex.get(), md5, false);
bool res = (remove_round_robin(r, md5.host_name, md5.ip) ? true : false);
if (cont)
cont->handleEvent(EVENT_HOST_DB_IP_REMOVED, res ? static_cast<void *>(&md5.ip) : static_cast<void *>(NULL));
@@ -1455,7 +1456,7 @@ HostDBContinuation::dnsEvent(int event, HostEnt *e)
ttl = failed ? 0 : e->ttl / 60;
int ttl_seconds = failed ? 0 : e->ttl; // ebalsa: moving to second accuracy
- HostDBInfo *old_r = probe(mutex, md5, true);
+ HostDBInfo *old_r = probe(mutex.get(), md5, true);
HostDBInfo old_info;
if (old_r)
old_info = *old_r;
@@ -1912,7 +1913,7 @@ HostDBContinuation::probeEvent(int /* event ATS_UNUSED */, Event *e)
if (!force_dns) {
// Do the probe
//
- HostDBInfo *r = probe(mutex, md5, false);
+ HostDBInfo *r = probe(mutex.get(), md5, false);
if (r)
HOSTDB_INCREMENT_DYN_STAT(hostdb_total_hits_stat);
@@ -2794,18 +2795,12 @@ HostDBFileContinuation::destroy()
// globals.
int HostDBFileUpdateActive = 0;
-// Actual ordering doesn't matter as long as it's consistent.
-bool
-CmpMD5(INK_MD5 const &lhs, INK_MD5 const &rhs)
-{
- return lhs[0] < rhs[0] || (lhs[0] == rhs[0] && lhs[1] < rhs[1]);
-}
-
-void
-ParseHostLine(RefCountedHostsFileMap *map, char *l)
+static void
+ParseHostLine(Ptr<RefCountedHostsFileMap> &map, char *l)
{
Tokenizer elts(" \t");
int n_elts = elts.Initialize(l, SHARE_TOKS);
+
// Elements should be the address then a list of host names.
// Don't use RecHttpLoadIp because the address *must* be literal.
IpAddr ip;
diff --git a/iocore/hostdb/MultiCache.cc b/iocore/hostdb/MultiCache.cc
index 2e6951a..a3201a1 100644
--- a/iocore/hostdb/MultiCache.cc
+++ b/iocore/hostdb/MultiCache.cc
@@ -1046,7 +1046,7 @@ struct MultiCacheSync : public Continuation {
}
MultiCacheSync(Continuation *acont, MultiCacheBase *amc)
- : Continuation(amc->locks[0]), partition(0), mc(amc), cont(acont), before_used(0)
+ : Continuation(amc->locks[0].get()), partition(0), mc(amc), cont(acont), before_used(0)
{
mutex = mc->locks[partition];
SET_HANDLER((MCacheSyncHandler)&MultiCacheSync::heapEvent);
@@ -1159,7 +1159,7 @@ struct MultiCacheHeapGC : public Continuation {
}
MultiCacheHeapGC(Continuation *acont, MultiCacheBase *amc)
- : Continuation(amc->locks[0]), cont(acont), mc(amc), partition(0), n_offsets(0)
+ : Continuation(amc->locks[0].get()), cont(acont), mc(amc), partition(0), n_offsets(0)
{
SET_HANDLER((MCacheHeapGCHandler)&MultiCacheHeapGC::startEvent);
offset_table = (OffsetTable *)ats_malloc(sizeof(OffsetTable) *
diff --git a/iocore/hostdb/P_MultiCache.h b/iocore/hostdb/P_MultiCache.h
index adc1ad3..b79f7f2 100644
--- a/iocore/hostdb/P_MultiCache.h
+++ b/iocore/hostdb/P_MultiCache.h
@@ -321,8 +321,9 @@ struct MultiCacheBase : public MultiCacheHeader {
ProxyMutex *
lock_for_bucket(int bucket)
{
- return locks[partition_of_bucket(bucket)];
+ return locks[partition_of_bucket(bucket)].get();
}
+
uint64_t
make_tag(uint64_t folded_md5)
{
diff --git a/iocore/utils/OneWayMultiTunnel.cc b/iocore/utils/OneWayMultiTunnel.cc
index fc28305..868a712 100644
--- a/iocore/utils/OneWayMultiTunnel.cc
+++ b/iocore/utils/OneWayMultiTunnel.cc
@@ -63,7 +63,7 @@ OneWayMultiTunnel::init(VConnection *vcSource, VConnection **vcTargets, int n_vc
bool aclose_targets, /* = false */
Transform_fn aManipulate_fn, int water_mark)
{
- mutex = aCont ? (ProxyMutex *)aCont->mutex : new_ProxyMutex();
+ mutex = aCont ? aCont->mutex : make_ptr(new_ProxyMutex());
cont = aCont;
manipulate_fn = aManipulate_fn;
close_source = aclose_source;
@@ -108,7 +108,7 @@ void
OneWayMultiTunnel::init(Continuation *aCont, VIO *SourceVio, VIO **TargetVios, int n_TargetVios, bool aclose_source,
bool aclose_targets)
{
- mutex = aCont ? (ProxyMutex *)aCont->mutex : new_ProxyMutex();
+ mutex = aCont ? aCont->mutex : make_ptr(new_ProxyMutex());
cont = aCont;
single_buffer = true;
manipulate_fn = 0;
diff --git a/iocore/utils/OneWayTunnel.cc b/iocore/utils/OneWayTunnel.cc
index d286a57..4e42eb6 100644
--- a/iocore/utils/OneWayTunnel.cc
+++ b/iocore/utils/OneWayTunnel.cc
@@ -107,7 +107,7 @@ OneWayTunnel::~OneWayTunnel()
}
OneWayTunnel::OneWayTunnel(Continuation *aCont, Transform_fn aManipulate_fn, bool aclose_source, bool aclose_target)
- : Continuation(aCont ? (ProxyMutex *)aCont->mutex : new_ProxyMutex()),
+ : Continuation(aCont ? aCont->mutex.get() : new_ProxyMutex()),
cont(aCont),
manipulate_fn(aManipulate_fn),
n_connections(2),
@@ -126,7 +126,7 @@ OneWayTunnel::init(VConnection *vcSource, VConnection *vcTarget, Continuation *a
int64_t nbytes, bool asingle_buffer, bool aclose_source, bool aclose_target, Transform_fn aManipulate_fn,
int water_mark)
{
- mutex = aCont ? (ProxyMutex *)aCont->mutex : (aMutex ? aMutex : new_ProxyMutex());
+ mutex = aCont ? aCont->mutex.get() : (aMutex ? aMutex : new_ProxyMutex());
cont = aMutex ? NULL : aCont;
single_buffer = asingle_buffer;
manipulate_fn = aManipulate_fn;
@@ -170,7 +170,7 @@ OneWayTunnel::init(VConnection *vcSource, VConnection *vcTarget, Continuation *a
bool aclose_source, bool aclose_target)
{
(void)vcSource;
- mutex = aCont ? (ProxyMutex *)aCont->mutex : new_ProxyMutex();
+ mutex = aCont ? aCont->mutex : make_ptr(new_ProxyMutex());
cont = aCont;
single_buffer = true;
manipulate_fn = 0;
@@ -196,7 +196,7 @@ OneWayTunnel::init(VConnection *vcSource, VConnection *vcTarget, Continuation *a
void
OneWayTunnel::init(Continuation *aCont, VIO *SourceVio, VIO *TargetVio, bool aclose_source, bool aclose_target)
{
- mutex = aCont ? (ProxyMutex *)aCont->mutex : new_ProxyMutex();
+ mutex = aCont ? aCont->mutex : make_ptr(new_ProxyMutex());
cont = aCont;
single_buffer = true;
manipulate_fn = 0;
--
To stop receiving notification emails like this one, please contact
"commits@trafficserver.apache.org" <co...@trafficserver.apache.org>.