mirror of
https://github.com/moparisthebest/curl
synced 2024-12-21 23:58:49 -05:00
nonblock => Curl_nonblock, remade the check for a live SSL connection (again)
This commit is contained in:
parent
64543e09ec
commit
b07e2a08f9
@ -88,8 +88,8 @@ int geterrno(void)
|
|||||||
* Description:
|
* Description:
|
||||||
* Set the socket to either blocking or non-blocking mode.
|
* Set the socket to either blocking or non-blocking mode.
|
||||||
*/
|
*/
|
||||||
static
|
|
||||||
int nonblock(int socket, /* operate on this */
|
int Curl_nonblock(int socket, /* operate on this */
|
||||||
int nonblock /* TRUE or FALSE */)
|
int nonblock /* TRUE or FALSE */)
|
||||||
{
|
{
|
||||||
#undef SETBLOCK
|
#undef SETBLOCK
|
||||||
@ -389,7 +389,7 @@ CURLcode Curl_connecthost(struct connectdata *conn, /* context */
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* set socket non-blocking */
|
/* set socket non-blocking */
|
||||||
nonblock(sockfd, TRUE);
|
Curl_nonblock(sockfd, TRUE);
|
||||||
|
|
||||||
rc = connect(sockfd, ai->ai_addr, ai->ai_addrlen);
|
rc = connect(sockfd, ai->ai_addr, ai->ai_addrlen);
|
||||||
|
|
||||||
@ -450,7 +450,7 @@ CURLcode Curl_connecthost(struct connectdata *conn, /* context */
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* now disable the non-blocking mode again */
|
/* now disable the non-blocking mode again */
|
||||||
nonblock(sockfd, FALSE);
|
Curl_nonblock(sockfd, FALSE);
|
||||||
|
|
||||||
if(addr)
|
if(addr)
|
||||||
*addr = ai; /* the address we ended up connected to */
|
*addr = ai; /* the address we ended up connected to */
|
||||||
@ -481,7 +481,7 @@ CURLcode Curl_connecthost(struct connectdata *conn, /* context */
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Convert socket to non-blocking type */
|
/* Convert socket to non-blocking type */
|
||||||
nonblock(sockfd, TRUE);
|
Curl_nonblock(sockfd, TRUE);
|
||||||
|
|
||||||
/* This is the loop that attempts to connect to all IP-addresses we
|
/* This is the loop that attempts to connect to all IP-addresses we
|
||||||
know for the given host. One by one. */
|
know for the given host. One by one. */
|
||||||
@ -546,7 +546,7 @@ CURLcode Curl_connecthost(struct connectdata *conn, /* context */
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* now disable the non-blocking mode again */
|
/* now disable the non-blocking mode again */
|
||||||
nonblock(sockfd, FALSE);
|
Curl_nonblock(sockfd, FALSE);
|
||||||
|
|
||||||
if(addr)
|
if(addr)
|
||||||
/* this is the address we've connected to */
|
/* this is the address we've connected to */
|
||||||
|
@ -23,6 +23,9 @@
|
|||||||
* $Id$
|
* $Id$
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
|
int Curl_nonblock(int socket, /* operate on this */
|
||||||
|
int nonblock /* TRUE or FALSE */);
|
||||||
|
|
||||||
CURLcode Curl_connecthost(struct connectdata *conn,
|
CURLcode Curl_connecthost(struct connectdata *conn,
|
||||||
Curl_addrinfo *host, /* connect to this */
|
Curl_addrinfo *host, /* connect to this */
|
||||||
long port, /* connect to this port number */
|
long port, /* connect to this port number */
|
||||||
|
23
lib/url.c
23
lib/url.c
@ -955,8 +955,27 @@ static bool SocketIsDead(struct connectdata *conn, int sock)
|
|||||||
#ifdef USE_SSLEAY
|
#ifdef USE_SSLEAY
|
||||||
/* the socket seems fine, but is the SSL later fine too? */
|
/* the socket seems fine, but is the SSL later fine too? */
|
||||||
if(conn->ssl.use) {
|
if(conn->ssl.use) {
|
||||||
if(SSL_get_shutdown(conn->ssl.handle))
|
int peek;
|
||||||
return TRUE; /* this connection is dead! */
|
int error;
|
||||||
|
Curl_nonblock(sock, TRUE);
|
||||||
|
|
||||||
|
peek = SSL_peek(conn->ssl.handle,
|
||||||
|
conn->data->state.buffer, BUFSIZE);
|
||||||
|
|
||||||
|
infof(conn->data, "SSL_peek returned %d\n", peek);
|
||||||
|
|
||||||
|
if(-1 == peek) {
|
||||||
|
error = SSL_get_error(conn->ssl.handle, peek);
|
||||||
|
infof(conn->data, "SSL_error returned %d\n", error);
|
||||||
|
|
||||||
|
if(SSL_ERROR_WANT_READ != error)
|
||||||
|
ret_val = TRUE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
/* peek did not return -1 */
|
||||||
|
ret_val = TRUE;
|
||||||
|
|
||||||
|
Curl_nonblock(sock, FALSE);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user