Skip to content

Commit 527fa18

Browse files
authored
Fix[MWC]: ntc channel execute after close (#465)
Signed-off-by: Evgeny Malygin <[email protected]>
1 parent 844ba5c commit 527fa18

File tree

4 files changed

+417
-12
lines changed

4 files changed

+417
-12
lines changed

src/groups/bmq/bmqio/bmqio_ntcchannel.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1333,8 +1333,12 @@ void NtcChannel::close(const Status& status)
13331333

13341334
int NtcChannel::execute(const ExecuteCb& cb)
13351335
{
1336-
d_streamSocket_sp->execute(cb);
1337-
return 0;
1336+
bslmt::LockGuard<bslmt::Mutex> lock(&d_mutex);
1337+
if (d_streamSocket_sp) {
1338+
d_streamSocket_sp->execute(cb);
1339+
return 0; // RETURN
1340+
}
1341+
return -1;
13381342
}
13391343

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

16331637
#if BMQIO_NTCLISTENER_BIND_ASYNC == 0
16341638

1635-
bsl::shared_ptr<ntsi::Resolver> resolver = ntsf::System::createResolver();
1639+
bsl::shared_ptr<ntsi::Resolver> resolver = ntsf::System::createResolver(
1640+
d_allocator_p);
16361641

16371642
ntsa::EndpointOptions endpointOptions;
16381643
endpointOptions.setTransport(ntsa::Transport::e_TCP_IPV4_STREAM);

src/groups/bmq/bmqio/bmqio_ntcchannel.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,8 @@ class NtcChannel : public bmqio::Channel,
354354
/// this channel for the write to succeed.
355355
void write(Status* status,
356356
const bdlbb::Blob& blob,
357-
bsls::Types::Int64 watermark) BSLS_KEYWORD_OVERRIDE;
357+
bsls::Types::Int64 watermark = bsl::numeric_limits<int>::max())
358+
BSLS_KEYWORD_OVERRIDE;
358359

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

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

0 commit comments

Comments
 (0)