Skip to content

Commit 98029e3

Browse files
authored
Merge pull request #3065 from geky/nsapi-remove-same-thread-asserts
nsapi - Remove assertions on same-thread send/recv
2 parents 9d8ec61 + 40836b1 commit 98029e3

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 @@ nsapi_size_or_error_t UDPSocket::sendto(const SocketAddress &address, const void
5352
_lock.lock();
5453
nsapi_size_or_error_t 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 @@ nsapi_size_or_error_t UDPSocket::sendto(const SocketAddress &address, const void
8780
}
8881
}
8982

90-
_write_in_progress = false;
9183
_lock.unlock();
9284
return ret;
9385
}
@@ -97,12 +89,6 @@ nsapi_size_or_error_t UDPSocket::recvfrom(SocketAddress *address, void *buffer,
9789
_lock.lock();
9890
nsapi_size_or_error_t 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 @@ nsapi_size_or_error_t UDPSocket::recvfrom(SocketAddress *address, void *buffer,
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
}
@@ -120,8 +119,6 @@ class UDPSocket : public Socket {
120119
volatile unsigned _pending;
121120
rtos::Semaphore _read_sem;
122121
rtos::Semaphore _write_sem;
123-
bool _read_in_progress;
124-
bool _write_in_progress;
125122
};
126123

127124

0 commit comments

Comments
 (0)