mirror of
https://github.com/obgm/libcoap.git
synced 2026-11-21 23:05:15 +03:00
coap_io.c: Set COAP_SOCKET_CONNECTED if connect does not complete for TCP
If the non-blocking connect() does not immediately complete, when the main i/o processing loop runs and coap_read is called, coap_read_session() will assert if COAP_SOCKET_CONNECTED is not set as there will be some TLS level packets to process. If WSAEWOULDBLOCK/EINPROGRESS is returned from the connect() set COAP_SOCKET_CONNECTED in the socket flags.
This commit is contained in:
1 parent
3870bfc809
commit
5969ae7633
1 file changed
+6
-1
+6
-1
@@ -312,7 +312,12 @@ coap_socket_connect_tcp1(coap_socket_t *sock,
|
||||
#else
|
||||
if (errno == EINPROGRESS) {
|
||||
#endif
|
||||
sock->flags |= COAP_SOCKET_WANT_CONNECT;
|
||||
/*
|
||||
* COAP_SOCKET_CONNECTED needs to be set here as there will be reads/writes
|
||||
* by underlying TLS libraries during connect() and we do not want to
|
||||
* assert() in coap_read_session() or coap_write_session() when called by coap_read()
|
||||
*/
|
||||
sock->flags |= COAP_SOCKET_WANT_CONNECT | COAP_SOCKET_CONNECTED;
|
||||
return 1;
|
||||
}
|
||||
coap_log(LOG_WARNING, "coap_socket_connect_tcp1: connect: %s\n", coap_socket_strerror());
|
||||
|
||||
Reference in new issue
Block a user