Skip to content

Commit

Permalink
Remove pass-by-referece scope locking since it breaks some GCCs, it
Browse files Browse the repository at this point in the history
seems
  • Loading branch information
dragorn committed Nov 22, 2018
1 parent 94e34b3 commit 0f3ed2f
Show file tree
Hide file tree
Showing 16 changed files with 53 additions and 79 deletions.
8 changes: 4 additions & 4 deletions antennatracker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Antennatracker::~Antennatracker() {
}

int Antennatracker::add_antenna(uuid in_src, int in_srcnum, int in_adjustment) {
local_locker l(mutex);
local_locker l(&mutex);

for (auto ai : *antenna_id_map) {
auto a = std::static_pointer_cast<tracked_antenna>(ai.second);
Expand Down Expand Up @@ -61,7 +61,7 @@ int Antennatracker::add_antenna(uuid in_src, int in_srcnum, int in_adjustment) {
}

int Antennatracker::add_antenna(uuid in_src, int in_srcnum, int in_adjustment, uuid in_ant_uuid) {
local_locker l(mutex);
local_locker l(&mutex);

for (auto ai : *antenna_id_map) {
auto a = std::static_pointer_cast<tracked_antenna>(ai.second);
Expand All @@ -85,7 +85,7 @@ int Antennatracker::add_antenna(uuid in_src, int in_srcnum, int in_adjustment, u
}

int Antennatracker::set_antenna_adjustment(int in_antnum, int in_adjustment) {
local_locker l(mutex);
local_locker l(&mutex);

auto ai = antenna_id_map->find(in_antnum);

Expand All @@ -99,7 +99,7 @@ int Antennatracker::set_antenna_adjustment(int in_antnum, int in_adjustment) {
}

std::shared_ptr<tracked_antenna> Antennatracker::get_antenna(int in_antnum) {
local_locker l(mutex);
local_locker l(&mutex);

auto ai = antenna_id_map->find(in_antnum);

Expand Down
6 changes: 3 additions & 3 deletions buffer_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ BufferHandlerOStringStreambuf::~BufferHandlerOStringStreambuf() {
}

std::streamsize BufferHandlerOStringStreambuf::xsputn(const char_type *s, std::streamsize n) {
local_locker l(mutex);
local_locker l(&mutex);

std::streamsize sz = std::stringbuf::xsputn(s, n);

Expand All @@ -555,7 +555,7 @@ std::streamsize BufferHandlerOStringStreambuf::xsputn(const char_type *s, std::s
}

BufferHandlerOStringStreambuf::int_type BufferHandlerOStringStreambuf::overflow(int_type ch) {
local_locker l(mutex);
local_locker l(&mutex);

BufferHandlerOStringStreambuf::int_type it = std::stringbuf::overflow(ch);

Expand All @@ -572,7 +572,7 @@ int BufferHandlerOStringStreambuf::sync() {
return -1;
}

local_locker l(mutex);
local_locker l(&mutex);

size_t sz = str().length();

Expand Down
14 changes: 7 additions & 7 deletions configfile.cc
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ HeaderValueConfig::HeaderValueConfig() {
}

void HeaderValueConfig::parseLine(const std::string& in_confline) {
local_locker l(mutex);
local_locker l(&mutex);

auto cpos = in_confline.find(":");

Expand All @@ -650,22 +650,22 @@ void HeaderValueConfig::parseLine(const std::string& in_confline) {
}

std::string HeaderValueConfig::getHeader() {
local_locker l(mutex);
local_locker l(&mutex);
return header;
}

void HeaderValueConfig::setHeader(const std::string& in_str) {
local_locker l(mutex);
local_locker l(&mutex);
header = in_str;
}

bool HeaderValueConfig::hasKey(const std::string& in_str) {
local_locker l(mutex);
local_locker l(&mutex);
return (content_map.find(in_str) != content_map.end());
}

std::string HeaderValueConfig::getValue(const std::string& in_str) {
local_locker l(mutex);
local_locker l(&mutex);

auto vi = content_map.find(in_str);

Expand All @@ -676,7 +676,7 @@ std::string HeaderValueConfig::getValue(const std::string& in_str) {
}

std::string HeaderValueConfig::getValue(const std::string& in_str, const std::string& in_defl) {
local_locker l(mutex);
local_locker l(&mutex);

auto vi = content_map.find(in_str);

Expand All @@ -687,7 +687,7 @@ std::string HeaderValueConfig::getValue(const std::string& in_str, const std::st
}

void HeaderValueConfig::eraseKey(const std::string& in_key) {
local_locker l(mutex);
local_locker l(&mutex);

auto vi = content_map.find(in_key);

Expand Down
8 changes: 4 additions & 4 deletions configfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class ConfigFile {
// default value is used.
template<typename T>
T fetchOptAs(const std::string& in_key, const T& dvalue) {
local_locker l(config_locker);
local_locker l(&config_locker);

auto ki = config_map.find(StrLower(in_key));

Expand All @@ -96,7 +96,7 @@ class ConfigFile {
// Set a value, converting the arbitrary input into a string
template<typename T>
void SetOpt(const std::string& in_key, const T in_value, int in_dirty) {
local_locker l(config_locker);
local_locker l(&config_locker);
std::vector<config_entity> v;
config_entity e(fmt::format("{}", in_value), "::dynamic::");
v.push_back(e);
Expand Down Expand Up @@ -193,7 +193,7 @@ class HeaderValueConfig {
// If the key is not present, return the defautl value
template<typename T>
T getValueAs(const std::string& in_key, const T& dvalue) {
local_locker l(mutex);
local_locker l(&mutex);

auto ki = content_map.find(StrLower(in_key));

Expand All @@ -213,7 +213,7 @@ class HeaderValueConfig {
// Set a value, converting the arbitrary input into a string
template<typename T>
void setValue(const std::string& in_key, T in_value) {
local_locker l(mutex);
local_locker l(&mutex);
content_map[in_key] = fmt::format("{}", in_value);
}

Expand Down
4 changes: 2 additions & 2 deletions datasourcetracker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,7 @@ void Datasourcetracker::open_datasource(const std::string& in_source,

// Record and initiate it
{
local_locker dl(dst_lock);
local_locker dl(&dst_lock);
probing_map[probeid] = dst_probe;
}

Expand Down Expand Up @@ -1306,7 +1306,7 @@ bool Datasourcetracker::Httpd_VerifyPath(const char *path, const char *method) {
return false;

{
local_shared_locker l(dst_lock);
local_shared_locker l(&dst_lock);
if (uuid_source_num_map.find(u) == uuid_source_num_map.end())
return false;
}
Expand Down
12 changes: 6 additions & 6 deletions devicetracker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -876,7 +876,7 @@ void Devicetracker::MatchOnDevicesRaw(std::shared_ptr<DevicetrackerFilterWorker>
bool m;

{
local_locker devlocker(v->device_mutex);
local_locker devlocker(&v->device_mutex);
m = worker->MatchDevice(this, v);
}

Expand Down Expand Up @@ -1126,7 +1126,7 @@ void Devicetracker::AddDevice(std::shared_ptr<kis_tracked_device_base> device) {
}

bool Devicetracker::add_view(std::shared_ptr<DevicetrackerView> in_view) {
local_locker l(view_mutex);
local_locker l(&view_mutex);

for (auto i : *view_vec) {
auto vi = std::static_pointer_cast<DevicetrackerView>(i);
Expand All @@ -1145,7 +1145,7 @@ bool Devicetracker::add_view(std::shared_ptr<DevicetrackerView> in_view) {
}

void Devicetracker::remove_view(const std::string& in_id) {
local_locker l(view_mutex);
local_locker l(&view_mutex);

for (auto i = view_vec->begin(); i != view_vec->end(); ++i) {
auto vi = std::static_pointer_cast<DevicetrackerView>(*i);
Expand All @@ -1157,7 +1157,7 @@ void Devicetracker::remove_view(const std::string& in_id) {
}

void Devicetracker::new_view_device(std::shared_ptr<kis_tracked_device_base> in_device) {
local_locker l(view_mutex);
local_locker l(&view_mutex);

for (auto i : *view_vec) {
auto vi = std::static_pointer_cast<DevicetrackerView>(i);
Expand All @@ -1166,7 +1166,7 @@ void Devicetracker::new_view_device(std::shared_ptr<kis_tracked_device_base> in_
}

void Devicetracker::update_view_device(std::shared_ptr<kis_tracked_device_base> in_device) {
local_locker l(view_mutex);
local_locker l(&view_mutex);

for (auto i : *view_vec) {
auto vi = std::static_pointer_cast<DevicetrackerView>(i);
Expand All @@ -1175,7 +1175,7 @@ void Devicetracker::update_view_device(std::shared_ptr<kis_tracked_device_base>
}

void Devicetracker::remove_view_device(std::shared_ptr<kis_tracked_device_base> in_device) {
local_locker l(view_mutex);
local_locker l(&view_mutex);

for (auto i : *view_vec) {
auto vi = std::static_pointer_cast<DevicetrackerView>(i);
Expand Down
2 changes: 1 addition & 1 deletion devicetracker_httpd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,7 @@ int Devicetracker::Httpd_PostComplete(Kis_Net_Httpd_Connection *concls) {

// Make the length and filter elements
{
local_shared_locker lock(devicelist_mutex);
local_shared_locker lock(&devicelist_mutex);
dt_length_elem =
std::make_shared<TrackerElementUInt64>(dt_length_id, tracked_vec.size());
}
Expand Down
10 changes: 5 additions & 5 deletions devicetracker_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ std::shared_ptr<TrackerElementVector> DevicetrackerView::doDeviceWork(Devicetrac

bool m;
{
local_locker devlocker(dev->device_mutex);
local_locker devlocker(&dev->device_mutex);
m = worker.matchDevice(dev);
}

Expand All @@ -90,15 +90,15 @@ std::shared_ptr<TrackerElementVector> DevicetrackerView::doDeviceWork(Devicetrac
}

void DevicetrackerView::newDevice(std::shared_ptr<kis_tracked_device_base> device) {
local_locker l(mutex);
local_locker l(&mutex);

if (new_cb != nullptr)
if (new_cb(device))
device_list->push_back(device);
}

void DevicetrackerView::updateDevice(std::shared_ptr<kis_tracked_device_base> device) {
local_locker l(mutex);
local_locker l(&mutex);

if (update_cb == nullptr)
return;
Expand Down Expand Up @@ -127,7 +127,7 @@ void DevicetrackerView::updateDevice(std::shared_ptr<kis_tracked_device_base> de
}

void DevicetrackerView::removeDevice(std::shared_ptr<kis_tracked_device_base> device) {
local_locker l(mutex);
local_locker l(&mutex);

auto di = device_presence_map.find(device->get_key());

Expand Down Expand Up @@ -376,7 +376,7 @@ unsigned int DevicetrackerView::device_endpoint_handler(std::ostream& stream,
// which is protected from the main vector being grown/shrank. While we're in there, log the total
// size of the original vector for windowed ops.
{
local_locker l(mutex);
local_locker l(&mutex);
next_work_vec->set(device_list->begin(), device_list->end());
total_sz_elem->set(next_work_vec->size());
}
Expand Down
6 changes: 3 additions & 3 deletions devicetracker_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,20 +67,20 @@ class DevicetrackerView : public tracker_component {
new_device_cb in_new_cb, updated_device_cb in_upd_cb);

virtual ~DevicetrackerView() {
local_locker l(mutex);
local_locker l(&mutex);
}

// Protect proxies w/ mutex
__ProxyGet(view_id, std::string, std::string, view_id);
__ProxyGet(view_description, std::string, std::string, view_description);

virtual void pre_serialize() override {
local_eol_shared_locker lock(mutex);
local_eol_shared_locker lock(&mutex);
list_sz->set(device_list->size());
}

virtual void post_serialize() override {
local_shared_unlocker lock(mutex);
local_shared_unlocker lock(&mutex);
}

// Do work on the base list of all devices in this view; this makes an immutable copy
Expand Down
2 changes: 1 addition & 1 deletion devicetracker_view_workers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include "kismet_algorithm.h"

void DevicetrackerViewWorker::setMatchedDevices(std::shared_ptr<TrackerElementVector> devs) {
local_locker l(mutex);
local_locker l(&mutex);
matched = devs;
}

Expand Down
6 changes: 3 additions & 3 deletions dlttracker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ DltTracker::DltTracker() {
}

DltTracker::~DltTracker() {
local_locker lock(mutex);
local_locker lock(&mutex);

}

Expand All @@ -38,15 +38,15 @@ uint32_t DltTracker::register_linktype(const std::string& in_linktype) {
if (csum < 4096)
csum += 4096;

local_locker l(mutex);
local_locker l(&mutex);

dlt_to_name_map[csum] = StrLower(in_linktype);

return csum;
}

std::string DltTracker::get_linktype_name(uint32_t in_dlt) {
local_locker l(mutex);
local_locker l(&mutex);

auto i = dlt_to_name_map.find(in_dlt);

Expand Down
2 changes: 1 addition & 1 deletion dot11_fingerprint.cc
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ std::shared_ptr<tracked_dot11_fingerprint> Dot11FingerprintTracker::get_fingerpr
}

void Dot11FingerprintTracker::rebuild_config() {
local_locker l(mutex);
local_locker l(&mutex);

if (configfile == nullptr)
return;
Expand Down
2 changes: 1 addition & 1 deletion kis_databaselogfile.cc
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ KisDatabaseLogfile::~KisDatabaseLogfile() {
}

bool KisDatabaseLogfile::Log_Open(std::string in_path) {
local_locker dbl(ds_mutex);
local_locker dbl(&ds_mutex);

bool dbr = Database_Open(in_path);

Expand Down
Loading

0 comments on commit 0f3ed2f

Please sign in to comment.