Skip to content

Commit

Permalink
Fix[MWC]: ntc channel execute after close
Browse files Browse the repository at this point in the history
Signed-off-by: Evgeny Malygin <[email protected]>
  • Loading branch information
678098 committed Oct 23, 2024
1 parent 7d0ecf3 commit 2d89761
Show file tree
Hide file tree
Showing 4 changed files with 417 additions and 12 deletions.
11 changes: 8 additions & 3 deletions src/groups/bmq/bmqio/bmqio_ntcchannel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1333,8 +1333,12 @@ void NtcChannel::close(const Status& status)

int NtcChannel::execute(const ExecuteCb& cb)
{
d_streamSocket_sp->execute(cb);
return 0;
bslmt::LockGuard<bslmt::Mutex> lock(&d_mutex);
if (d_streamSocket_sp) {
d_streamSocket_sp->execute(cb);
return 0; // RETURN
}
return -1;
}

bdlmt::SignalerConnection NtcChannel::onClose(const CloseFn& cb)
Expand Down Expand Up @@ -1632,7 +1636,8 @@ int NtcListener::listen(bmqio::Status* status,

#if BMQIO_NTCLISTENER_BIND_ASYNC == 0

bsl::shared_ptr<ntsi::Resolver> resolver = ntsf::System::createResolver();
bsl::shared_ptr<ntsi::Resolver> resolver = ntsf::System::createResolver(
d_allocator_p);

ntsa::EndpointOptions endpointOptions;
endpointOptions.setTransport(ntsa::Transport::e_TCP_IPV4_STREAM);
Expand Down
5 changes: 3 additions & 2 deletions src/groups/bmq/bmqio/bmqio_ntcchannel.h
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,8 @@ class NtcChannel : public bmqio::Channel,
/// this channel for the write to succeed.
void write(Status* status,
const bdlbb::Blob& blob,
bsls::Types::Int64 watermark) BSLS_KEYWORD_OVERRIDE;
bsls::Types::Int64 watermark = bsl::numeric_limits<int>::max())
BSLS_KEYWORD_OVERRIDE;

/// Cancel the operation.
void cancel() BSLS_KEYWORD_OVERRIDE;
Expand All @@ -369,7 +370,7 @@ class NtcChannel : public bmqio::Channel,
/// Shutdown this channel, and cancel all pending read requests (but do
/// not invoke them). Pass the specified `status` to any registered
/// `CloseFn`s.
void close(const Status& status) BSLS_KEYWORD_OVERRIDE;
void close(const Status& status = Status()) BSLS_KEYWORD_OVERRIDE;

/// Execute the specified `cb` serialized with calls to any registered
/// read callbacks, or any `close` or `watermark` event handlers for
Expand Down
Loading

0 comments on commit 2d89761

Please sign in to comment.