Skip to content

Commit

Permalink
tests: net: socket: tls: Fix race on TCP socket close
Browse files Browse the repository at this point in the history
One of the tests closed the underlying TCP connection right after
establishing one. This caused a certain race between incoming TLS
handshake data and entering FIN1 state (experienced on nrF52840), where
the TLS handshake data could be received after the FIN1 state was
entered, causing the server side to send RST packet. This disrupted the
test flow, as graceful TCP connection teardown was expected.

Fix this, by adding a small delay for such case to avoid the race.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
  • Loading branch information
rlubos authored and dleach02 committed Jan 4, 2024
1 parent 5cc1902 commit 312e000
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tests/net/socket/tls/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -809,6 +809,10 @@ static void fake_tcp_server_work(struct k_work *work)
test_accept(data->sock, &new_sock, NULL, 0);

if (!data->reply) {
/* Add small delay to avoid race between incoming data and
* sending FIN.
*/
k_msleep(10);
goto out;
}

Expand Down

0 comments on commit 312e000

Please sign in to comment.