class STG_LOCKER
{
public:
- STG_LOCKER(pthread_mutex_t& m)
+ explicit STG_LOCKER(pthread_mutex_t& m)
: mutex(&m)
{
pthread_mutex_lock(mutex);
}
- STG_LOCKER(pthread_mutex_t * m)
+ explicit STG_LOCKER(pthread_mutex_t * m)
: mutex(m)
{
pthread_mutex_lock(mutex);
struct ChannelConfig {
struct Error : std::runtime_error {
- Error(const std::string& message) : runtime_error(message) {}
+ explicit Error(const std::string& message) : runtime_error(message) {}
};
- ChannelConfig(std::string address);
+ explicit ChannelConfig(std::string address);
std::string transport;
std::string key;
class PacketGen : public Gen
{
public:
- PacketGen(const std::string& type)
+ explicit PacketGen(const std::string& type)
: m_type(type)
{
m_gen.add("packet", m_type);
m_parser(&Conn::Impl::process, this),
m_connected(true)
{
+ RadLog("Created connection.");
pthread_mutex_init(&m_mutex, NULL);
int res = pthread_create(&m_thread, NULL, &Conn::Impl::run, this);
if (res != 0)
shutdown(m_sock, SHUT_RDWR);
close(m_sock);
pthread_mutex_destroy(&m_mutex);
+ RadLog("Deleted connection.");
}
bool Conn::Impl::stop()
{
m_running = true;
+ RadLog("Run connection.");
+
while (m_running) {
fd_set fds;
tv.tv_sec = 0;
tv.tv_usec = 500000;
+ RadLog("Starting 'select'.");
int res = select(m_sock + 1, &fds, NULL, NULL, &tv);
+ RadLog("'select' result: %d.", res);
if (res < 0)
{
if (errno == EINTR)
break;
}
+
if (!m_running)
break;
if (res > 0)
{
+ RadLog("Got %d fds.", res);
if (FD_ISSET(m_sock, &fds))
m_running = read();
+ RadLog("Read complete.");
}
else
m_running = tick();
}
+ RadLog("End running connection.");
+
m_connected = false;
m_stopped = true;
}
RadLog("Failed to write data: %s.", strerror(errno));
return false;
}
+ RadLog("Send %d bytes.", res);
size -= res;
}
return true;
class BoolGen : public Gen
{
public:
- BoolGen(bool value) : m_value(value) {}
+ explicit BoolGen(bool value) : m_value(value) {}
virtual void run(yajl_gen_t* handle) const;
private:
bool m_value;
class StringGen : public Gen
{
public:
- StringGen(const std::string& value) : m_value(value) {}
+ explicit StringGen(const std::string& value) : m_value(value) {}
virtual void run(yajl_gen_t* handle) const;
private:
std::string m_value;
class NumberGen : public Gen
{
public:
- NumberGen(const std::string& value) : m_value(value) {}
+ explicit NumberGen(const std::string& value) : m_value(value) {}
template <typename T>
- NumberGen(const T& value) : m_value(x2str(value)) {}
+ explicit NumberGen(const T& value) : m_value(x2str(value)) {}
virtual void run(yajl_gen_t* handle) const;
private:
std::string m_value;