Skip to content

Commit a80e240

Browse files
authored
Merge pull request #4120 from jrw972/async-tcp-on-start-callbacks
TcpDataLink fails to send association message
2 parents cf370ec + cc6aa5c commit a80e240

File tree

5 files changed

+29
-8
lines changed

5 files changed

+29
-8
lines changed

dds/DCPS/transport/framework/TransportClient.cpp

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ TransportClient::associate(const AssociationData& data, bool active)
203203
ACE_GUARD_RETURN(ACE_Thread_Mutex, guard, lock_, false);
204204

205205
repo_id_ = repo_id;
206+
OPENDDS_ASSERT(repo_id_ != GUID_UNKNOWN);
206207

207208
if (impls_.empty()) {
208209
if (DCPS_debug_level) {
@@ -248,6 +249,7 @@ TransportClient::associate(const AssociationData& data, bool active)
248249
pa->impls_.clear();
249250
pa->blob_index_ = 0;
250251
pa->data_ = data;
252+
OPENDDS_ASSERT(repo_id_ != GUID_UNKNOWN);
251253
pa->attribs_.local_id_ = repo_id_;
252254
pa->attribs_.priority_ = get_priority_value(data);
253255
pa->attribs_.local_reliable_ = reliable_;
@@ -621,9 +623,9 @@ TransportClient::add_link(const DataLink_rch& link, const GUID_t& peer)
621623

622624
TransportReceiveListener_rch trl = get_receive_listener();
623625

626+
OPENDDS_ASSERT(repo_id_ != GUID_UNKNOWN);
624627
if (trl) {
625628
link->make_reservation(peer, repo_id_, trl, reliable_);
626-
627629
} else {
628630
link->make_reservation(peer, repo_id_, get_send_listener(), reliable_);
629631
}
@@ -745,6 +747,7 @@ TransportClient::disassociate(const GUID_t& peerId)
745747
link.in()));
746748
}
747749

750+
OPENDDS_ASSERT(repo_id_ != GUID_UNKNOWN);
748751
link->release_reservations(peerId, repo_id_, released);
749752

750753
if (!released.empty()) {
@@ -777,6 +780,11 @@ void TransportClient::transport_stop()
777780
const GUID_t repo_id = repo_id_;
778781
guard.release();
779782

783+
if (repo_id == GUID_UNKNOWN) {
784+
// Not associated so nothing to stop.
785+
return;
786+
}
787+
780788
for (size_t i = 0; i < impls.size(); ++i) {
781789
const TransportImpl_rch impl = impls[i].lock();
782790
if (impl) {
@@ -1112,6 +1120,9 @@ SendControlStatus
11121120
TransportClient::send_control(const DataSampleHeader& header,
11131121
Message_Block_Ptr msg)
11141122
{
1123+
if (repo_id_ == GUID_UNKNOWN) {
1124+
return SEND_CONTROL_OK;
1125+
}
11151126
return links_.send_control(repo_id_, get_send_listener(), header, move(msg));
11161127
}
11171128

@@ -1120,6 +1131,10 @@ TransportClient::send_control_to(const DataSampleHeader& header,
11201131
Message_Block_Ptr msg,
11211132
const GUID_t& destination)
11221133
{
1134+
if (repo_id_ == GUID_UNKNOWN) {
1135+
return SEND_CONTROL_OK;
1136+
}
1137+
11231138
DataLinkSet singular;
11241139
{
11251140
ACE_GUARD_RETURN(ACE_Thread_Mutex, guard, lock_, SEND_CONTROL_ERROR);
@@ -1143,6 +1158,9 @@ TransportClient::remove_sample(const DataSampleElement* sample)
11431158
bool
11441159
TransportClient::remove_all_msgs()
11451160
{
1161+
if (repo_id_ == GUID_UNKNOWN) {
1162+
return true;
1163+
}
11461164
return links_.remove_all_msgs(repo_id_);
11471165
}
11481166

dds/DCPS/transport/framework/TransportControlElement.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@
1313
#include "TransportControlElement.inl"
1414
#endif /* __ACE_INLINE__ */
1515

16-
OpenDDS::DCPS::TransportControlElement::TransportControlElement(
17-
Message_Block_Ptr msg_block
18-
) : TransportQueueElement(1),
19-
msg_( msg_block.release())
16+
OpenDDS::DCPS::TransportControlElement::TransportControlElement(Message_Block_Ptr msg_block,
17+
const GUID_t& publication_id)
18+
: TransportQueueElement(1)
19+
, msg_( msg_block.release())
20+
, publication_id_(publication_id)
2021
{
2122
DBG_ENTRY_LVL("TransportControlElement", "TransportControlElement", 6);
2223
}

dds/DCPS/transport/framework/TransportControlElement.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ class OpenDDS_Dcps_Export TransportControlElement
3131
* msg_block - chain of ACE_Message_Blocks containing the control
3232
* sample held by this queue element, if any.
3333
*/
34-
explicit TransportControlElement(Message_Block_Ptr msg_block);
34+
explicit TransportControlElement(Message_Block_Ptr msg_block,
35+
const GUID_t& publication_id = GUID_UNKNOWN);
3536

3637
virtual ~TransportControlElement();
3738

@@ -57,6 +58,7 @@ class OpenDDS_Dcps_Export TransportControlElement
5758
TransportControlElement(const TransportControlElement&);
5859
/// The control message.
5960
Message_Block_Ptr msg_;
61+
GUID_t publication_id_;
6062
};
6163

6264
} // namespace DCPS

dds/DCPS/transport/framework/TransportControlElement.inl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ ACE_INLINE
2626
OpenDDS::DCPS::GUID_t
2727
OpenDDS::DCPS::TransportControlElement::publication_id() const
2828
{
29-
return GUID_UNKNOWN;
29+
return publication_id_;
3030
}
3131

3232
ACE_INLINE

dds/DCPS/transport/tcp/TcpDataLink.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ OpenDDS::DCPS::TcpDataLink::send_association_msg(const GUID_t& local, const GUID
554554
Serializer ser(message.get(), encoding_unaligned_native);
555555
ser << remote;
556556

557-
TransportControlElement* send_element = new TransportControlElement(move(message));
557+
TransportControlElement* send_element = new TransportControlElement(move(message), local);
558558

559559
this->send_i(send_element, false);
560560
}

0 commit comments

Comments
 (0)