casaroli opened a new pull request, #4166: URL: https://github.com/apache/nuttx-apps/pull/4166
## Summary When a signal interrupted the blocking `connect()` of `webclient_perform()`, webclient called `connect()` again in a loop and took `EISCONN` as success. POSIX `connect()`: "If connect() is interrupted by a signal that is caught while blocked waiting to establish a connection, connect() shall fail and set errno to [EINTR], but the connection request shall not be aborted, and the connection shall be established asynchronously." A second `connect()` while the handshake goes on gives `EALREADY` (Linux, and NuttX with apache/nuttx#22429), so webclient failed. Without that change NuttX gave `EISCONN` for a connection that never completed, and webclient took it as connected. - Commit 1: add the blank lines after declarations that nxstyle reports in `webclient.c` (whitespace only, `git diff -w --ignore-blank-lines` is empty). - Commit 2: after `EINTR`, webclient waits for the end of the connection with `poll(POLLOUT)`, for the timeout of the context (`timeout_sec`, as `SO_SNDTIMEO`), and takes the result from `SO_ERROR`. ## Impact Only the blocking `connect()` of webclient after a signal. The non-blocking mode and a `connect()` that is not interrupted do not change. The change is correct with and without apache/nuttx#22429: on the current NuttX master the wait ends at once with an error (the interrupted connection has no monitor), instead of a socket that is taken as connected but is not. ## Testing Builds with `-Werror` in the CI image: qemu-armv8a:nsh (flat) with `CONFIG_NETUTILS_WEBCLIENT`, on NuttX master and with apache/nuttx#22429. checkpatch passes. No runtime test: it needs an HTTP server that answers the SYN late and a signal during `connect()`; the same kernel behaviour is tested by `test_tun_tcp_connect_intr` (apache/nuttx-apps#4165). -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
