diff --git a/src/info_receiver.cpp b/src/info_receiver.cpp index 2f26daab..36e1355f 100644 --- a/src/info_receiver.cpp +++ b/src/info_receiver.cpp @@ -52,7 +52,10 @@ void lsl::info_receiver::info_thread() { buffer.register_at(&conn_); std::iostream server_stream(&buffer); // connect... - buffer.connect(conn_.get_tcp_endpoint()); + if (nullptr == buffer.connect(conn_.get_tcp_endpoint())) + { + throw asio::system_error(buffer.error()); + } // send the query server_stream << "LSL:fullinfo\r\n" << std::flush; // receive and parse the response diff --git a/testing/ext/discovery.cpp b/testing/ext/discovery.cpp index 7d66e6e3..4523a1fe 100644 --- a/testing/ext/discovery.cpp +++ b/testing/ext/discovery.cpp @@ -43,5 +43,21 @@ TEST_CASE("fullinfo", "[inlet][fullinfo][basic]") { CHECK(fullinfo.desc().child_value("info") == extinfo); } +TEST_CASE("downed outlet deadlock", "[inlet][streaminfo]") +{ + // This test verifies that calling info on a resolved inlet that has become disconnected + // does not get locked waiting on a response. + auto outlet = std::make_unique(lsl::stream_info("deadtest", "type")); + + auto resolved = lsl::resolve_streams(); + REQUIRE(!resolved.empty()); + lsl::stream_inlet inlet(resolved[0]); + + outlet.reset(); + + // this would previously deadlock + CHECK_THROWS(inlet.info()); +} + } // namespace