(ixbots) fix tsan data race error when accessing verbose parameter
This commit is contained in:
parent
4f17cd5e74
commit
af003fc79b
@ -21,7 +21,6 @@ namespace ix
|
||||
const std::string& channel,
|
||||
const std::string& filter,
|
||||
const std::string& position,
|
||||
bool verbose,
|
||||
bool enableHeartbeat,
|
||||
int runtime)
|
||||
{
|
||||
@ -117,7 +116,6 @@ namespace ix
|
||||
&filter,
|
||||
&subscriptionPosition,
|
||||
&jsonWriter,
|
||||
verbose,
|
||||
&throttled,
|
||||
&receivedCount,
|
||||
&fatalCobraError,
|
||||
@ -146,18 +144,11 @@ namespace ix
|
||||
subscriptionPosition,
|
||||
[this,
|
||||
&jsonWriter,
|
||||
verbose,
|
||||
&throttled,
|
||||
&receivedCount,
|
||||
&subscriptionPosition,
|
||||
&fatalCobraError,
|
||||
&sentCount](const Json::Value& msg, const std::string& position) {
|
||||
if (verbose)
|
||||
{
|
||||
CoreLogger::info("Subscriber received message "
|
||||
+ position + " -> " + jsonWriter.write(msg));
|
||||
}
|
||||
|
||||
subscriptionPosition = position;
|
||||
|
||||
// If we cannot send to sentry fast enough, drop the message
|
||||
@ -169,8 +160,8 @@ namespace ix
|
||||
++receivedCount;
|
||||
|
||||
_onBotMessageCallback(
|
||||
msg, position, verbose,
|
||||
throttled, fatalCobraError, sentCount);
|
||||
msg, position, throttled,
|
||||
fatalCobraError, sentCount);
|
||||
});
|
||||
}
|
||||
else if (event->type == ix::CobraEventType::Subscribed)
|
||||
|
@ -16,7 +16,6 @@ namespace ix
|
||||
{
|
||||
using OnBotMessageCallback = std::function<void(const Json::Value&,
|
||||
const std::string&,
|
||||
const bool verbose,
|
||||
std::atomic<bool>&,
|
||||
std::atomic<bool>&,
|
||||
std::atomic<uint64_t>&)>;
|
||||
@ -30,7 +29,6 @@ namespace ix
|
||||
const std::string& channel,
|
||||
const std::string& filter,
|
||||
const std::string& position,
|
||||
bool verbose,
|
||||
bool enableHeartbeat,
|
||||
int runtime);
|
||||
|
||||
|
@ -26,42 +26,19 @@ namespace ix
|
||||
int runtime)
|
||||
{
|
||||
CobraBot bot;
|
||||
bot.setOnBotMessageCallback([&sentryClient](const Json::Value& msg,
|
||||
bot.setOnBotMessageCallback([&sentryClient, &verbose](const Json::Value& msg,
|
||||
const std::string& /*position*/,
|
||||
const bool verbose,
|
||||
std::atomic<bool>& throttled,
|
||||
std::atomic<bool>& /*fatalCobraError*/,
|
||||
std::atomic<uint64_t>& sentCount) -> void {
|
||||
sentryClient.send(msg, verbose,
|
||||
[&sentCount, &throttled, &verbose](const HttpResponsePtr& response) {
|
||||
[&sentCount, &throttled](const HttpResponsePtr& response) {
|
||||
if (!response)
|
||||
{
|
||||
CoreLogger::warn("Null HTTP Response");
|
||||
return;
|
||||
}
|
||||
|
||||
if (verbose)
|
||||
{
|
||||
for (auto it : response->headers)
|
||||
{
|
||||
CoreLogger::info(it.first + ": " + it.second);
|
||||
}
|
||||
|
||||
CoreLogger::info("Upload size: " + std::to_string(response->uploadSize));
|
||||
CoreLogger::info("Download size: " + std::to_string(response->downloadSize));
|
||||
|
||||
CoreLogger::info("Status: " + std::to_string(response->statusCode));
|
||||
if (response->errorCode != HttpErrorCode::Ok)
|
||||
{
|
||||
CoreLogger::info("error message: " + response->errorMsg);
|
||||
}
|
||||
|
||||
if (response->headers["Content-Type"] != "application/octet-stream")
|
||||
{
|
||||
CoreLogger::info("payload: " + response->payload);
|
||||
}
|
||||
}
|
||||
|
||||
if (response->statusCode == 200)
|
||||
{
|
||||
sentCount++;
|
||||
@ -103,7 +80,6 @@ namespace ix
|
||||
channel,
|
||||
filter,
|
||||
position,
|
||||
verbose,
|
||||
enableHeartbeat,
|
||||
runtime);
|
||||
}
|
||||
|
@ -73,9 +73,8 @@ namespace ix
|
||||
|
||||
CobraBot bot;
|
||||
bot.setOnBotMessageCallback(
|
||||
[&statsdClient, &tokens, &gauge, &timer](const Json::Value& msg,
|
||||
[&statsdClient, &tokens, &gauge, &timer, &verbose](const Json::Value& msg,
|
||||
const std::string& /*position*/,
|
||||
const bool verbose,
|
||||
std::atomic<bool>& /*throttled*/,
|
||||
std::atomic<bool>& fatalCobraError,
|
||||
std::atomic<uint64_t>& sentCount) -> void {
|
||||
@ -146,7 +145,6 @@ namespace ix
|
||||
channel,
|
||||
filter,
|
||||
position,
|
||||
verbose,
|
||||
enableHeartbeat,
|
||||
runtime);
|
||||
}
|
||||
|
@ -69,7 +69,6 @@ namespace ix
|
||||
const std::string& position,
|
||||
bool fluentd,
|
||||
bool quiet,
|
||||
bool verbose,
|
||||
bool enableHeartbeat,
|
||||
int runtime)
|
||||
{
|
||||
@ -79,7 +78,6 @@ namespace ix
|
||||
bot.setOnBotMessageCallback(
|
||||
[&fluentd, &quiet, &jsonWriter](const Json::Value& msg,
|
||||
const std::string& position,
|
||||
const bool /*verbose*/,
|
||||
std::atomic<bool>& /*throttled*/,
|
||||
std::atomic<bool>& /*fatalCobraError*/,
|
||||
std::atomic<uint64_t>& sentCount) -> void {
|
||||
@ -94,7 +92,6 @@ namespace ix
|
||||
channel,
|
||||
filter,
|
||||
position,
|
||||
verbose,
|
||||
enableHeartbeat,
|
||||
runtime);
|
||||
}
|
||||
|
@ -18,7 +18,6 @@ namespace ix
|
||||
const std::string& position,
|
||||
bool fluentd,
|
||||
bool quiet,
|
||||
bool verbose,
|
||||
bool enableHeartbeat,
|
||||
int runtime);
|
||||
} // namespace ix
|
||||
|
@ -87,7 +87,6 @@ TEST_CASE("Cobra_to_stdout_bot", "[cobra_bots]")
|
||||
|
||||
std::string filter;
|
||||
std::string position("$");
|
||||
bool verbose = true;
|
||||
bool quiet = false;
|
||||
bool enableHeartbeat = false;
|
||||
|
||||
@ -103,7 +102,6 @@ TEST_CASE("Cobra_to_stdout_bot", "[cobra_bots]")
|
||||
position,
|
||||
fluentd,
|
||||
quiet,
|
||||
verbose,
|
||||
enableHeartbeat,
|
||||
runtime);
|
||||
//
|
||||
|
Loading…
x
Reference in New Issue
Block a user