New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/reentrancy #111
Feature/reentrancy #111
Conversation
Signed-off-by: Igor Egorov <igor@soramitsu.co.jp>
Signed-off-by: Dmitriy Khaustov aka xDimon <khaustov.dm@gmail.com>
Signed-off-by: Dmitriy Khaustov aka xDimon <khaustov.dm@gmail.com>
Signed-off-by: Dmitriy Khaustov aka xDimon <khaustov.dm@gmail.com>
Signed-off-by: Dmitriy Khaustov aka xDimon <khaustov.dm@gmail.com>
Signed-off-by: Dmitriy Khaustov aka xDimon <khaustov.dm@gmail.com>
Signed-off-by: Dmitriy Khaustov aka xDimon <khaustov.dm@gmail.com>
Signed-off-by: Dmitriy Khaustov aka xDimon <khaustov.dm@gmail.com>
Signed-off-by: Dmitriy Khaustov aka xDimon <khaustov.dm@gmail.com>
Signed-off-by: Dmitriy Khaustov aka xDimon <khaustov.dm@gmail.com>
Signed-off-by: Dmitriy Khaustov aka xDimon <khaustov.dm@gmail.com>
Signed-off-by: Dmitriy Khaustov aka xDimon <khaustov.dm@gmail.com>
refactoring: replace deprecated sha256 function by hasher Signed-off-by: Dmitriy Khaustov aka xDimon <khaustov.dm@gmail.com>
Signed-off-by: Dmitriy Khaustov aka xDimon <khaustov.dm@gmail.com>
Signed-off-by: Dmitriy Khaustov aka xDimon <khaustov.dm@gmail.com>
Signed-off-by: Dmitriy Khaustov aka xDimon <khaustov.dm@gmail.com>
Signed-off-by: Dmitriy Khaustov aka xDimon <khaustov.dm@gmail.com>
Signed-off-by: Dmitriy Khaustov aka xDimon <khaustov.dm@gmail.com>
Address sanitizer reports a heap-use-after-free error when launching Please check the log attached. Please fix the memory corruption. asan-3.txt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The first phase of review done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
* | ||
* @note if (!ec) then this function does nothing | ||
*/ | ||
virtual void deferReadCallback(outcome::result<size_t> res, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
Callback aleady has an argument of type
outcome::result<size_t>
- was it expected the first argument to be an error_code like indeferWriteCallback
? -
If 1 is true, then can we have a single method named something like
deferIoCallback
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- fixed
- trying to avoid diamond hierarchy
* | ||
* @note if (!ec) then this function does nothing | ||
*/ | ||
virtual void deferWriteCallback(std::error_code ec, WriteCallbackFunc cb) = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we have to pass ec
into that method? Can we just do the check outside of that method implementation if needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes we can, but the fn will do nothing anyways
@@ -131,438 +147,535 @@ namespace libp2p::connection { | |||
|
|||
void YamuxedConnection::read(gsl::span<uint8_t> out, size_t bytes, | |||
ReadCallbackFunc cb) { | |||
connection_->read(out, bytes, std::move(cb)); | |||
log()->critical("YamuxedConnection::read : invalid direct call"); | |||
deferReadCallback(YamuxError::FORBIDDEN_CALL, std::move(cb)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As we discussed offline - this could be the reason the multiselect protocol gets broken.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It appears that it's not where it breaks, unfortunately
void YamuxedConnection::writeStreamData(uint32_t stream_id, | ||
gsl::span<const uint8_t> data, | ||
bool some) { | ||
// TODO(artem): reform in buffers (shared + vector writes) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please fix or create an issue with a clear description. Unfortunately, it does not prescriptive enough of what to do.
|
||
capacity_remains_ = alloc_granularity_; | ||
} else { | ||
fragments_.emplace_back(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it ok if new fragment will be added only for oversized data?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, some heuristic here to minimize copying
|
||
capacity_remains_ -= sz; | ||
} else if (capacity_remains_ > 0) { | ||
auto &vec = fragments_.back(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it ok if parts of data which size less remaining capacity will inflate only one fragment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, only last fragmen's capacity counts
total_size_ = 0; | ||
first_byte_offset_ = 0; | ||
capacity_remains_ = 0; | ||
std::deque<Fragment>{}.swap(fragments_); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is advantages to use swap instead clear?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
deallocation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but it will be deallocated anyway in dtor at out of scope
@@ -66,16 +71,16 @@ TEST(EchoTest, Server) { | |||
* @when client writes string "hello" to the Stream | |||
* @then client reads back the same string | |||
*/ | |||
TEST(EchoTest, Client) { | |||
TEST(EchoTest, DISABLED_Client) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment, please, why is it disabled and issue (number or link) to enable it back.
Or remove if it really needless anymore
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this test expects reentrant behavior from mocks and other objects, needs to be rewritten as soon as new testing tools for async appears (net PR)
* multiselect revised, WIP * multiselect: simple outbound stream negotiate * multiselect numerous fixes * multiselect: instances and reuse * multiselect: fixes * multiselect: removed old implementation * multiselect: interop with go impl fixes * multiselect: bugfixes * multiselect: ProtocolMuxer interface abstracts simple outbound stream negotiation * multiselect: cleanups and logging * trigger CI * temporarily disabled tests that required synchronous reaction of multiselect * just removed unused lines * reverted back ci.yml
This update resolves the following: