Commit 5f9937b1 authored by Francis Dupont's avatar Francis Dupont

[#880] Added some atomics to satisfy the thread sanitizer

parent de4cd27f
......@@ -26,7 +26,7 @@ using namespace isc::process;
namespace isc {
namespace netconf {
bool NetconfProcess::shut_down = false;
std::atomic<bool> NetconfProcess::shut_down(false);
NetconfProcess::NetconfProcess(const char* name,
const asiolink::IOServicePtr& io_service)
......
// Copyright (C) 2018 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2018-2019 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
......@@ -10,6 +10,7 @@
#include <netconf/netconf.h>
#include <process/d_process.h>
#include <vector>
#include <atomic>
namespace isc {
namespace netconf {
......@@ -85,7 +86,7 @@ public:
NetconfCfgMgrPtr getNetconfCfgMgr();
/// @brief Global (globally visible) shutdown flag.
static bool shut_down;
static std::atomic<bool> shut_down;
private:
......
......@@ -24,6 +24,7 @@
#include <gtest/gtest.h>
#include <sstream>
#include <thread>
#include <atomic>
using namespace std;
using namespace isc;
......@@ -425,10 +426,10 @@ public:
}
// To know when the callback was called.
static bool finished;
static atomic<bool> finished;
};
bool TestCallback::finished = false;
atomic<bool> TestCallback::finished(false);
/// Verifies the logChanges method handles correctly changes.
TEST_F(NetconfAgentLogTest, logChanges) {
......
......@@ -15,7 +15,7 @@
#include <queue>
#include <thread>
#include <mutex>
#include <boost/atomic.hpp>
#include <atomic>
namespace isc {
namespace perfdhcp {
......@@ -34,7 +34,7 @@ namespace perfdhcp {
class Receiver {
private:
/// \brief Flag indicating if thread should run (true) or not (false).
boost::atomic_flag run_flag_;
std::atomic_flag run_flag_;
/// \brief Thread for receiving packets.
std::unique_ptr<std::thread> recv_thread_;
......@@ -62,6 +62,7 @@ public:
socket_(socket),
single_threaded_(single_threaded),
ip_version_(ip_version) {
run_flag_.clear();
}
/// \brief Destructor.
......
// Copyright (C) 2011-2017 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2011-2019 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
......@@ -15,6 +15,8 @@
#include <exceptions/exceptions.h>
#include <atomic>
namespace isc {
namespace asiolink {
......@@ -50,7 +52,7 @@ private:
// a function to call back when timer_ expires
IntervalTimer::Callback cbfunc_;
// interval in milliseconds
long interval_;
std::atomic<long> interval_;
// asio timer
boost::asio::deadline_timer timer_;
......@@ -99,7 +101,7 @@ void
IntervalTimerImpl::update() {
try {
// Update expire time to (current time + interval_).
timer_.expires_from_now(boost::posix_time::millisec(interval_));
timer_.expires_from_now(boost::posix_time::millisec(long(interval_)));
// Reset timer.
// Pass a function bound with a shared_ptr to this.
timer_.async_wait(boost::bind(&IntervalTimerImpl::callback,
......
......@@ -15,6 +15,8 @@
#include <exceptions/exceptions.h>
#include <atomic>
namespace isc {
namespace process {
......@@ -203,7 +205,7 @@ private:
asiolink::IOServicePtr io_service_;
/// @brief Boolean flag set when shutdown has been requested.
bool shut_down_flag_;
std::atomic<bool> shut_down_flag_;
/// @brief Pointer to the configuration manager.
DCfgMgrBasePtr cfg_mgr_;
......
......@@ -12,6 +12,7 @@
#include <gtest/gtest.h>
#include <unistd.h>
#include <atomic>
using namespace std;
using namespace isc;
......@@ -84,7 +85,7 @@ public:
/// @brief Counter used to track the number of passes made
/// within the thread worker function.
int passes_;
std::atomic<int> passes_;
};
const int WatchedThreadTest::WORKER_MAX_PASSES = 10;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment