Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit eaa9971

Browse filesBrowse files
committed
Fixed strand issue in shdr connector
1 parent a1aafa4 commit eaa9971
Copy full SHA for eaa9971

2 files changed

+6-4Lines changed: 6 additions & 4 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/mtconnect/source/adapter/shdr/connector.hpp‎

Copy file name to clipboardExpand all lines: src/mtconnect/source/adapter/shdr/connector.hpp
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ namespace mtconnect::source::adapter::shdr {
118118
// Name of the server to connect to
119119
std::string m_server;
120120

121-
// Connection
122-
boost::asio::io_context::strand m_strand;
121+
// Connection – reference to the owning Source's strand (not a copy)
122+
boost::asio::io_context::strand &m_strand;
123123
boost::asio::ip::tcp::socket m_socket;
124124
boost::asio::ip::tcp::endpoint m_endpoint;
125125
boost::asio::ip::tcp::resolver::results_type m_results;
Collapse file

‎test_package/connector_test.cpp‎

Copy file name to clipboardExpand all lines: test_package/connector_test.cpp
+4-2Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,11 @@ class TestConnector : public Connector
112112
class ConnectorTest : public testing::Test
113113
{
114114
protected:
115+
ConnectorTest() : m_strand(m_context) { }
116+
115117
void SetUp() override
116118
{
117-
boost::asio::io_context::strand strand(m_context);
118-
m_connector = std::make_unique<TestConnector>(strand, "127.0.0.1", m_port);
119+
m_connector = std::make_unique<TestConnector>(m_strand, "127.0.0.1", m_port);
119120
m_connector->m_disconnected = true;
120121
m_connected = false;
121122
}
@@ -204,6 +205,7 @@ class ConnectorTest : public testing::Test
204205
unsigned short m_port {0};
205206
boost::asio::io_context m_context;
206207

208+
boost::asio::io_context::strand m_strand;
207209
std::unique_ptr<asio::ip::tcp::socket> m_server;
208210
std::unique_ptr<tcp::acceptor> m_acceptor;
209211
bool m_connected;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.