Skip to content

Commit 952f949

Browse files
Mikolaj Maleckicl-ment
Mikolaj Malecki
authored andcommitted
[test] Fixing ConnectNonBlocking: delay listen to prevent connection from being established too early
1 parent ee03ae9 commit 952f949

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

test/test_bonding.cpp

+7-5
Original file line numberDiff line numberDiff line change
@@ -732,7 +732,6 @@ TEST(Bonding, ConnectNonBlocking)
732732
EXPECT_NE(srt_bind(g_listen_socket, sa.get(), sa.size()), -1);
733733
const int yes = 1;
734734
srt_setsockflag(g_listen_socket, SRTO_GROUPCONNECT, &yes, sizeof yes);
735-
EXPECT_NE(srt_listen(g_listen_socket, 5), -1);
736735

737736
int lsn_eid = srt_epoll_create();
738737
int lsn_events = SRT_EPOLL_IN | SRT_EPOLL_ERR | SRT_EPOLL_UPDATE;
@@ -770,8 +769,14 @@ TEST(Bonding, ConnectNonBlocking)
770769

771770
ThreadName::set("TEST_A");
772771

773-
cout << "[A] Waiting for accept\n";
772+
cout << "[A] Waiting for main thread to pass connect()\n";
773+
774+
// Delay with executing accept to keep the peer in "in progress"
775+
// connection state.
776+
connect_passed.get_future().get();
777+
EXPECT_NE(srt_listen(g_listen_socket, 5), SRT_ERROR);
774778

779+
cout << "[A] Waiting for accept\n";
775780
// This can wait in infinity; worst case it will be killed in process.
776781
int uwait_res = srt_epoll_uwait(lsn_eid, ev, 3, -1);
777782
EXPECT_EQ(uwait_res, 1);
@@ -783,9 +788,6 @@ TEST(Bonding, ConnectNonBlocking)
783788
bool have_also_update = ev[0].events & SRT_EPOLL_UPDATE;
784789

785790
cout << "[A] Accept delay until connect done...\n";
786-
// Delay with executing accept to keep the peer in "in progress"
787-
// connection state.
788-
connect_passed.get_future().get();
789791

790792
cout << "[A] Accept: go on\n";
791793

0 commit comments

Comments
 (0)