Skip to content

Commit 40836b1

Browse files
gekyc1728p9
authored andcommitted
nsapi - Removed assertions on same-thread send/recv
Initially these assertions were added to protected simultaneous send/recv from the same socket when similarly purposed mutexes were removed. However, simultaneous send/recv can still be useful for UDP if the payload is guaranteed to be less than the MTU across the entire connection.
1 parent 9976738 commit 40836b1

File tree

2 files changed

+2
-20
lines changed

2 files changed

+2
-20
lines changed

features/netsocket/UDPSocket.cpp

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@
1919
#include "mbed_assert.h"
2020

2121
UDPSocket::UDPSocket()
22-
: _pending(0), _read_sem(0), _write_sem(0),
23-
_read_in_progress(false), _write_in_progress(false)
22+
: _pending(0), _read_sem(0), _write_sem(0)
2423
{
2524
}
2625

@@ -53,12 +52,6 @@ int UDPSocket::sendto(const SocketAddress &address, const void *data, unsigned s
5352
_lock.lock();
5453
int ret;
5554

56-
// If this assert is hit then there are two threads
57-
// performing a send at the same time which is undefined
58-
// behavior
59-
MBED_ASSERT(!_write_in_progress);
60-
_write_in_progress = true;
61-
6255
while (true) {
6356
if (!_socket) {
6457
ret = NSAPI_ERROR_NO_SOCKET;
@@ -87,7 +80,6 @@ int UDPSocket::sendto(const SocketAddress &address, const void *data, unsigned s
8780
}
8881
}
8982

90-
_write_in_progress = false;
9183
_lock.unlock();
9284
return ret;
9385
}
@@ -97,12 +89,6 @@ int UDPSocket::recvfrom(SocketAddress *address, void *buffer, unsigned size)
9789
_lock.lock();
9890
int ret;
9991

100-
// If this assert is hit then there are two threads
101-
// performing a recv at the same time which is undefined
102-
// behavior
103-
MBED_ASSERT(!_read_in_progress);
104-
_read_in_progress = true;
105-
10692
while (true) {
10793
if (!_socket) {
10894
ret = NSAPI_ERROR_NO_SOCKET;
@@ -131,7 +117,6 @@ int UDPSocket::recvfrom(SocketAddress *address, void *buffer, unsigned size)
131117
}
132118
}
133119

134-
_read_in_progress = false;
135120
_lock.unlock();
136121
return ret;
137122
}

features/netsocket/UDPSocket.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ class UDPSocket : public Socket {
4545
*/
4646
template <typename S>
4747
UDPSocket(S *stack)
48-
: _pending(0), _read_sem(0), _write_sem(0),
49-
_read_in_progress(false), _write_in_progress(false)
48+
: _pending(0), _read_sem(0), _write_sem(0)
5049
{
5150
open(stack);
5251
}
@@ -117,8 +116,6 @@ class UDPSocket : public Socket {
117116
volatile unsigned _pending;
118117
rtos::Semaphore _read_sem;
119118
rtos::Semaphore _write_sem;
120-
bool _read_in_progress;
121-
bool _write_in_progress;
122119
};
123120

124121

0 commit comments

Comments
 (0)