Skip to content

Commit 2c5d246

Browse files
author
Cruz Monrreal
authored
Merge pull request #9429 from SeppoTakalo/TCPSOCKET_endpoint_close
Fix TCPSOCKET_ENDPOINT_CLOSE: Cannot accept WOULD_BLOCK
2 parents a12ab30 + 6b92d32 commit 2c5d246

File tree

1 file changed

+2
-21
lines changed

1 file changed

+2
-21
lines changed

TESTS/netsocket/tcp/tcpsocket_endpoint_close.cpp

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,6 @@
2424

2525
using namespace utest::v1;
2626

27-
namespace {
28-
static const int SIGNAL_SIGIO = 0x1;
29-
static const int SIGIO_TIMEOUT = 20000; //[ms]
30-
}
31-
32-
static void _sigio_handler(osThreadId id)
33-
{
34-
osSignalSet(id, SIGNAL_SIGIO);
35-
}
36-
3727
static nsapi_error_t _tcpsocket_connect_to_daytime_srv(TCPSocket &sock)
3828
{
3929
SocketAddress tcp_addr;
@@ -49,7 +39,6 @@ static nsapi_error_t _tcpsocket_connect_to_daytime_srv(TCPSocket &sock)
4939
return sock.connect(tcp_addr);
5040
}
5141

52-
5342
void TCPSOCKET_ENDPOINT_CLOSE()
5443
{
5544
static const int MORE_THAN_AVAILABLE = 30;
@@ -63,24 +52,16 @@ void TCPSOCKET_ENDPOINT_CLOSE()
6352
TEST_FAIL();
6453
return;
6554
}
66-
sock.sigio(callback(_sigio_handler, ThisThread::get_id()));
6755

6856
int recvd = 0;
6957
int recvd_total = 0;
7058
while (true) {
71-
recvd = sock.recv(&(buff[recvd_total]), MORE_THAN_AVAILABLE);
59+
recvd = sock.recv(buff, MORE_THAN_AVAILABLE);
7260
if (recvd_total > 0 && recvd == 0) {
7361
break; // Endpoint closed socket, success
7462
} else if (recvd <= 0) {
75-
TEST_FAIL();
63+
TEST_ASSERT_EQUAL(0, recvd);
7664
break;
77-
} else if (recvd == NSAPI_ERROR_WOULD_BLOCK) {
78-
if (tc_exec_time.read() >= time_allotted ||
79-
osSignalWait(SIGNAL_SIGIO, SIGIO_TIMEOUT).status == osEventTimeout) {
80-
TEST_FAIL();
81-
break;
82-
}
83-
continue;
8465
}
8566
recvd_total += recvd;
8667
TEST_ASSERT(recvd_total < MORE_THAN_AVAILABLE);

0 commit comments

Comments
 (0)