Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/groups/bmq/bmqio/bmqio_channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ class Channel {

/// Return the URI of the "remote" end of this channel. It is up to the
/// underlying implementation to define the format of the returned URI.
virtual const bsl::string& peerUri() const = 0;
virtual bsl::string peerUri() const = 0;

/// Return a reference providing modifiable access to the properties of
/// this Channel.
Expand Down
4 changes: 2 additions & 2 deletions src/groups/bmq/bmqio/bmqio_decoratingchannelpartialimp.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class DecoratingChannelPartialImp : public Channel {
Channel* base() const;

// Channel
const bsl::string& peerUri() const BSLS_KEYWORD_OVERRIDE;
bsl::string peerUri() const BSLS_KEYWORD_OVERRIDE;

/// Forward to the underlying base `Channel`.
const bmqvt::PropertyBag& properties() const BSLS_KEYWORD_OVERRIDE;
Expand Down Expand Up @@ -177,7 +177,7 @@ inline Channel* DecoratingChannelPartialImp::base() const
return d_base.get();
}

inline const bsl::string& DecoratingChannelPartialImp::peerUri() const
inline bsl::string DecoratingChannelPartialImp::peerUri() const
{
return d_base->peerUri();
}
Expand Down
3 changes: 2 additions & 1 deletion src/groups/bmq/bmqio/bmqio_ntcchannel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1342,8 +1342,9 @@ ntsa::Endpoint NtcChannel::sourceEndpoint() const
: ntsa::Endpoint();
}

const bsl::string& NtcChannel::peerUri() const
bsl::string NtcChannel::peerUri() const
Comment thread
SrinathhSatuluri marked this conversation as resolved.
{
bslmt::LockGuard<bslmt::Mutex> lock(&d_mutex);
return d_peerUri;
}

Expand Down
2 changes: 1 addition & 1 deletion src/groups/bmq/bmqio/bmqio_ntcchannel.h
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ class NtcChannel : public bmqio::Channel,

/// Return the URI of the "remote" end of this channel. It is up to the
/// underlying implementation to define the format of the returned URI.
const bsl::string& peerUri() const BSLS_KEYWORD_OVERRIDE;
bsl::string peerUri() const BSLS_KEYWORD_OVERRIDE;

/// Return a reference providing modifiable access to the properties of
/// this Channel.
Expand Down
2 changes: 1 addition & 1 deletion src/groups/bmq/bmqio/bmqio_ntcchannel.t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ void executeOnClosedChannelFunc(bmqio::NtcChannel* channel,
BSLA_MAYBE_UNUSED ntsa::Endpoint peerEndpoint = channel->peerEndpoint();
BSLA_MAYBE_UNUSED ntsa::Endpoint sourceEndpoint =
channel->sourceEndpoint();
BSLA_MAYBE_UNUSED const bsl::string& peerUri = channel->peerUri();
BSLA_MAYBE_UNUSED bsl::string peerUri = channel->peerUri();
BSLA_MAYBE_UNUSED bmqvt::PropertyBag& properties = channel->properties();

channel->setChannelId(id);
Expand Down
2 changes: 1 addition & 1 deletion src/groups/bmq/bmqio/bmqio_ntcchannelfactory.t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1051,7 +1051,7 @@ void Tester::checkChannelUri(int line,
return; // RETURN
}

bslstl::StringRef uri = info.d_channel->peerUri();
bsl::string uri = info.d_channel->peerUri();
BMQTST_ASSERT_EQ_D(line,
uri.data(),
bdlb::StringRefUtil::strstr(uri, prefix).data());
Expand Down
11 changes: 6 additions & 5 deletions src/groups/bmq/bmqio/bmqio_resolvingchannelfactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,13 @@ ResolvingChannelFactory_Channel::ResolvingChannelFactory_Channel(
bslma::Allocator* basicAllocator)
: DecoratingChannelPartialImp(channel, basicAllocator)
, d_resolvedPeerUri(basicAllocator)
, d_basePeerUri(channel->peerUri(), basicAllocator)

@SrinathhSatuluri SrinathhSatuluri Jul 24, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

peerUri() returns a temporary now, so d_peerUri needs a stable copy to point at. d_basePeerUri owns that copy until resolution replaces it.

, d_peerUri()
{
// PRECONDITIONS
BSLS_ASSERT(channel);

d_peerUri = &channel->peerUri();
d_peerUri = &d_basePeerUri;
}

// MANIPULATORS
Expand All @@ -117,7 +118,7 @@ void ResolvingChannelFactory_Channel::updatePeerUri()
}

// ACCESSORS
const bsl::string& ResolvingChannelFactory_Channel::peerUri() const
bsl::string ResolvingChannelFactory_Channel::peerUri() const
{
return *d_peerUri;
}
Expand Down Expand Up @@ -235,7 +236,7 @@ void ResolvingChannelFactoryUtil::defaultResolutionFn(
const ResolveFn& resolveFn,
bool verbose)
{
bslstl::StringRef peerUri = baseChannel.peerUri();
bsl::string peerUri = baseChannel.peerUri();
bslstl::StringRef colon = bdlb::StringRefUtil::strstr(peerUri, ":");
if (colon.length() == 0) {
if (verbose) {
Expand All @@ -248,7 +249,7 @@ void ResolvingChannelFactoryUtil::defaultResolutionFn(

bdlma::LocalSequentialAllocator<128> arena;

bsl::string ipAddrStr(peerUri.data(), colon.data(), &arena);
bsl::string ipAddrStr(peerUri.c_str(), colon.data(), &arena);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

bsl::string::data() returns char* in C++17, StringRef::data() returns const char*. Iterator pair deduction fails on the mismatch. c_str() is always const char*.

ntsa::IpAddress ipAddr;

if (!ipAddr.parse(ipAddrStr)) {
Expand Down Expand Up @@ -277,7 +278,7 @@ void ResolvingChannelFactoryUtil::defaultResolutionFn(
resolvedUri->append(ipAddrStr);
resolvedUri->append(1, '~');
resolvedUri->append(resolvedName);
resolvedUri->append(colon.data(), peerUri.end());
resolvedUri->append(colon.data(), peerUri.c_str() + peerUri.length());
}

} // close package namespace
Expand Down
4 changes: 3 additions & 1 deletion src/groups/bmq/bmqio/bmqio_resolvingchannelfactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ class ResolvingChannelFactory_Channel : public DecoratingChannelPartialImp {
// PRIVATE DATA
bsl::string d_resolvedPeerUri;

bsl::string d_basePeerUri;

bsls::AtomicPointer<const bsl::string> d_peerUri;

private:
Expand Down Expand Up @@ -177,7 +179,7 @@ class ResolvingChannelFactory_Channel : public DecoratingChannelPartialImp {

/// Return our base Channel's peerUri until our resolution is done, and
/// start returning the resolved peerUri after that.
const bsl::string& peerUri() const BSLS_KEYWORD_OVERRIDE;
bsl::string peerUri() const BSLS_KEYWORD_OVERRIDE;
};

// =============================
Expand Down
2 changes: 1 addition & 1 deletion src/groups/bmq/bmqio/bmqio_testchannel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ bmqvt::PropertyBag& TestChannel::properties()
return d_properties;
}

const bsl::string& TestChannel::peerUri() const
bsl::string TestChannel::peerUri() const
{
return d_peerUri;
}
Expand Down
2 changes: 1 addition & 1 deletion src/groups/bmq/bmqio/bmqio_testchannel.h
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ class TestChannel : public Channel {

// ACCESSORS
// Channel
const bsl::string& peerUri() const BSLS_KEYWORD_OVERRIDE;
bsl::string peerUri() const BSLS_KEYWORD_OVERRIDE;
const bmqvt::PropertyBag& properties() const BSLS_KEYWORD_OVERRIDE;
};

Expand Down
2 changes: 1 addition & 1 deletion src/groups/mqb/mqba/mqba_adminsession.t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ struct TestAdminRetranslator {
TestAdminRetranslator() {}

int enqueueCommand(
BSLA_MAYBE_UNUSED const bslstl::StringRef& source,
BSLA_MAYBE_UNUSED const bsl::string& source,
const bsl::string& cmd,
const mqbnet::Session::AdminCommandProcessedCb& onProcessedCb)
{
Expand Down
12 changes: 6 additions & 6 deletions src/groups/mqb/mqba/mqba_application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
// same time or on the same physical host.
unsigned int seed =
bsl::time(NULL) +
static_cast<unsigned int>(bdls::ProcessUtil::getProcessId()) +

Check warning on line 117 in src/groups/mqb/mqba/mqba_application.cpp

View workflow job for this annotation

GitHub Actions / Build [ubuntu] / Build [ubuntu, cpp23] fd7c28bc2c6c6a6c89355501843838e2d71c3c9f bmqbrkr bmqtool bmqstoragetool all.it

conversion from ‘time_t’ {aka ‘long int’} to ‘unsigned int’ may change value [-Wconversion]

Check warning on line 117 in src/groups/mqb/mqba/mqba_application.cpp

View workflow job for this annotation

GitHub Actions / Build [ubuntu, C++03] / Build [ubuntu, cpp03] fd7c28bc2c6c6a6c89355501843838e2d71c3c9f bmqbrkr bmqtool bmq.t mqb.t

conversion from ‘time_t’ {aka ‘long int’} to ‘unsigned int’ may change value [-Wconversion]

Check warning on line 117 in src/groups/mqb/mqba/mqba_application.cpp

View workflow job for this annotation

GitHub Actions / UT [c++] / Build [ubuntu, cpp23] fd7c28bc2c6c6a6c89355501843838e2d71c3c9f all.t

conversion from ‘time_t’ {aka ‘long int’} to ‘unsigned int’ may change value [-Wconversion]
static_cast<unsigned int>(bmqu::Time::highResolutionTimer() &
0xFFFFFFFF);

Expand All @@ -139,12 +139,12 @@
, d_adminExecutionPool(bslmt::ThreadAttributes(),
0,
1,
bsls::TimeInterval(120).totalMilliseconds(),

Check warning on line 142 in src/groups/mqb/mqba/mqba_application.cpp

View workflow job for this annotation

GitHub Actions / Build [ubuntu] / Build [ubuntu, cpp23] fd7c28bc2c6c6a6c89355501843838e2d71c3c9f bmqbrkr bmqtool bmqstoragetool all.it

conversion from ‘BloombergLP::bsls::Types::Int64’ {aka ‘long long int’} to ‘int’ may change value [-Wconversion]

Check warning on line 142 in src/groups/mqb/mqba/mqba_application.cpp

View workflow job for this annotation

GitHub Actions / Build [ubuntu, C++03] / Build [ubuntu, cpp03] fd7c28bc2c6c6a6c89355501843838e2d71c3c9f bmqbrkr bmqtool bmq.t mqb.t

conversion from ‘BloombergLP::bsls::Types::Int64’ {aka ‘long long int’} to ‘int’ may change value [-Wconversion]

Check warning on line 142 in src/groups/mqb/mqba/mqba_application.cpp

View workflow job for this annotation

GitHub Actions / UT [c++] / Build [ubuntu, cpp23] fd7c28bc2c6c6a6c89355501843838e2d71c3c9f all.t

conversion from ‘BloombergLP::bsls::Types::Int64’ {aka ‘long long int’} to ‘int’ may change value [-Wconversion]
allocator)
, d_adminRerouteExecutionPool(bslmt::ThreadAttributes(),
0,
1,
bsls::TimeInterval(120).totalMilliseconds(),

Check warning on line 147 in src/groups/mqb/mqba/mqba_application.cpp

View workflow job for this annotation

GitHub Actions / Build [ubuntu] / Build [ubuntu, cpp23] fd7c28bc2c6c6a6c89355501843838e2d71c3c9f bmqbrkr bmqtool bmqstoragetool all.it

conversion from ‘BloombergLP::bsls::Types::Int64’ {aka ‘long long int’} to ‘int’ may change value [-Wconversion]

Check warning on line 147 in src/groups/mqb/mqba/mqba_application.cpp

View workflow job for this annotation

GitHub Actions / Build [ubuntu, C++03] / Build [ubuntu, cpp03] fd7c28bc2c6c6a6c89355501843838e2d71c3c9f bmqbrkr bmqtool bmq.t mqb.t

conversion from ‘BloombergLP::bsls::Types::Int64’ {aka ‘long long int’} to ‘int’ may change value [-Wconversion]

Check warning on line 147 in src/groups/mqb/mqba/mqba_application.cpp

View workflow job for this annotation

GitHub Actions / UT [c++] / Build [ubuntu, cpp23] fd7c28bc2c6c6a6c89355501843838e2d71c3c9f all.t

conversion from ‘BloombergLP::bsls::Types::Int64’ {aka ‘long long int’} to ‘int’ may change value [-Wconversion]
allocator)
, d_bufferFactory(k_BLOBBUFFER_SIZE,
bsls::BlockGrowth::BSLS_CONSTANT,
Expand Down Expand Up @@ -515,7 +515,7 @@
bsl::vector<bsl::shared_ptr<mqbi::Cluster> > clusters(d_allocator_p);
d_clusterCatalog_mp->getClusters(&clusters);

bslmt::Latch latch(clusters.size());

Check warning on line 518 in src/groups/mqb/mqba/mqba_application.cpp

View workflow job for this annotation

GitHub Actions / Build [ubuntu] / Build [ubuntu, cpp23] fd7c28bc2c6c6a6c89355501843838e2d71c3c9f bmqbrkr bmqtool bmqstoragetool all.it

conversion from ‘bsl::vectorBase<bsl::shared_ptr<BloombergLP::mqbi::Cluster> >::size_type’ {aka ‘long unsigned int’} to ‘int’ may change value [-Wconversion]

Check warning on line 518 in src/groups/mqb/mqba/mqba_application.cpp

View workflow job for this annotation

GitHub Actions / Build [ubuntu, C++03] / Build [ubuntu, cpp03] fd7c28bc2c6c6a6c89355501843838e2d71c3c9f bmqbrkr bmqtool bmq.t mqb.t

conversion from ‘bsl::vectorBase<bsl::shared_ptr<BloombergLP::mqbi::Cluster> >::size_type’ {aka ‘long unsigned int’} to ‘int’ may change value [-Wconversion]

Check warning on line 518 in src/groups/mqb/mqba/mqba_application.cpp

View workflow job for this annotation

GitHub Actions / UT [c++] / Build [ubuntu, cpp23] fd7c28bc2c6c6a6c89355501843838e2d71c3c9f all.t

conversion from ‘bsl::vectorBase<bsl::shared_ptr<BloombergLP::mqbi::Cluster> >::size_type’ {aka ‘long unsigned int’} to ‘int’ may change value [-Wconversion]

BALL_LOG_INFO << "Initiating " << clusters.size()
<< " cluster(s) shutdown...";
Expand Down Expand Up @@ -647,7 +647,7 @@
}
}

bslmt::Latch latchDownstreams(clients.size() + 1);

Check warning on line 650 in src/groups/mqb/mqba/mqba_application.cpp

View workflow job for this annotation

GitHub Actions / Build [ubuntu] / Build [ubuntu, cpp23] fd7c28bc2c6c6a6c89355501843838e2d71c3c9f bmqbrkr bmqtool bmqstoragetool all.it

conversion from ‘bsl::vectorBase<bsl::shared_ptr<BloombergLP::mqbnet::Session> >::size_type’ {aka ‘long unsigned int’} to ‘int’ may change value [-Wconversion]

Check warning on line 650 in src/groups/mqb/mqba/mqba_application.cpp

View workflow job for this annotation

GitHub Actions / Build [ubuntu, C++03] / Build [ubuntu, cpp03] fd7c28bc2c6c6a6c89355501843838e2d71c3c9f bmqbrkr bmqtool bmq.t mqb.t

conversion from ‘bsl::vectorBase<bsl::shared_ptr<BloombergLP::mqbnet::Session> >::size_type’ {aka ‘long unsigned int’} to ‘int’ may change value [-Wconversion]

Check warning on line 650 in src/groups/mqb/mqba/mqba_application.cpp

View workflow job for this annotation

GitHub Actions / UT [c++] / Build [ubuntu, cpp23] fd7c28bc2c6c6a6c89355501843838e2d71c3c9f all.t

conversion from ‘bsl::vectorBase<bsl::shared_ptr<BloombergLP::mqbnet::Session> >::size_type’ {aka ‘long unsigned int’} to ‘int’ may change value [-Wconversion]
// The 'StopRequestManagerType::sendRequest' always calls 'd_responseCb'.

// The first round of StopRequests blocks incoming PUTs.
Expand Down Expand Up @@ -884,10 +884,10 @@
}
}

int Application::processCommand(const bslstl::StringRef& source,
const bsl::string& cmd,
bsl::ostream& os,
bool fromReroute)
int Application::processCommand(const bsl::string& source,
const bsl::string& cmd,
bsl::ostream& os,
bool fromReroute)
{
enum RcEnum {
rc_SUCCESS = 0,
Expand Down Expand Up @@ -987,7 +987,7 @@
}

int Application::processCommandCb(
const bslstl::StringRef& source,
const bsl::string& source,
const bsl::string& cmd,
const bsl::function<void(int, const bsl::string&)>& onProcessedCb,
bool fromReroute)
Expand All @@ -1008,7 +1008,7 @@
}

int Application::enqueueCommand(
const bslstl::StringRef& source,
const bsl::string& source,
const bsl::string& cmd,
const bsl::function<void(int, const bsl::string&)>& onProcessedCb,
bool fromReroute)
Expand Down
12 changes: 6 additions & 6 deletions src/groups/mqb/mqba/mqba_application.h
Original file line number Diff line number Diff line change
Expand Up @@ -240,18 +240,18 @@ class Application {
/// Mark `fromReroute` as true if executing the command from a reroute to
/// ensure proper routing logic. Returns 0 on success, -1 on early exit,
/// -2 on error, and some non-zero error code on parse failure.
int processCommand(const bslstl::StringRef& source,
const bsl::string& cmd,
bsl::ostream& os,
bool fromReroute = false);
int processCommand(const bsl::string& source,
const bsl::string& cmd,
bsl::ostream& os,
bool fromReroute = false);

/// Process the command `cmd` coming from the specified `source` node, and
/// send the result of the command in the given `onProcessedCb`. Mark
/// `fromReroute` as true if executing command from a reroute to ensure
/// proper routing logic. Returns the error code of calling
/// `processCommand` with the given `cmd`, `source`, and `fromReroute`.
int processCommandCb(
const bslstl::StringRef& source,
const bsl::string& source,
const bsl::string& cmd,
const bsl::function<void(int, const bsl::string&)>& onProcessedCb,
bool fromReroute = false);
Expand All @@ -262,7 +262,7 @@ class Application {
/// as true if executing command from a reroute to ensure proper routing
/// logic.
int enqueueCommand(
const bslstl::StringRef& source,
const bsl::string& source,
const bsl::string& cmd,
const bsl::function<void(int, const bsl::string&)>& onProcessedCb,
bool fromReroute = false);
Expand Down
2 changes: 1 addition & 1 deletion src/groups/mqb/mqbnet/mqbnet_session.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class Session : public SessionEventProcessor {
/// executed. The execution result (structured, non-structured text or
/// possible error message) is expected to be passed to the specified
/// `onProcessed` callback.
typedef bsl::function<void(const bslstl::StringRef& source,
typedef bsl::function<void(const bsl::string& source,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

StringRef bound into a thread pool job captures a pointer, not the data. With peerUri() returning a temporary, the data is freed before the job runs.

const bsl::string& command,
const AdminCommandProcessedCb& onProcessed,
bool fromReroute)>
Expand Down
2 changes: 1 addition & 1 deletion src/groups/mqb/mqbnet/mqbnet_tcpsessionfactory.g.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ class MockChannel : public bmqio::Channel {

MOCK_METHOD1(setWriteQueueHighWatermark, void(int highWatermark));

MOCK_CONST_METHOD0(peerUri, const bsl::string&());
MOCK_CONST_METHOD0(peerUri, bsl::string());

MOCK_CONST_METHOD0(properties, const bmqvt::PropertyBag&());
};
Expand Down
Loading