Skip to content
This repository has been archived by the owner on Apr 17, 2019. It is now read-only.

Fix send tx sequence method #1685

Merged
merged 3 commits into from
Aug 31, 2018
Merged

Fix send tx sequence method #1685

merged 3 commits into from
Aug 31, 2018

Conversation

kamilsa
Copy link
Contributor

@kamilsa kamilsa commented Aug 28, 2018

Signed-off-by: kamilsa [email protected]

Description of the Change

Due to unclear reasons boost::barrier throws segfault in send tx sequence test (once out from 100 runs on average). To avoid that it was replaced with std::condition_variable.

Benefits

No segfaults are thrown anymore(test was executed ~2000 times)

Possible Drawbacks

Inconsistency with sendTx method which still uses boost::barrier

@kamilsa kamilsa requested review from vdrobnyi and lebdron August 28, 2018 06:39
Signed-off-by: kamilsa <[email protected]>
bar.wait();
{
std::unique_lock<std::mutex> lk(m);
cv.wait(lk, [&] { return processed; });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That will wait forever, if notify_all is called before

Copy link
Contributor

@lebdron lebdron Aug 30, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? This is equivalent to while (!pred()) { wait(lock); }, so it will unlock after the observable is completed.
Edit: it will wait forever indeed because it will not be woken up

@@ -279,7 +286,10 @@ namespace integration_framework {
tx_list);

// make sure that the first (stateless) status is come
bar.wait();
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code block is redundant.

@@ -265,7 +268,11 @@ namespace integration_framework {
statuses.push_back(*std::static_pointer_cast<
shared_model::proto::TransactionResponse>(s));
},
[&bar] { bar.wait(); });
[&cv, &m, &processed] {
std::lock_guard<std::mutex> lock(m);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lock seems redundant here, what is its purpose? processed cannot be modified concurrently because on_complete is called once only.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Signed-off-by: kamilsa <[email protected]>
@kamilsa kamilsa force-pushed the fix/itf-send-tx-sequence branch from 3aa5f29 to 4a30e0e Compare August 31, 2018 15:39
@sorabot
Copy link

sorabot commented Aug 31, 2018

SonarQube analysis reported 1 issue

  1. MAJOR integration_test_framework.cpp#L289: Reference to auto variable returned. rule

@kamilsa kamilsa merged commit a194db8 into dev Aug 31, 2018
@kamilsa kamilsa deleted the fix/itf-send-tx-sequence branch August 31, 2018 17:25
bakhtin pushed a commit that referenced this pull request Nov 2, 2018
* Fix send tx sequence method

Signed-off-by: kamilsa <[email protected]>

* Add lock guard

Signed-off-by: kamilsa <[email protected]>

* Remove scope

Signed-off-by: kamilsa <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants