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.
pull/3065/head
Christopher Haster 2016-10-18 12:31:21 -05:00 committed by Russ Butler
parent 9976738882
commit 40836b11a5
2 changed files with 2 additions and 20 deletions

View File

@ -19,8 +19,7 @@
#include "mbed_assert.h"
UDPSocket::UDPSocket()
: _pending(0), _read_sem(0), _write_sem(0),
_read_in_progress(false), _write_in_progress(false)
: _pending(0), _read_sem(0), _write_sem(0)
{
}
@ -53,12 +52,6 @@ int UDPSocket::sendto(const SocketAddress &address, const void *data, unsigned s
_lock.lock();
int ret;
// If this assert is hit then there are two threads
// performing a send at the same time which is undefined
// behavior
MBED_ASSERT(!_write_in_progress);
_write_in_progress = true;
while (true) {
if (!_socket) {
ret = NSAPI_ERROR_NO_SOCKET;
@ -87,7 +80,6 @@ int UDPSocket::sendto(const SocketAddress &address, const void *data, unsigned s
}
}
_write_in_progress = false;
_lock.unlock();
return ret;
}
@ -97,12 +89,6 @@ int UDPSocket::recvfrom(SocketAddress *address, void *buffer, unsigned size)
_lock.lock();
int ret;
// If this assert is hit then there are two threads
// performing a recv at the same time which is undefined
// behavior
MBED_ASSERT(!_read_in_progress);
_read_in_progress = true;
while (true) {
if (!_socket) {
ret = NSAPI_ERROR_NO_SOCKET;
@ -131,7 +117,6 @@ int UDPSocket::recvfrom(SocketAddress *address, void *buffer, unsigned size)
}
}
_read_in_progress = false;
_lock.unlock();
return ret;
}

View File

@ -45,8 +45,7 @@ public:
*/
template <typename S>
UDPSocket(S *stack)
: _pending(0), _read_sem(0), _write_sem(0),
_read_in_progress(false), _write_in_progress(false)
: _pending(0), _read_sem(0), _write_sem(0)
{
open(stack);
}
@ -117,8 +116,6 @@ protected:
volatile unsigned _pending;
rtos::Semaphore _read_sem;
rtos::Semaphore _write_sem;
bool _read_in_progress;
bool _write_in_progress;
};