Skip to content

Commit a6a988c

Browse files
authored
Fix build errors and warnings from #184 (#218)
Fix build errors on old compilers Avoid c++11 constructs. Fix warning due to internal linkage usage in non-internal class.
1 parent 205dc58 commit a6a988c

File tree

2 files changed

+85
-77
lines changed

2 files changed

+85
-77
lines changed

src/remote/pv/beaconHandler.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,13 @@
2929
namespace
3030
{
3131
class InternalClientContextImpl;
32-
class BeaconCleanupHandler;
3332
}
3433

3534
namespace epics {
3635
namespace pvAccess {
36+
namespace detail {
37+
class BeaconCleanupHandler;
38+
}
3739

3840
/**
3941
* BeaconHandler
@@ -94,7 +96,7 @@ class BeaconHandler
9496
/**
9597
* Callback for cleaning up the beacon
9698
*/
97-
std::shared_ptr<BeaconCleanupHandler> _callback;
99+
std::tr1::shared_ptr<detail::BeaconCleanupHandler> _callback;
98100

99101
/**
100102
* Update beacon.

src/remoteClient/clientContextImpl.cpp

Lines changed: 81 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,51 @@ Status ClientChannelImpl::channelDestroyed(
6060
Status ClientChannelImpl::channelDisconnected(
6161
Status::STATUSTYPE_WARNING, "channel disconnected");
6262

63+
namespace detail {
64+
/**
65+
* Handles cleanup of old beacons.
66+
*/
67+
class BeaconCleanupHandler
68+
{
69+
public:
70+
POINTER_DEFINITIONS(BeaconCleanupHandler);
71+
72+
class Callback : public TimerCallback
73+
{
74+
public:
75+
Callback(BeaconCleanupHandler& handler) : m_handler(handler)
76+
{
77+
}
78+
79+
virtual void callback() OVERRIDE FINAL;
80+
virtual void timerStopped() OVERRIDE FINAL;
81+
82+
BeaconCleanupHandler& m_handler;
83+
};
84+
85+
BeaconCleanupHandler(InternalClientContextImpl& impl, osiSockAddr addr);
86+
~BeaconCleanupHandler();
87+
88+
/**
89+
* Extend the lifetime of the beacon, resetting removal countdown to 0
90+
*/
91+
void touch() { epicsAtomicSetIntT(&m_count, 0); }
92+
93+
private:
94+
void remove();
95+
96+
std::tr1::shared_ptr<BeaconCleanupHandler::Callback> m_callback;
97+
osiSockAddr m_from;
98+
InternalClientContextImpl& m_impl;
99+
int m_count;
100+
};
101+
102+
} // namespace detail
63103
}}
104+
64105
namespace {
65106
using namespace epics::pvAccess;
107+
using namespace epics::pvAccess::detail;
66108

67109
class ChannelGetFieldRequestImpl;
68110

@@ -3040,45 +3082,6 @@ enum ContextState {
30403082
CONTEXT_DESTROYED
30413083
};
30423084

3043-
3044-
/**
3045-
* Handles cleanup of old beacons.
3046-
*/
3047-
class BeaconCleanupHandler
3048-
{
3049-
public:
3050-
POINTER_DEFINITIONS(BeaconCleanupHandler);
3051-
3052-
class Callback : public TimerCallback
3053-
{
3054-
public:
3055-
Callback(BeaconCleanupHandler& handler) : m_handler(handler)
3056-
{
3057-
}
3058-
3059-
virtual void callback() OVERRIDE FINAL;
3060-
virtual void timerStopped() OVERRIDE FINAL;
3061-
3062-
BeaconCleanupHandler& m_handler;
3063-
};
3064-
3065-
BeaconCleanupHandler(InternalClientContextImpl& impl, osiSockAddr addr);
3066-
~BeaconCleanupHandler();
3067-
3068-
/**
3069-
* Extend the lifetime of the beacon, resetting removal countdown to 0
3070-
*/
3071-
void touch() { epicsAtomicSetIntT(&m_count, 0); }
3072-
3073-
private:
3074-
void remove();
3075-
3076-
std::shared_ptr<BeaconCleanupHandler::Callback> m_callback;
3077-
osiSockAddr m_from;
3078-
InternalClientContextImpl& m_impl;
3079-
int m_count;
3080-
};
3081-
30823085
class InternalClientContextImpl :
30833086
public ClientContextImpl,
30843087
public ChannelProvider
@@ -4397,7 +4400,7 @@ class InternalClientContextImpl :
43974400
char ipa[64];
43984401
sockAddrToDottedIP(&responseFrom->sa, ipa, sizeof(ipa));
43994402
LOG(logLevelDebug, "Tracked beacon limit reached (%d), ignoring %s\n", maxTrackedBeacons, ipa);
4400-
return nullptr;
4403+
return BeaconHandler::shared_pointer();
44014404
}
44024405

44034406
// stores weak_ptr
@@ -4610,43 +4613,9 @@ class InternalClientContextImpl :
46104613

46114614
TransportRegistry::transportVector_t m_flushTransports;
46124615

4613-
friend class BeaconCleanupHandler;
4616+
friend class epics::pvAccess::detail::BeaconCleanupHandler;
46144617
};
46154618

4616-
4617-
BeaconCleanupHandler::BeaconCleanupHandler(InternalClientContextImpl& impl, osiSockAddr addr) :
4618-
m_from(addr),
4619-
m_impl(impl),
4620-
m_count(0)
4621-
{
4622-
m_callback.reset(new Callback(*this));
4623-
m_impl.m_timer->schedulePeriodic(m_callback, maxBeaconLifetime / 4, maxBeaconLifetime / 4);
4624-
}
4625-
4626-
BeaconCleanupHandler::~BeaconCleanupHandler()
4627-
{
4628-
m_impl.m_timer->cancel(m_callback);
4629-
}
4630-
4631-
void BeaconCleanupHandler::Callback::callback()
4632-
{
4633-
if (epicsAtomicIncrIntT(&m_handler.m_count) >= 5) {
4634-
m_handler.remove();
4635-
}
4636-
}
4637-
4638-
void BeaconCleanupHandler::Callback::timerStopped()
4639-
{
4640-
m_handler.remove();
4641-
}
4642-
4643-
void BeaconCleanupHandler::remove()
4644-
{
4645-
Lock guard(m_impl.m_beaconMapMutex);
4646-
m_impl.m_timer->cancel(m_callback);
4647-
m_impl.m_beaconHandlers.erase(m_from);
4648-
}
4649-
46504619
size_t InternalClientContextImpl::num_instances;
46514620
size_t InternalClientContextImpl::InternalChannelImpl::num_instances;
46524621
size_t InternalClientContextImpl::InternalChannelImpl::num_active;
@@ -4850,5 +4819,42 @@ ChannelProvider::shared_pointer createClientProvider(const Configuration::shared
48504819
return external;
48514820
}
48524821

4822+
namespace detail {
4823+
4824+
BeaconCleanupHandler::BeaconCleanupHandler(InternalClientContextImpl& impl, osiSockAddr addr) :
4825+
m_from(addr),
4826+
m_impl(impl),
4827+
m_count(0)
4828+
{
4829+
m_callback.reset(new Callback(*this));
4830+
m_impl.m_timer->schedulePeriodic(m_callback, maxBeaconLifetime / 4, maxBeaconLifetime / 4);
4831+
}
4832+
4833+
BeaconCleanupHandler::~BeaconCleanupHandler()
4834+
{
4835+
m_impl.m_timer->cancel(m_callback);
4836+
}
4837+
4838+
void BeaconCleanupHandler::Callback::callback()
4839+
{
4840+
if (epicsAtomicIncrIntT(&m_handler.m_count) >= 5) {
4841+
m_handler.remove();
4842+
}
4843+
}
4844+
4845+
void BeaconCleanupHandler::Callback::timerStopped()
4846+
{
4847+
m_handler.remove();
4848+
}
4849+
4850+
void BeaconCleanupHandler::remove()
4851+
{
4852+
Lock guard(m_impl.m_beaconMapMutex);
4853+
m_impl.m_timer->cancel(m_callback);
4854+
m_impl.m_beaconHandlers.erase(m_from);
4855+
}
4856+
4857+
}
4858+
48534859
}
48544860
};

0 commit comments

Comments
 (0)