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/3290/head
Christopher Haster 2016-10-18 12:31:21 -05:00 committed by Anna Bridge
parent 6918c960c2
commit 16bba05f4e
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 @@ nsapi_size_or_error_t UDPSocket::sendto(const SocketAddress &address, const void
_lock.lock();
nsapi_size_or_error_t 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 @@ nsapi_size_or_error_t UDPSocket::sendto(const SocketAddress &address, const void
}
}
_write_in_progress = false;
_lock.unlock();
return ret;
}
@ -97,12 +89,6 @@ nsapi_size_or_error_t UDPSocket::recvfrom(SocketAddress *address, void *buffer,
_lock.lock();
nsapi_size_or_error_t 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 @@ nsapi_size_or_error_t UDPSocket::recvfrom(SocketAddress *address, void *buffer,
}
}
_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);
}
@ -120,8 +119,6 @@ protected:
volatile unsigned _pending;
rtos::Semaphore _read_sem;
rtos::Semaphore _write_sem;
bool _read_in_progress;
bool _write_in_progress;
};