mirror of
https://github.com/curl/curl.git
synced 2026-08-25 17:53:43 +03:00
cf-socket: optimize curlx_nonblock() and check its return error
Reviewed-by: Stefan Eissing Closes #13942
This commit is contained in:
parent
36e9222c42
commit
bd8e45c6c5
2 changed files with 29 additions and 7 deletions
|
|
@ -1234,12 +1234,25 @@ static CURLcode cf_socket_open(struct Curl_cfilter *cf,
|
|||
#endif
|
||||
|
||||
#ifndef SOCK_NONBLOCK
|
||||
/* set socket non-blocking */
|
||||
(void)curlx_nonblock(ctx->sock, TRUE);
|
||||
/* Set socket non-blocking, must be a non-blocking socket for
|
||||
* a non-blocking connect. */
|
||||
error = curlx_nonblock(ctx->sock, TRUE);
|
||||
if(error < 0) {
|
||||
result = CURLE_UNSUPPORTED_PROTOCOL;
|
||||
ctx->error = SOCKERRNO;
|
||||
goto out;
|
||||
}
|
||||
#else
|
||||
if(data->set.fopensocket)
|
||||
/* set socket non-blocking */
|
||||
(void)curlx_nonblock(ctx->sock, TRUE);
|
||||
if(data->set.fopensocket) {
|
||||
/* Set socket non-blocking, must be a non-blocking socket for
|
||||
* a non-blocking connect. */
|
||||
error = curlx_nonblock(ctx->sock, TRUE);
|
||||
if(error < 0) {
|
||||
result = CURLE_UNSUPPORTED_PROTOCOL;
|
||||
ctx->error = SOCKERRNO;
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
ctx->sock_connected = (ctx->addr.socktype != SOCK_DGRAM);
|
||||
out:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue