aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2001-10-31 08:44:11 +0000
committerDaniel Stenberg <daniel@haxx.se>2001-10-31 08:44:11 +0000
commitb07e2a08f9a98f7261d82f3ad5931ac5bcfb05a4 (patch)
tree8dcd7031f8a09389258633ab7da5d2e7e4702598 /lib
parent64543e09ecea6dc2b1d269cf4b83b5d86729bb01 (diff)
nonblock => Curl_nonblock, remade the check for a live SSL connection (again)
Diffstat (limited to 'lib')
-rw-r--r--lib/connect.c14
-rw-r--r--lib/connect.h3
-rw-r--r--lib/url.c23
3 files changed, 31 insertions, 9 deletions
diff --git a/lib/connect.c b/lib/connect.c
index b952d85e8..af98242c5 100644
--- a/lib/connect.c
+++ b/lib/connect.c
@@ -88,9 +88,9 @@ int geterrno(void)
* Description:
* Set the socket to either blocking or non-blocking mode.
*/
-static
-int nonblock(int socket, /* operate on this */
- int nonblock /* TRUE or FALSE */)
+
+int Curl_nonblock(int socket, /* operate on this */
+ int nonblock /* TRUE or FALSE */)
{
#undef SETBLOCK
#ifdef HAVE_O_NONBLOCK
@@ -389,7 +389,7 @@ CURLcode Curl_connecthost(struct connectdata *conn, /* context */
continue;
/* set socket non-blocking */
- nonblock(sockfd, TRUE);
+ Curl_nonblock(sockfd, TRUE);
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 */
- nonblock(sockfd, FALSE);
+ Curl_nonblock(sockfd, FALSE);
if(addr)
*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 */
- nonblock(sockfd, TRUE);
+ Curl_nonblock(sockfd, TRUE);
/* This is the loop that attempts to connect to all IP-addresses we
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 */
- nonblock(sockfd, FALSE);
+ Curl_nonblock(sockfd, FALSE);
if(addr)
/* this is the address we've connected to */
diff --git a/lib/connect.h b/lib/connect.h
index 8c5fac508..8d36365e5 100644
--- a/lib/connect.h
+++ b/lib/connect.h
@@ -23,6 +23,9 @@
* $Id$
*****************************************************************************/
+int Curl_nonblock(int socket, /* operate on this */
+ int nonblock /* TRUE or FALSE */);
+
CURLcode Curl_connecthost(struct connectdata *conn,
Curl_addrinfo *host, /* connect to this */
long port, /* connect to this port number */
diff --git a/lib/url.c b/lib/url.c
index bd01136d8..b11d33aac 100644
--- a/lib/url.c
+++ b/lib/url.c
@@ -955,8 +955,27 @@ static bool SocketIsDead(struct connectdata *conn, int sock)
#ifdef USE_SSLEAY
/* the socket seems fine, but is the SSL later fine too? */
if(conn->ssl.use) {
- if(SSL_get_shutdown(conn->ssl.handle))
- return TRUE; /* this connection is dead! */
+ int peek;
+ 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
}