Re: Fwd: unable to compile on freebsd
Alex Rousskov <[email protected]> Sun, 28 Aug 2016 18:52:35 -0600
| Newsgroups | gmane.comp.web.web-polygraph.user |
|---|---|
| Message-ID | <[email protected]> |
This is a multi-part message in MIME format.
--------------E6BF8415805B3E03934147DD
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
On 08/26/2016 09:19 AM, Charlie Younghusband wrote:
> I was looking to compile this on a modern FreeBSD machine, but it
> doesn't work. I got it working fine on an Ubuntu box for now, but
> advice for running on recent FreeBSD?
Hi Charlie,
This problem is not specific to FreeBSD. It is a clang compatibility
problem. You can probably build on FreeBSD using GCC instead.
The attached patch makes Polygraph v4.9.0 compile with clang in our
tests, but we have not tried doing that on FreeBSD yet.
Please let me know if the patch helps in your FreeBSD environment. You
should get two dynamic-class-memaccess warnings about memcpy(). We still
need to fix those.
Thank you,
Alex.
--------------E6BF8415805B3E03934147DD
Content-Type: text/x-diff;
name="clang-v4p9p0-t1.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="clang-v4p9p0-t1.patch"
Backported the following master changes to v4.9.0:
commit e893cb3
Made clang happier.
* error: unknown type name 'InAddress'
* -Wunused-function
Static operators in histogram.cc are superseded by OLog and ILog ones.
createInitiatorMaterial() forward declaration was out of sync.
* -Wunused-variable
commit b9e8e70
Made clang happier.
* -Wunused-private-field (includeProxies)
Removed AgentSymIter ability to include proxy "sides" in robots or
servers iteration. Our ProxySym no longer has "sides" so that feature
was most likely unused since that ProxySym change (dca30c9b28?).
commit a6aa8fd
Made clang happier.
* warning: using directive refers to implicitly-defined namespace 'std'
"using namespace std" requires explicit std use. Worked around by
always #including <limits>. TODO: Remove that using declaration
instead. Also removed repeated/duplicated using declarations under the
assumption that post-config.h is included everywhere.
* error: dependent using declaration resolved to type without 'typename'
A using declaration should use "typename" for dependent type names:
http://stackoverflow.com/questions/1071119/accessing-types-from-dependent-
* error: default argument on redeclaration
* -Wmismatched-tags (struct vs class)
TODO: Needs more work. These changes do not address all clang problems.
diff --git a/src/app/PolyApp.cc b/src/app/PolyApp.cc
index bad25aa..9684668 100644
--- a/src/app/PolyApp.cc
+++ b/src/app/PolyApp.cc
@@ -292,77 +292,77 @@ void PolyApp::configureLogs(int prec) {
void PolyApp::configureRnd() {
ThePersistWorkSetMgr.loadSeeds(); // must be called before seeds are used
// set random seeds
GlbPermut().reseed(TheOpts.theGlbRngSeed);
LclPermut().reseed(TheOpts.theLclRngSeed);
RndGen::DefSeed(LclPermut(TheOpts.theLclRngSeed));
// use the seed as uid "space" index for non-unique worlds
if (!TheOpts.useUniqueWorld)
UniqId::Space(TheOpts.theLclRngSeed);
TheGroupId = UniqId::Create();
ThePersistWorkSetMgr.configure(); // must be called after UniqId::Space()
}
// collect server configurations into TheHostMap
void PolyApp::configureHosts() {
TheAddrMap = new AddrMap();
TheAddrMap->configure(PglStaticSemx::TheAddrMapsToUse);
TheAddrSubsts = new AddrSubsts;
TheAddrSubsts->configure(PglStaticSemx::TheAddrSubstsToUse);
AgentSymIter::Agents &agents = PglStaticSemx::TheAgentsToUse;
// count the global number of servers for HostMap
// include AddrMap names in the count as we add them below
int srvCount = TheAddrMap->nameCount();
- for (AgentSymIter i(agents, ServerSym::TheType, true); i; ++i)
+ for (AgentSymIter i(agents, ServerSym::TheType); i; ++i)
srvCount += i.agent()->hostCount();
TheHostMap = new HostMap(srvCount);
// create selectors for each server configuration symbol
// note: we stretch for all agents, not just servers
// preset with nil pointers: proxies and robots have no ContentSel
theContentSels.resize(agents.count());
- for (AgentSymIter i(agents, ServerSym::TheType, false); i; ++i) {
+ for (AgentSymIter i(agents, ServerSym::TheType); i; ++i) {
ContentSel *sel = new ContentSel;
sel->configure(static_cast<const ServerSym*>(i.agent())); // XXX:cast()
theContentSels.put(sel, i.agentIdx());
}
// get client-side ContentCfg added
- for (AgentSymIter i(agents, RobotSym::TheType, false); i; ++i) {
+ for (AgentSymIter i(agents, RobotSym::TheType); i; ++i) {
const RobotSym *const clt =
&static_cast<const RobotSym&>(i.agent()->cast(RobotSym::TheType));
configureRobotContent(*clt, "post_contents");
configureRobotContent(*clt, "put_contents");
}
// assign content selectors to origin servers
// assign protocols and SSL wraps to servers, including proxies
int sslServerCount = 0;
Array<int> forAddrMap(srvCount);
for (AgentAddrIter i(agents, ServerSym::TheType); i; ++i) {
int idx = -1;
const NetAddr &host = i.address();
if (host.isDomainName()) {
cerr << here << "server address must be an IP, got: " <<
host << endl << xexit;
}
HostCfg *hostCfg = addToHostMap(host, idx);
if (ContentSel *sel = theContentSels[i.agentIdx()])
hostCfg->theContent = sel;
// will add host addresses by default, but do not mix find with add
if (!TheAddrMap->findAddr(host))
forAddrMap.append(idx);
const ServerSym *srv =
&static_cast<const ServerSym&>(i.agent()->cast(ServerSym::TheType));
@@ -630,61 +630,61 @@ void PolyApp::getHostAddrs(Array<NetAddr*> &hosts) const {
void PolyApp::getCpuCores(Array< Array<int> > &cpuCores) const {
if (PglStaticSemx::TheBench && PglStaticSemx::TheBench->side(sideName()))
PglStaticSemx::TheBench->side(sideName())->cpuCoresArray(cpuCores);
}
// Find unique IP addresses to avoid creation of duplicate aliases on different
// hosts when IPs are sliced: a,b,a,b must yield a|b IPs for a,a|b,b agents
// Skip addresses without ifnames: addrs are used for alias creation only
void PolyApp::getAgentAliasAddrs(AddrSyms &addrs) const {
Array<NetAddr> skipped;
std::auto_ptr<HostMap> skipped_map; // lookup table to weed out duplicates
Array<NetAddrSym *> bench_addrs;
std::auto_ptr<HostMap> bench_addrs_map; // lookup table to weed out duplicates
// use bench.side.addresses or collect from agents
if (PglStaticSemx::TheBench &&
PglStaticSemx::TheBench->side(sideName()) &&
PglStaticSemx::TheBench->side(sideName())->addresses(bench_addrs)) {
bench_addrs_map.reset(new HostMap(bench_addrs.count()));
skipped_map.reset(new HostMap(bench_addrs.count()));
// append unique IP addresses with ifnames only
for (int i = 0; i < bench_addrs.count(); ++i) {
addUniqueAddrs(&addrs, *bench_addrs[i], *bench_addrs_map,
skipped, *skipped_map);
}
}
// count all addresses to size the lookup table
int allCount = 0;
- for (AgentSymIter i(PglStaticSemx::TheAgentsToUse, theAgentType, true); i; ++i)
+ for (AgentSymIter i(PglStaticSemx::TheAgentsToUse, theAgentType); i; ++i)
allCount += i.agent()->hostCount();
// append unique IP addresses with ifnames only
HostMap agent_addrs_map(allCount); // lookup table to weed out duplicates
if (!skipped_map.get())
skipped_map.reset(new HostMap(allCount));
for (AgentAddrIter i(PglStaticSemx::TheAgentsToUse, theAgentType); i; ++i) {
addUniqueAddrs(bench_addrs_map.get() ? 0 : &addrs,
ConstSymCast(NetAddrSym, *i.addressSym()),
agent_addrs_map, skipped, *skipped_map);
}
if (bench_addrs_map.get()) {
allCount = bench_addrs.count();
// compare bench.side.addresses and agent addresses
const HostMap *a;
HostMap *b; // HostMap::find() is not const
String msg;
if (bench_addrs_map->hostCount() > agent_addrs_map.hostCount()) {
a = bench_addrs_map.get();
b = &agent_addrs_map;
msg = "bench.side.addresses address not used by any agent";
} else {
a = &agent_addrs_map;
b = bench_addrs_map.get();
msg = "agent address missing in bench.side.addresses";
}
for (int i = 0; i < a->iterationCount(); ++i) {
const HostCfg *const host = a->at(i);
@@ -823,61 +823,61 @@ void PolyApp::makeAgents() {
const bool thisHostNeedsExtra = TheOpts.theWorkerId <= hostsWithExtra;
const int hostsToTheLeft = TheOpts.theWorkerId - 1;
agentBegin = thisHostNeedsExtra ?
(hostsToTheLeft * (agentsPerHost + 1)) :
(hostsToTheLeft * agentsPerHost + hostsWithExtra);
agentEnd = agentBegin + agentsPerHost + (thisHostNeedsExtra ? 1 : 0);
} else {
Comment << "error: --worker value " << TheOpts.theWorkerId <<
" exceeds the number of local agents " << localAgents.count() <<
"; no agents will be started for this worker" << endc;
}
for (int agentIdx = agentBegin; agentIdx < agentEnd; ++agentIdx) {
makeAgent(*localAgents[agentIdx], *localAgentAddreses[agentIdx]);
Clock::Update(false);
if (TheClock.time() >= cfgNextReport) {
Comment(5) << "created " << setw(6) << theLocals.count() <<
" agents so far" << endc;
cfgNextReport = TheClock + cfgReportGap; // drift is OK
}
}
Clock::Update(false);
Comment(4) << "created " << theLocals.count() << " agents total" << endc;
if (!theLocals.count()) {
cerr << ThePrgName << ": no " << theAgentType
<< " matches local interface addresses" << endl;
ArraySym agentAddrs("addr");
- {for (AgentSymIter i(PglStaticSemx::TheAgentsToUse, theAgentType, false); i; ++i)
+ {for (AgentSymIter i(PglStaticSemx::TheAgentsToUse, theAgentType); i; ++i)
i.agent()->addresses(agentAddrs);
}
ArraySym localAddrs("addr");
localAddrs.reserve(theIfaces.count());
{for (int i = 0; i < theIfaces.count(); ++i) {
NetAddrSym s;
s.val(NetAddr(theIfaces[i], -1));
localAddrs.add(s);
}}
agentAddrs.print(cerr << agentAddrs.count() << ' ' << theAgentType << " addresses:", "");
cerr << endl;
localAddrs.print(cerr << localAddrs.count() << " local addresses: ", "");
cerr << endl;
cerr << xexit;
}
if (localCpuCores.count()) {
const int cpuCoresIndex = TheOpts.theWorkerId.wasSet() ? TheOpts.theWorkerId - 1 : 0;
if (cpuCoresIndex < 0 || cpuCoresIndex >= localCpuCores.count()) {
Comment(1) << "warning: --worker value " << TheOpts.theWorkerId <<
" exceeds the number of local hosts " << localCpuCores.count() <<
"; ignoring CPU affinity for this worker" << endc;
} else if (localCpuCores[cpuCoresIndex].count()) {
CpuAffinitySet cpuAffinitySet;
for (int i = 0; i < localCpuCores[cpuCoresIndex].count(); ++i)
cpuAffinitySet.reset(localCpuCores[cpuCoresIndex][i], true);
diff --git a/src/base/histograms.cc b/src/base/histograms.cc
index 071026f..d5131ae 100644
--- a/src/base/histograms.cc
+++ b/src/base/histograms.cc
@@ -64,73 +64,60 @@ int Log2Hist::val2Bin(Val v) const {
const int sbin_offset = (vo - min_val) >> p;
const int sbin = (p+1) << 8;
return sbin + sbin_offset;
} else
return vo;
}
Log2Hist::Val Log2Hist::bin2Val(int bin) const {
const int bino = bin;
if (bin >= 512) {
const int bin_offset = bin % 256;
const int sbin = bin - bin_offset;
const int p = sbin/256 - 1;
const int val_offset = bin_offset << p;
const int min_val = 1 << (8+p);
return min_val + val_offset;
} else
return bino;
}
/* TimeHist */
TimeHist::TimeHist(): theTmMax(Time::Msec(theValMax)) {
Assert(theTmMax > 0);
}
/* TimeVsSmthHist */
-static inline
-OLog &operator <<(OLog &log, const TimeHist *h) {
- Assert(h);
- return log << *h;
-}
-
-static inline
-ILog &operator >>(ILog &log, TimeHist *h) {
- Assert(h);
- return log >> *h;
-}
-
-
TimeVsSmthHist::TimeVsSmthHist(int aMaxSmth): theMaxSmth(aMaxSmth) {
}
TimeVsSmthHist::~TimeVsSmthHist() {
while (theHists.count()) delete theHists.pop();
}
void TimeVsSmthHist::resize(int maxGrp) {
Assert(!theHists.count());
Assert(maxGrp >= 0);
const int count = 1 + maxGrp;
theHists.stretch(count);
for (int i = 0; i < count; ++i)
theHists.append(new TimeHist);
}
OLog &TimeVsSmthHist::store(OLog &log) const {
return log << theMaxSmth << theHists;
}
ILog &TimeVsSmthHist::load(ILog &log) {
const int ms = log.geti();
Must(ms <= theMaxSmth);
theMaxSmth = ms;
return log >> theHists;
}
// log2 step except a special case of 100 bytes
// range must be checked in the caller
diff --git a/src/base/polygraph.h b/src/base/polygraph.h
index 5471e0a..66996b8 100644
--- a/src/base/polygraph.h
+++ b/src/base/polygraph.h
@@ -1,24 +1,22 @@
/* Web Polygraph http://www.web-polygraph.org/
* Copyright 2003-2011 The Measurement Factory
* Licensed under the Apache License, Version 2.0 */
#ifndef POLYGRAPH__BASE_POLYGRAPH_H
#define POLYGRAPH__BASE_POLYGRAPH_H
// polygraph.h file must be included by all source files
-using namespace std;
-
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "xstd/h/stdint.h"
#include "xstd/Time.h"
#include "xstd/Size.h"
#include "xstd/Assert.h"
typedef int64_t Counter;
#endif
diff --git a/src/client/SpnegoCodec.cc b/src/client/SpnegoCodec.cc
index 604f169..54c4292 100644
--- a/src/client/SpnegoCodec.cc
+++ b/src/client/SpnegoCodec.cc
@@ -25,126 +25,108 @@ typedef std::vector<std::string> Strings;
class ByteListReader;
class ByteBuffer;
enum spnego_flags {
CONSTRUCTED = 0x20,
APPLICATION = 0x40,
CONTEXT_SPECIFIC = 0x80,
BIT_STRING = 0x03,
OCTET_STRING = 0x04,
OID = 0x06,
ENUMERATED = 0x0a,
SEQUENCE = 0x10,
NEG_TOKEN_INIT = 0xa0 /* CONSTRUCTED | CONTEXT_SPECIFIC */ | 0x00,
NEG_TOKEN_TARG = 0xa0 /* CONSTRUCTED | CONTEXT_SPECIFIC */ | 0x01,
MECHANISM_TYPES = 0xa0 /* CONSTRUCTED | CONTEXT_SPECIFIC */ | 0x00,
REQUEST_FLAGS = 0xa0 /* CONSTRUCTED | CONTEXT_SPECIFIC */ | 0x01,
MECHANISM_MATERIAL = 0xa0 /* CONSTRUCTED | CONTEXT_SPECIFIC */ | 0x02,
MECHANISM_LIST_MIC = 0xa0 /* CONSTRUCTED | CONTEXT_SPECIFIC */ | 0x03,
RESULT = 0xa0 /* CONSTRUCTED | CONTEXT_SPECIFIC */ | 0x00,
MECHANISM = 0xa0 /* CONSTRUCTED | CONTEXT_SPECIFIC */ | 0x01
};
// returns either 0 or token type
// use this to confirm that we got InitToken
// in the first received message and NegToken
// in subsequent ones
int readTokenType(ByteListReader & in);
-// we probably won't need that unless we try
-// to "force" Negotiate/spnego by sending our
-// own InitToken.
-Bytes createInitiatorMaterial(
- const ByteListReader & mechanismMaterial,
- const std::vector < std::string > & mechanisms,
- const int flags,
- const Bytes & mic);
-
-// use it to encode subsequent responses.
-Bytes createTargetMaterial(
- const ByteListReader & mechanismMaterial,
- const std::string & mechanism,
- const int result,
- const Bytes & mic);
-
// parse InitToken, the first message in sequence.
// IN:
// in - contains the part spnego token after the part with token
// type (the position after the call to readTokenType)
// OUT:
// mechanismMaterial Data for preferred mechanism if applicable
// (usually kerberos data), otherwise empty.
// mechanisms List with OIDs of supported auth mechanisms
// in printable/readable form. Optional but
// usually present.
// flags Request flags. Typically ignored by spnego
// implementations. Optional.
// mic Mic value used to sign the list of supported
// auth methods. Optional.
// return value False if obvious errors were detected while
// parsing the source material, true otherwise.
bool readInitiatorToken(ByteListReader & in,
Bytes & mechanismMaterial,
Strings & mechanisms,
int & flags,
Bytes & mic);
// parse NegToken, second and al subsequent message in the sequence
// IN:
// in - contains the part spnego token after the part with token
// type (the position after the call to readTokenType)
// OUT:
// mechanismMaterial Data for chosen mechanism
// mechanism OID of chosen mechanism
// result Current state of negotiation.
// mic Mic value. Optional.
// return value False if obvious errors were detected while
// parsing the source material, true otherwise.
bool readTargetToken(ByteListReader & in,
Bytes & mechanismMaterial,
std::string & mechanism,
spnego_auth_result & result,
Bytes & mic);
Strings readMechanisms(ByteListReader & in);
// NOTE: request flags are usually ignored, we do that too
int readRequestFlags(ByteListReader & in);
spnego_auth_result readResult(ByteListReader & in);
Bytes readOctetString(ByteListReader & in);
Bytes readOID(ByteListReader & in);
-Bytes findOID(const Bytes & material);
std::string createMechanism(const Bytes & oid);
Bytes createOID(const std::string & mechanism);
-Bytes createFlags(int flags);
Bytes createHeader(const unsigned char type, const int length);
unsigned int readLength(ByteListReader & in);
// start of helper class and function implementations
class ByteListReader
{
private:
// current position in reader
unsigned int pos;
// reference to vector with data (if initialized with vector)
const Bytes * pvBytes;
// pointer to the beginning of char array (if initialized with pointer)
const char * pBytes;
// size of vector/array
unsigned int size;
public:
ByteListReader(const Bytes & bv)
: pos(0), pvBytes(&bv), pBytes(0), size(bv.size())
{}
;
ByteListReader(const char * ba, unsigned int asize)
: pos(0), pvBytes(0), pBytes(ba), size(asize)
{}
;
int read()
{
@@ -215,135 +197,62 @@ private:
int readTokenType(ByteListReader & in)
{
if (in.read() == (CONSTRUCTED | APPLICATION))
{
readLength(in);
if (in.read() != OID)
{
// log error no object identifier
return 0;
}
readLength(in);
if (createOID(GSSOID_SPNEGO_MECHANISM) != readOID(in))
{
// log error Not SPNEGO material.
return 0;
}
}
int val = in.read();
if (val == NEG_TOKEN_INIT || val == NEG_TOKEN_TARG)
{
return val;
}
// log error Unknown material type
return 0;
}
-Bytes createInitiatorMaterial(
- const Bytes & mechanismMaterial,
- const Strings & mechanisms,
- const int flags,
- const Bytes & mic)
-{
- ByteBuffer buff;
- int length = 0;
- Bytes bytes;
- length = mic.size();
- if (length)
- {
- buff.put(mic);
- bytes = createHeader(OCTET_STRING, length);
- buff.put(bytes);
- buff.put(createHeader(MECHANISM_LIST_MIC, length + bytes.size()));
- }
- length = mechanismMaterial.size();
- if (length)
- {
- buff.put(mechanismMaterial);
- bytes = createHeader(OCTET_STRING, length);
- buff.put(bytes);
- buff.put(createHeader(MECHANISM_MATERIAL, length + bytes.size()));
- }
- if (flags)
- {
- bytes = createFlags(flags);
- buff.put(bytes);
- length = bytes.size();
- bytes = createHeader(BIT_STRING, length);
- buff.put(bytes);
- buff.put(createHeader(REQUEST_FLAGS, length + bytes.size()));
- }
- length = 0;
- if (mechanismMaterial.size())
- {
- bytes = findOID(mechanismMaterial);
- if (mechanisms.size())
- {
- for (int i = mechanisms.size() - 1; i >= 0; i--)
- {
- Bytes oid = createOID(mechanisms[i]);
- if (bytes != oid)
- {
- buff.put(oid);
- length += oid.size();
- oid = createHeader(OID, oid.size());
- buff.put(oid);
- length += oid.size();
- }
- }
- }
- if (bytes.size())
- {
- buff.put(bytes);
- length += bytes.size();
- bytes = createHeader(OID, bytes.size());
- buff.put(bytes);
- length += bytes.size();
- }
- bytes = createHeader(CONSTRUCTED | SEQUENCE, length);
- buff.put(bytes);
- buff.put(createHeader(MECHANISM_TYPES, bytes.size() + length));
- }
- buff.put(createHeader(CONSTRUCTED | SEQUENCE, buff.size()));
- buff.put(createHeader(NEG_TOKEN_INIT, buff.size()));
- Bytes spnego_oid = createOID(GSSOID_SPNEGO_MECHANISM);
- buff.put(spnego_oid);
- buff.put(createHeader(OID, spnego_oid.size()));
- buff.put(createHeader(CONSTRUCTED | APPLICATION, buff.size()));
- return buff.get();
-}
-
// use it to encode subsequent responses.
+static
Bytes createTargetMaterial(
const Bytes & mechanismMaterial,
const std::string & mechanism,
const int result,
const Bytes & mic)
{
ByteBuffer buff;
int length = 0;
Bytes bytes;
if (mic.size())
{
buff.put(mic);
length = mic.size();
bytes = createHeader(OCTET_STRING, length);
buff.put(bytes);
buff.put(createHeader(MECHANISM_LIST_MIC, length + bytes.size()));
}
if (mechanismMaterial.size())
{
buff.put(mechanismMaterial);
length = mechanismMaterial.size();
bytes = createHeader(OCTET_STRING, length);
buff.put(bytes);
buff.put(createHeader(MECHANISM_MATERIAL, length + bytes.size()));
}
bytes = createOID(mechanism);
if (bytes.size())
{
buff.put(bytes);
length = bytes.size();
@@ -560,85 +469,60 @@ Bytes readOctetString(ByteListReader & in)
{
// log error not an octet string
return bytes;
}
unsigned int length = readLength(in);
in.read(bytes, length);
if (length != bytes.size())
{
// log error premature end of content
}
return bytes;
}
Bytes readOID(ByteListReader & in)
{
Bytes bytes;
if (in.read() != OID)
{
// log error
return bytes;
}
unsigned int length = readLength(in);
in.read(bytes, length);
if(bytes.size() != length)
{
// log error
}
return bytes;
}
-Bytes findOID(const Bytes & material)
-{
- Bytes bytes;
- ByteListReader in (material);
- if (in.read() != (CONSTRUCTED | APPLICATION))
- {
- // log error here
- return bytes;
- }
- readLength(in);
-
- if (in.read() != OID)
- {
- // log error
- return bytes;
- }
- unsigned int length = readLength(in);
- in.read(bytes,length);
- if(bytes.size() != length)
- {
- // log error
- }
- return bytes;
-}
-
std::string createMechanism(const Bytes & oid)
{
if (oid.size() == 0)
{
// log error
return "";
}
std::ostringstream oss;
unsigned char value = oid[0];
oss << (value / 40) << "." << (value % 40);
int oid_size = oid.size();
for (int i = 1; i < oid_size; i++)
{
value = 0;
do
{
value = (value << 7) | (oid[i] & 0x7f);
}
while ((oid[i++] & 0x80) && i < oid_size);
oss << "." << value;
}
return oss.str();
}
static int dottedAtoi(const char* & str)
{
int value = 0;
while (*str && *str != '.')
{
value = 10 * value + (*str - '0');
@@ -650,71 +534,60 @@ static int dottedAtoi(const char* & str)
}
return value;
}
Bytes createOID(const std::string & mechanism)
{
Bytes bytes;
const char* str = mechanism.c_str();
int value;
// byte 1 is (40 * first component) + second component
value = dottedAtoi(str);
bytes.push_back((40 * value) + dottedAtoi(str));
// rest of bytes are base-128 representation of each component
// high bit set for all but the last byte of each block
while(*str)
{
value = dottedAtoi(str);
bytes.push_back(value & 0x7f);
value >>= 7;
Bytes :: iterator it = bytes.end();
--it;
while (value != 0)
{
it = bytes.insert(it, (value & 0x7f) | 0x80);
value >>= 7;
}
}
return bytes;
}
-Bytes createFlags(int flags)
-{
-
- // DER-encoded bit string; we know a zero will need to be right-padded.
- Bytes bytes;
- flags <<= 1;
- bytes.push_back(1);
- bytes.push_back((char) (flags & 0x0ff));
- return bytes;
-}
-
Bytes createHeader(const unsigned char type, const int length)
{
Bytes header;
header.push_back(type);
if (length < 0x80)
{
header.push_back((char)(length & 0x7f));
}
else
{
int rest = length;
header.push_back(2); // number of bytes for length
header.push_back(0); // zero byte at the beginning
header.push_back((char)(rest & 0xff));
Bytes :: iterator it = header.end();
--it;
rest >>= 8;
while(rest != 0)
{
it = header.insert(it, (char)(rest & 0xff));
rest >>= 8;
header[1]++;
}
header[1] |= 0x80;
}
return header;
}
unsigned int readLength(ByteListReader & in)
{
diff --git a/src/client/pgl2ldif.cc b/src/client/pgl2ldif.cc
index 5214a4f..9b046ff 100644
--- a/src/client/pgl2ldif.cc
+++ b/src/client/pgl2ldif.cc
@@ -315,58 +315,58 @@ int main(int argc, char **argv) {
LdifTemplate *tmp = new LdifTemplate();
tmp->load(f);
if (!tmp->empty())
templates.append(tmp);
}
logStats("templates", templates.count());
if (!templates.count())
cerr << TheOpts.theTemplate << ": warning: no templates found" << endl;
// parse PGL
TheOpts.theCfgDirs.copy(PglPp::TheDirs);
PglStaticSemx::Interpret(TheOpts.theCfgName);
logStats("use()d MembershipMaps", PglStaticSemx::TheMembershipsToUse.count());
if (!PglStaticSemx::TheMembershipsToUse.count())
cerr << TheOpts.theCfgName << ": warning: no MembershipMaps use()d" << endl;
long groupSpace = 0;
long userSpace = 0;
for (int i = 0; i < PglStaticSemx::TheMembershipsToUse.count(); ++i) {
MembershipMap *g = new MembershipMap;
g->configure(*PglStaticSemx::TheMembershipsToUse[i], i+1);
groupSpace += g->groupNameCount();
userSpace += g->userNameCount();
TheMemberships.append(g);
}
logStats("possible user group names", groupSpace);
logStats("possible user credentials", userSpace);
- for (AgentSymIter u(PglStaticSemx::TheAgentsToUse, RobotSym::TheType, false); u; ++u) {
+ for (AgentSymIter u(PglStaticSemx::TheAgentsToUse, RobotSym::TheType); u; ++u) {
const RobotSym &r = (const RobotSym&)u.agent()->cast(RobotSym::TheType);
Array<String*> creds;
r.credentials(creds);
for (int c = 0; c < creds.count(); ++c) {
TheCredentials.append(new UserCred(*creds[c]));
}
}
logStats("user credentials", TheCredentials.count());
for (int g = 0; g < TheMemberships.count(); ++g) {
TheMemberships[g]->collectUsedGroupNames(TheCredentials,
TheUsedUserGroupNames);
}
logStats("user groups", TheUsedUserGroupNames.count());
//logStats("mean groups per user", TheUsedUserGroupNames.count()/(double)TheCredentials.count());
//logStats("mean users per group", TheCredentials.count()/(double)TheUsedUserGroupNames.count());
for (int t = 0; t < templates.count(); ++t)
step(*templates[t]);
logStats("instantiated templates", TheInstantiatedTemplatesCount);
// cleanup
while (templates.count()) delete templates.pop();
while (TheUsedUserGroupNames.count()) delete TheUsedUserGroupNames.pop();
return 0;
}
diff --git a/src/pgl/AgentAddrIter.cc b/src/pgl/AgentAddrIter.cc
index 94b8e44..0e6b4c3 100644
--- a/src/pgl/AgentAddrIter.cc
+++ b/src/pgl/AgentAddrIter.cc
@@ -1,52 +1,52 @@
/* Web Polygraph http://www.web-polygraph.org/
* Copyright 2003-2011 The Measurement Factory
* Licensed under the Apache License, Version 2.0 */
#include "pgl/pgl.h"
#include "pgl/AgentAddrIter.h"
#include "pgl/AgentSym.h"
#include "pgl/PglArraySym.h"
#include "pgl/PglNetAddrSym.h"
class AddrCollector: public ContainerSym::Visitor {
public:
AddrCollector(AgentAddrIter::Addresses &aStore);
virtual void visit(const SynSym &item);
AgentAddrIter::Addresses &theStore;
};
AgentAddrIter::AgentAddrIter(AgentSymIter::Agents &agents, const String &agentType):
- theSymIter(agents, agentType, true), theAddrPos(0) {
+ theSymIter(agents, agentType), theAddrPos(0) {
sync();
}
AgentAddrIter::~AgentAddrIter() {
resetAddresses();
}
bool AgentAddrIter::eof() const {
return !theSymIter;
}
AgentAddrIter::operator void *() const {
return !eof() ? (void*)(-1) : 0;
}
AgentAddrIter &AgentAddrIter::operator ++() {
theAddrPos++;
sync();
return *this;
}
const NetAddr &AgentAddrIter::address() const {
Assert(!eof());
return theAddr;
}
const NetAddrSym *AgentAddrIter::addressSym() const {
Assert(!eof());
return theAddresses.item(theAddrPos);
}
diff --git a/src/pgl/AgentSymIter.cc b/src/pgl/AgentSymIter.cc
index 6d6ccec..2cd02e5 100644
--- a/src/pgl/AgentSymIter.cc
+++ b/src/pgl/AgentSymIter.cc
@@ -1,41 +1,39 @@
/* Web Polygraph http://www.web-polygraph.org/
* Copyright 2003-2011 The Measurement Factory
* Licensed under the Apache License, Version 2.0 */
#include "pgl/pgl.h"
#include "pgl/AgentSymIter.h"
#include "pgl/AgentSym.h"
#include "pgl/ProxySym.h"
-AgentSymIter::AgentSymIter(Agents &anAgents, const String &anAgentType, bool doIncludeProxies):
+AgentSymIter::AgentSymIter(Agents &anAgents, const String &anAgentType):
theAgents(anAgents), theAgentType(anAgentType),
- includeProxies(doIncludeProxies), isAgentInProxy(false),
thePos(0) {
sync();
}
AgentSymIter::~AgentSymIter() {
}
AgentSymIter::operator void *() const {
return (thePos < theAgents.count()) ? (void*)(-1) : 0;
}
AgentSymIter &AgentSymIter::operator ++() {
thePos++;
sync();
return *this;
}
// must be called after a cfg index change
void AgentSymIter::sync() {
- isAgentInProxy = false;
for (; thePos < theAgents.count(); ++thePos) {
const AgentSym *agent = theAgents[thePos];
if (agent->isA(theAgentType))
return;
}
}
diff --git a/src/pgl/AgentSymIter.h b/src/pgl/AgentSymIter.h
index 8fd3185..69f9b85 100644
--- a/src/pgl/AgentSymIter.h
+++ b/src/pgl/AgentSymIter.h
@@ -1,46 +1,41 @@
/* Web Polygraph http://www.web-polygraph.org/
* Copyright 2003-2011 The Measurement Factory
* Licensed under the Apache License, Version 2.0 */
#ifndef POLYGRAPH__PGL_AGENTITER_H
#define POLYGRAPH__PGL_AGENTITER_H
#include "xstd/Array.h"
#include "xstd/NetAddr.h"
class AgentSym;
// Iterates Agent configurations of the matching Agent type,
// optionally including matching right proxy-side configurations
class AgentSymIter {
public:
typedef Array<AgentSym*> Agents;
public:
- AgentSymIter(Agents &, const String &anAgentType, bool doIncludeProxies);
+ AgentSymIter(Agents &, const String &anAgentType);
~AgentSymIter();
//bool eof() const;
operator void *() const;
AgentSymIter &operator ++(); // next agent
const AgentSym *agent() const { return theAgents[thePos]; }
int agentIdx() const { return thePos; }
- bool agentInProxy() const { return isAgentInProxy; }
protected:
void sync();
private:
Agents &theAgents; // all agents, matching or not
String theAgentType; // matching agent type
- bool includeProxies; // whether to include matching proxy side
-
- bool isAgentInProxy; // whether agent() represents a proxy side
int thePos; // current iteration offset
-
};
#endif
diff --git a/src/pgl/PglIntSym.cc b/src/pgl/PglIntSym.cc
index 13ef1e7..89e41cc 100644
--- a/src/pgl/PglIntSym.cc
+++ b/src/pgl/PglIntSym.cc
@@ -1,57 +1,57 @@
/* Web Polygraph http://www.web-polygraph.org/
* Copyright 2003-2011 The Measurement Factory
* Licensed under the Apache License, Version 2.0 */
#include "pgl/pgl.h"
#include "xstd/h/math.h"
#include <limits.h>
#include "pgl/PglBoolSym.h"
#include "pgl/PglNumSym.h"
#include "pgl/PglTimeSym.h"
#include "pgl/PglSizeSym.h"
#include "pgl/PglRateSym.h"
#include "pgl/PglBwidthSym.h"
#include "pgl/PglDistrSym.h"
#include "pgl/PglArraySym.h"
#include "pgl/PglIntSym.h"
#include "xstd/gadgets.h"
String IntSym::TheType = "int";
-IntSym::IntSym(const Value aVal = -1): ExpressionSym(TheType), theVal(aVal) {
+IntSym::IntSym(const Value aVal): ExpressionSym(TheType), theVal(aVal) {
}
bool IntSym::isA(const String &type) const {
return ExpressionSym::isA(type) || type == TheType;
}
SynSym *IntSym::dupe(const String &type) const {
if (isA(type))
return new IntSym(theVal);
if (type == "float")
return new NumSym(theVal);
if (type == BoolSym::TheType)
return new BoolSym(theVal != 0);
// zero is zero regardless of strScale
if (!theVal) {
if (type == TimeSym::TheType)
return new TimeSym(Time(0,0));
if (type == SizeSym::TheType)
return new SizeSym(BigSize(0));
if (type == RateSym::TheType)
return new RateSym(0);
if (type == BwidthSym::TheType)
return new BwidthSym(0);
if (type.str("_distr"))
return new DistrSym(type, 0);
}
diff --git a/src/pgl/PglNetAddrRange.h b/src/pgl/PglNetAddrRange.h
index 65356ae..d0b4afb 100644
--- a/src/pgl/PglNetAddrRange.h
+++ b/src/pgl/PglNetAddrRange.h
@@ -1,48 +1,49 @@
/* Web Polygraph http://www.web-polygraph.org/
* Copyright 2003-2011 The Measurement Factory
* Licensed under the Apache License, Version 2.0 */
#ifndef POLYGRAPH__PGL_PGLNETADDRRANGE_H
#define POLYGRAPH__PGL_PGLNETADDRRANGE_H
#include "pgl/PglStrRange.h"
+class InAddress;
class NetAddr;
class NetAddrSym;
class PglNetAddrRange: public PglStrRange {
public:
typedef void (*AddrIter)(const NetAddr &);
public:
PglNetAddrRange();
virtual void reset();
// use subnet specs or guess an approprite netmask for the range
- void netmask(struct InAddress &pin) const;
+ void netmask(InAddress &pin) const;
virtual ArraySym *toSyms(const TokenLoc &loc) const;
void toAddrs(Array<NetAddr*> &addrs) const;
void toAddrs(AddrIter iter) const;
void addrAt(int idx, NetAddrSym &nas) const;
virtual bool parse(const String &val);
virtual ostream &print(ostream &os) const;
protected:
virtual bool canMergeSameType(const StringArrayBlock &b) const;
virtual void mergeSameType(const StringArrayBlock &b);
virtual bool optRangeBeg(char ch) const;
void currentAddrSym(NetAddrSym &nas) const;
void currentNetAddr(NetAddr &addr) const;
protected:
String theIfName; // interface name
String theAddr; // address:port
int theSubnet; // subnet specs
};
#endif
diff --git a/src/pgl/pgl.h b/src/pgl/pgl.h
index 05d42d4..5c99bc8 100644
--- a/src/pgl/pgl.h
+++ b/src/pgl/pgl.h
@@ -1,20 +1,18 @@
/* Web Polygraph http://www.web-polygraph.org/
* Copyright 2003-2011 The Measurement Factory
* Licensed under the Apache License, Version 2.0 */
#ifndef POLYGRAPH__PGL_PGL_H
#define POLYGRAPH__PGL_PGL_H
-using namespace std;
-
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "xstd/h/iostream.h"
#include "xstd/String.h"
#include "xparser/xparser.h"
#endif
diff --git a/src/pgl/pgl2acl.cc b/src/pgl/pgl2acl.cc
index 4b15700..f7f7505 100644
--- a/src/pgl/pgl2acl.cc
+++ b/src/pgl/pgl2acl.cc
@@ -715,61 +715,61 @@ void Normalizer::run() {
}
default:
Assert(false);
}
}
static
void normalizeRules(AclRule::Action action, const RegExExpr &expr, Rules &rules) {
Normalizer n(action, expr, rules);
n.run();
}
int main(int argc, char **argv) {
CmdLine cmd;
cmd.configure(Array<OptGrp*>() << &TheOpts);
if (!cmd.parse(argc, argv) || !TheOpts.validate())
return -1;
configureStream(cout, 2);
configureStream(clog, 3);
GlbPermut().reseed(TheOpts.theGlbRngSeed);
clog << argv[0] << ": parsing..." << endl;
TheOpts.theCfgDirs.copy(PglPp::TheDirs);
PglStaticSemx::Interpret(TheOpts.theCfgName);
clog << argv[0] << ": collecting rules..." << endl;
// collect all rules
Rules rules;
- for (AgentSymIter ai(PglStaticSemx::TheAgentsToUse, RobotSym::TheType, false); ai; ++ai) {
+ for (AgentSymIter ai(PglStaticSemx::TheAgentsToUse, RobotSym::TheType); ai; ++ai) {
const RobotSym &robot = (const RobotSym&)*ai.agent();
if (AclSym *acl = robot.acl()) {
if (acl->allow())
normalizeRules(AclRule::rlAllow, *acl->allow(), rules);
if (acl->deny())
normalizeRules(AclRule::rlDeny, *acl->deny(), rules);
if (acl->rewrite())
normalizeRules(AclRule::rlRewrite, *acl->rewrite(), rules);
}
}
// collect all groups
//for (int i = 0; i < PglSemx::TheUserGroupsToUse; ++i)
// TheGroups.append(PglSemx::TheUserGroupsToUse[i]);
clog << argv[0] << ": pruning " << rules.count() << " rules ..." << endl;
rules.prune();
// check for conflicts
// check for coverage (holes)
clog << argv[0] << ": sorting " << rules.count() << " rules ..." << endl;
rules.sort();
clog << argv[0] << ": simplifying..." << endl;
rules.simplify(); // prune based on order
clog << argv[0] << ": printing " << rules.count() << " rules ..." << endl;
rules.print(cout);
return 0;
diff --git a/src/pgl/pgl2eng.cc b/src/pgl/pgl2eng.cc
index 4b1d9a4..0d70a96 100644
--- a/src/pgl/pgl2eng.cc
+++ b/src/pgl/pgl2eng.cc
@@ -398,61 +398,61 @@ void explainServer(XmlTag §, const ServerSym &srv) {
addAnd(p.buf(), i, dacfgs.count());
p.buf() << '"' << dacfgs[i]->kind() << '"';
}
p.buf() << ". ";
} else {
p.buf() << "No hosted content can be accessed direclty. ";
}
if (RndDistr *xt = srv.xactThink()) {
p.buf() << "Server \"think time\" distribution is set to ";
xt->print(p.buf(), &DistrSym::TimeArgPrinter) << ". ";
} else {
p.buf() << "The server responds to all requests without"
<< " artificial delays. ";
}
XmlNodes code;
explainAgent(code, srv, "server");
explainMsgTypes(code, srv, "reply");
p << code;
sect << p;
}
static
void explainServers(XmlNodes &code, const PglParser &) {
XmlSection sect(2, "Servers configuration");
Array<const ServerSym *> servers;
- for (AgentSymIter i(PglStaticSemx::TheAgentsToUse, "Server", false); i; ++i)
+ for (AgentSymIter i(PglStaticSemx::TheAgentsToUse, "Server"); i; ++i)
servers.append(&(ServerSym&)i.agent()->cast("Server"));
if (servers.count()) {
XmlTextTag<XmlParagraph> p;
p.buf() << "The workload defines " << servers.count() << " server ";
addOneOrMany(p.buf(), servers.count(), "type") << ". ";
sect << p;
for (int i = 0; i < servers.count(); ++i) {
explainServer(sect, *servers[i]);
}
} else {
XmlTextTag<XmlParagraph> p;
p.buf() << "The workload does not use any servers. ";
sect << p;
}
code << sect;
}
static
void explainInterests(XmlNodes &code, const RobotSym &robot) {
XmlText t;
Array<StringSym*> interests;
Array<double> iprobs;
if (robot.interests(interests, iprobs)) {
t.buf() << "The robot is interested in the following "
<< interests.count() << " object groups: ";
for (int i = 0; i < interests.count(); ++i) {
@@ -548,61 +548,61 @@ void explainRobot(XmlTag §, const RobotSym &rbt) {
explainAgent(code, rbt, "robot");
explainInterests(code, rbt);
explainMsgTypes(code, rbt, "request");
p2 << code;
sect << p2;
XmlTextTag<XmlParagraph> p3;
if (PopModelSym *pm = rbt.popModel()) {
const PopDistr *pd = pm->popDistr();
double hotSetFrac;
double hotSetProb;
if (pd && pm->hotSetFrac(hotSetFrac) && pm->hotSetProb(hotSetProb)) {
p3.buf() << "\"" << rbt.kind() << "\" robots direct "
<< (100*hotSetProb) << "% of all requests to "
<< (100*hotSetFrac) << "% of the working set, using ";
pd->print(p3.buf()) << " popularity distribution. ";
}
}
sect << p3;
}
static
void explainRobots(XmlNodes &code, const PglParser &) {
XmlSection sect(2, "Robots configuration");
Array<const RobotSym *> robots;
- for (AgentSymIter i(PglStaticSemx::TheAgentsToUse, RobotSym::TheType, false); i; ++i)
+ for (AgentSymIter i(PglStaticSemx::TheAgentsToUse, RobotSym::TheType); i; ++i)
robots.append(&(RobotSym&)i.agent()->cast(RobotSym::TheType));
if (robots.count()) {
XmlTextTag<XmlParagraph> p;
p.buf() << "The workload defines " << robots.count() << " robot ";
addOneOrMany(p.buf(), robots.count(), "type") << ". ";
sect << p;
for (int i = 0; i < robots.count(); ++i) {
explainRobot(sect, *robots[i]);
}
} else {
XmlTextTag<XmlParagraph> p;
p.buf() << "The workload does not use any robots. ";
sect << p;
}
code << sect;
}
static
void explainContType(XmlTag §, const ContentSym &ctype) {
XmlTextTag<XmlParagraph> p;
if (RndDistr *sized = ctype.size()) {
p.buf() << "The size distribution for \"" << ctype.kind()
<< "\" content type is ";
sized->print(p.buf(), &DistrSym::SizeArgPrinter);
p.buf() << ". ";
@@ -713,61 +713,61 @@ void buildContTypeTable(XmlTable &table, const Array<const ContentSym*> &ctypes)
double ratio = 0;
ctype.cachable(ratio);
cellChb.buf() << (100*ratio) << '%'; // default is zero
cellChb << XmlAttr("align", "right");
rec << cellChb;
XmlTextTag<XmlTableCell> cellExts;
if (MimeSym *mime = ctype.mime()) {
Array<String*> exts;
RndDistr *sel;
if (mime->extensions(exts, sel)) {
for (int e = 0; e < exts.count(); ++e) {
addAnd(cellExts.buf(), e, exts.count());
cellExts.buf() << *exts[e];
}
}
}
if (!cellExts.buf().tellp())
cellExts.buf() << " ";
rec << cellExts;
table << rec;
}
}
static
void explainContTypes(XmlNodes &code, const PglParser &) {
XmlSection sect(2, "Content types");
Array<const ContentSym*> ctypes;
- {for (AgentSymIter i(PglStaticSemx::TheAgentsToUse, ServerSym::TheType, false); i; ++i) {
+ {for (AgentSymIter i(PglStaticSemx::TheAgentsToUse, ServerSym::TheType); i; ++i) {
const ServerSym &srv = (const ServerSym&)i.agent()->cast(ServerSym::TheType);
Array<ContentSym*> ccfgs;
Array<double> cprobs;
if (srv.contents(ccfgs, cprobs)) {
for (int c = 0; c < ccfgs.count(); ++c) {
bool found = false;
for (int f = 0; !found && f < ctypes.count(); ++f)
found = ctypes[f]->equal(*ccfgs[c]);
if (!found)
ctypes.append(ccfgs[c]);
}
}
}}
if (ctypes.count()) {
XmlTextTag<XmlParagraph> p;
p.buf() << "The workload uses " << ctypes.count();
addOneOrMany(p.buf(), ctypes.count(), " unique content type") << ". ";
sect << p;
XmlTag c("center");
XmlTable table;
buildContTypeTable(table, ctypes);
c << table;
sect << c;
for (int i = 0; i < ctypes.count(); ++i) {
explainContType(sect, *ctypes[i]);
}
diff --git a/src/post-config.h b/src/post-config.h
index 528b595..a02266f 100644
--- a/src/post-config.h
+++ b/src/post-config.h
@@ -1,40 +1,41 @@
/* Web Polygraph http://www.web-polygraph.org/
* Copyright 2003-2011 The Measurement Factory
* Licensed under the Apache License, Version 2.0 */
/* Fine-tune ./configure-generated configuration. */
#ifndef POLYGRAPH__POST_CONFIG_H
#define POLYGRAPH__POST_CONFIG_H
+#include <limits>
using namespace std;
/* various post-processing fixes and adjustments */
// increase FD_SETSIZE if needed and OS supports FD_SETSIZE redifinition
#if !defined(__linux__) && !defined(linux)
# if PROBED_MAXFD > 0 && DEFAULT_FD_SETSIZE > 0 && PROBED_MAXFD > DEFAULT_FD_SETSIZE
# ifdef FD_SETSIZE
# warning FD_SETSIZE is already defined
# else
# define FD_SETSIZE PROBED_MAXFD
# endif
# endif
#endif
// what file scanner (select(2), poll(2), epoll(7), etc.) use by default
// note: our current heuristic will fail in many environments
#if defined(HAVE_EPOLL_CREATE)
# define PG_PREFFERED_FILE_SCANNER Epoll
#elif defined(HAVE_POLL)
# define PG_PREFFERED_FILE_SCANNER Poll
#else
# define PG_PREFFERED_FILE_SCANNER Select
#endif
// define CONFIG_HOST_OS_* macros (shortened to CFG_HOS_*)
// this code is similar to Squid's include/config.h.in
#if defined(__sun__) || defined(__sun)
# define CFG_HOS_SUN
# if defined(__SVR4)
diff --git a/src/tools/pgl2ips.cc b/src/tools/pgl2ips.cc
index b6e6a00..3d5cc24 100644
--- a/src/tools/pgl2ips.cc
+++ b/src/tools/pgl2ips.cc
@@ -352,61 +352,61 @@ static void configureHosts(const String &nameBase,
const int agentsPerHost = totalAgentCount / hosts.count();
const int addrsPerHost = addrs.count() / hosts.count();
if (addrsPerHost * hosts.count() != addrs.count())
clog <<
"the number of agent addresses (" << addrs.count() <<
") is not divisible by the number of real host "
"addresess (" << hosts.count() << ')' << endl << xexit;
for (int i = 0; i < hosts.count(); ++i) {
const String name(makeName(nameBase, i+1));
if (!TheOpts.theHost ||
name == TheOpts.theHost ||
hosts[i]->addrA() == TheOpts.theHost) {
HostInfo *const info = new HostInfo(name, *hosts[i],
addrs, i*addrsPerHost, addrsPerHost,
agentsPerHost);
hostInfos.append(info);
if (TheOpts.theHost) {
TheHostScope = info;
break;
}
}
}
}
// collect agent info
static void configureAgents(const String &nameBase, const String &agentType, Array<AgentInfo*> &agentInfos) {
static AgentSymIter::Agents &agents = PglStaticSemx::TheAgentsToUse;
int n(1);
- for (AgentSymIter i(agents, agentType, false); i; ++i) {
+ for (AgentSymIter i(agents, agentType); i; ++i) {
const String name(makeName(nameBase, n++));
const AgentSym &agent(*i.agent());
if (!TheOpts.theAgent ||
name == TheOpts.theAgent ||
agent.kind() == TheOpts.theAgent) {
AgentInfo *const info = new AgentInfo (name,
agent.kind(), agent.addresses());
agentInfos.append(info);
}
}
}
// print current scope
static ostream &printScope(ostream &os) {
os << "scope: host=";
if (TheOpts.theHost)
TheOpts.theHost.report(os);
else
os << '*';
os << " agent=";
if (TheOpts.theAgent)
TheOpts.theAgent.report(os);
else
os << '*';
return os << endl;
}
int main(int argc, char **argv) {
CmdLine cmd;
diff --git a/src/xstd/Ring.h b/src/xstd/Ring.h
index d9f5d60..d26624d 100644
--- a/src/xstd/Ring.h
+++ b/src/xstd/Ring.h
@@ -1,51 +1,52 @@
/* Web Polygraph http://www.web-polygraph.org/
* Copyright 2003-2011 The Measurement Factory
* Licensed under the Apache License, Version 2.0 */
#ifndef POLYGRAPH__XSTD_RING_H
#define POLYGRAPH__XSTD_RING_H
#include "xstd/Array.h"
#include "xstd/Rnd.h"
// FIFO Queue of <Item>s with fixed capacity (i.e., ring)
// note dynamic resize()-ing on enqueue() does work but is disabled
template <class Item>
class Ring: protected Array<Item> {
public:
Ring(int aCapacity = 0): Array<Item>(aCapacity), theInOff(0), theOutOff(0) {}
using Array<Item>::capacity;
using Array<Item>::size;
+ using typename Array<Item>::Value;
int count() const { return theInOff - theOutOff; }
bool empty() const { return theInOff <= theOutOff; }
bool full() const { return count() >= capacity(); }
inline const Item &top(const int off = 0) const;
inline Item &top(const int off = 0);
inline void enqueue(const Item i);
inline Item dequeue();
void reset() { theInOff = theOutOff = 0; }
inline void resize(const int newCap);
inline void randomize(RndGen &rng);
inline Ring &operator =(const Ring &r);
protected:
inline Item &item(const int off);
inline const Item &item(const int off) const;
inline void check();
inline void copyFrom(const Item *const fromItems, const int inOff, const int outOff, const int fromCapacity);
virtual void copyOld(const Item *oldItems, int oldCapacity);
private:
int theInOff;
int theOutOff;
};
diff --git a/src/xstd/xstd.h b/src/xstd/xstd.h
index 05c9f24..9949674 100644
--- a/src/xstd/xstd.h
+++ b/src/xstd/xstd.h
@@ -1,17 +1,15 @@
/* Web Polygraph http://www.web-polygraph.org/
* Copyright 2003-2011 The Measurement Factory
* Licensed under the Apache License, Version 2.0 */
#ifndef POLYGRAPH__XSTD_XSTD_H
#define POLYGRAPH__XSTD_XSTD_H
// xstd.h must be included by all source files of xstd library
-using namespace std;
-
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#endif
--------------E6BF8415805B3E03934147DD
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
Users mailing list
[email protected]
http://lists.web-polygraph.org/mailman/listinfo/users
--------------E6BF8415805B3E03934147DD--