mirror of https://github.com/ARMmbed/mbed-os.git
Fix small issues from the review
parent
2b60e42756
commit
e7cb4752fa
|
@ -114,10 +114,10 @@ public:
|
|||
*/
|
||||
void set_port(uint16_t port);
|
||||
|
||||
/** Get the human readable IP address
|
||||
/** Get the human-readable IP address
|
||||
*
|
||||
* Allocates memory for a string and converts binary address to
|
||||
* human readable format. String is freed in the destructor.
|
||||
* human-readable format. String is freed in the destructor.
|
||||
*
|
||||
* @return Null-terminated representation of the IP Address
|
||||
*/
|
||||
|
@ -153,7 +153,7 @@ public:
|
|||
*/
|
||||
operator bool() const;
|
||||
|
||||
/** Copy addres from another SocketAddress
|
||||
/** Copy address from another SocketAddress
|
||||
*
|
||||
* @param addr SocketAddress to copy
|
||||
*/
|
||||
|
|
|
@ -249,21 +249,22 @@ TCPSocket *TCPSocket::accept(nsapi_error_t *error)
|
|||
{
|
||||
_lock.lock();
|
||||
TCPSocket *connection = NULL;
|
||||
nsapi_error_t ret;
|
||||
|
||||
_readers++;
|
||||
|
||||
while (true) {
|
||||
if (!_socket) {
|
||||
*error = NSAPI_ERROR_NO_SOCKET;
|
||||
ret = NSAPI_ERROR_NO_SOCKET;
|
||||
break;
|
||||
}
|
||||
|
||||
_pending = 0;
|
||||
void *socket;
|
||||
SocketAddress address;
|
||||
*error = _stack->socket_accept(_socket, &socket, &address);
|
||||
ret = _stack->socket_accept(_socket, &socket, &address);
|
||||
|
||||
if (0 == *error) {
|
||||
if (0 == ret) {
|
||||
TCPSocket *connection = new TCPSocket();
|
||||
connection->_lock.lock();
|
||||
connection->_factory_allocated = true; // Destroy automatically on close()
|
||||
|
@ -275,7 +276,7 @@ TCPSocket *TCPSocket::accept(nsapi_error_t *error)
|
|||
|
||||
connection->_lock.unlock();
|
||||
break;
|
||||
} else if ((_timeout == 0) || (*error != NSAPI_ERROR_WOULD_BLOCK)) {
|
||||
} else if ((_timeout == 0) || (ret != NSAPI_ERROR_WOULD_BLOCK)) {
|
||||
break;
|
||||
} else {
|
||||
uint32_t flag;
|
||||
|
@ -288,7 +289,7 @@ TCPSocket *TCPSocket::accept(nsapi_error_t *error)
|
|||
|
||||
if (flag & osFlagsError) {
|
||||
// Timeout break
|
||||
*error = NSAPI_ERROR_WOULD_BLOCK;
|
||||
ret = NSAPI_ERROR_WOULD_BLOCK;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -299,5 +300,8 @@ TCPSocket *TCPSocket::accept(nsapi_error_t *error)
|
|||
_event_flag.set(FINISHED_FLAG);
|
||||
}
|
||||
_lock.unlock();
|
||||
if (error) {
|
||||
*error = ret;
|
||||
}
|
||||
return connection;
|
||||
}
|
||||
|
|
|
@ -34,8 +34,6 @@ nsapi_protocol_t UDPSocket::get_proto()
|
|||
|
||||
nsapi_error_t UDPSocket::connect(const SocketAddress &address)
|
||||
{
|
||||
if (!address)
|
||||
return NSAPI_ERROR_PARAMETER;
|
||||
_remote_peer = address;
|
||||
return NSAPI_ERROR_OK;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue