Merge pull request #3065 from geky/nsapi-remove-same-thread-asserts

nsapi - Remove assertions on same-thread send/recv
pull/3278/head
Martin Kojtal 2016-11-16 17:41:13 +00:00 committed by GitHub
commit 98029e3906
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;
};