mirror of https://github.com/ARMmbed/mbed-os.git
Fixed incorrect semaphore handling on lwip connect and socket_connect
- Semaphore returns 0 on timeout, and negative was incorrect used for errors - Correctly checked error code on tcp_connect thanks to @LiyouZhou fixes #284, fixes #285, fixes #166pull/2231/head
parent
df5c05f38c
commit
d82bbb1c40
|
|
@ -110,7 +110,7 @@ int LWIPInterface::connect()
|
||||||
|
|
||||||
// Wait for an IP Address
|
// Wait for an IP Address
|
||||||
// -1: error, 0: timeout
|
// -1: error, 0: timeout
|
||||||
if (netif_up.wait(2500) < 0) {
|
if (netif_up.wait(2500) <= 0) {
|
||||||
return NSAPI_ERROR_DHCP_FAILURE;
|
return NSAPI_ERROR_DHCP_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -291,10 +291,10 @@ int LWIPInterface::socket_connect(void *handle, const SocketAddress &addr)
|
||||||
Semaphore connected(0);
|
Semaphore connected(0);
|
||||||
s->sem = &connected;
|
s->sem = &connected;
|
||||||
|
|
||||||
tcp_connect(s->tcp, &ip_addr, addr.get_port(), tcp_connect_irq);
|
err_t err = tcp_connect(s->tcp, &ip_addr, addr.get_port(), tcp_connect_irq);
|
||||||
|
|
||||||
// Wait for connection
|
// Wait for connection
|
||||||
if (connected.wait(1500) < 0) {
|
if (err || connected.wait(1500) <= 0) {
|
||||||
return NSAPI_ERROR_NO_CONNECTION;
|
return NSAPI_ERROR_NO_CONNECTION;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue