diff --git a/src/groups/mqb/mqbnet/mqbnet_tcpsessionfactory.cpp b/src/groups/mqb/mqbnet/mqbnet_tcpsessionfactory.cpp index 03f43efdbb..f9696c4f73 100644 --- a/src/groups/mqb/mqbnet/mqbnet_tcpsessionfactory.cpp +++ b/src/groups/mqb/mqbnet/mqbnet_tcpsessionfactory.cpp @@ -972,8 +972,8 @@ TCPSessionFactory::TCPSessionFactory( , d_initialMissedHeartbeatCounter(calculateInitialMissedHbCounter(config)) , d_listeningHandles(allocator) , d_isListening(false) -, d_timestampMap(allocator) , d_listenContexts(allocator) +, d_timestampMap(allocator) , d_allocator_p(allocator) { // PRECONDITIONS @@ -1392,6 +1392,8 @@ int TCPSessionFactory::listen(const mqbcfg::TcpInterfaceListener& listener, const int port = listener.port(); BSLS_ASSERT_SAFE(d_listenContexts.find(port) == d_listenContexts.cend()); + BSLS_ASSERT_SAFE(d_listeningHandles.find(port) == + d_listeningHandles.cend()); // Maintain ownership of 'OperationContext' instead of passing it to // 'ChannelFactory::listen' because it may delete the context @@ -1411,12 +1413,11 @@ int TCPSessionFactory::listen(const mqbcfg::TcpInterfaceListener& listener, bmqio::ListenOptions listenOptions; listenOptions.setEndpoint(endpoint.str()); - OpHandleMp& listeningHandle = d_listeningHandles[port]; - + bslma::ManagedPtr listeningHandle_mp; bmqio::Status status; d_statChannelFactory_mp->listen( &status, - &listeningHandle, + &listeningHandle_mp, listenOptions, bdlf::BindUtil::bind(&TCPSessionFactory::channelStateCallback, this, @@ -1433,7 +1434,11 @@ int TCPSessionFactory::listen(const mqbcfg::TcpInterfaceListener& listener, return status.category(); // RETURN } - BSLS_ASSERT_SAFE(listeningHandle); + BSLS_ASSERT_SAFE(listeningHandle_mp); + + OpHandleSp listeningHandle_sp(listeningHandle_mp, d_allocator_p); + d_listeningHandles.emplace(port, listeningHandle_sp); + BALL_LOG_INFO << "TCPSessionFactory '" << d_config.name() << "' " << "successfully listening to '" << endpoint.str() << "'"; diff --git a/src/groups/mqb/mqbnet/mqbnet_tcpsessionfactory.h b/src/groups/mqb/mqbnet/mqbnet_tcpsessionfactory.h index 5d2c39da00..efdb77f8eb 100644 --- a/src/groups/mqb/mqbnet/mqbnet_tcpsessionfactory.h +++ b/src/groups/mqb/mqbnet/mqbnet_tcpsessionfactory.h @@ -272,12 +272,12 @@ class TCPSessionFactory { typedef TCPSessionFactory_OperationContext OperationContext; - typedef bslma::ManagedPtr OpHandleMp; + typedef bsl::shared_ptr OpHandleSp; typedef bsl::unordered_map TimestampMap; - typedef bsl::unordered_map ListeningHandleMap; + typedef bsl::unordered_map ListeningHandleMap; private: // DATA