aboutsummaryrefslogtreecommitdiff
path: root/lib/getinfo.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2006-05-10 22:17:42 +0000
committerDaniel Stenberg <daniel@haxx.se>2006-05-10 22:17:42 +0000
commitc9c5ce23652db79f36925c1509a15ddf4f665422 (patch)
tree1bbae2f759500f21219e6df3d77354798409ba06 /lib/getinfo.c
parent975534370f111f341e7fb659e1df41f41247cde1 (diff)
David McCreedy provided a fix for CURLINFO_LASTSOCKET that does extended
checks on the to-be-returned socket to make sure it truly seems to be alive and well. For SSL connection it (only) uses OpenSSL functions.
Diffstat (limited to 'lib/getinfo.c')
-rw-r--r--lib/getinfo.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/lib/getinfo.c b/lib/getinfo.c
index c7b4cfa4a..d74fbcf3c 100644
--- a/lib/getinfo.c
+++ b/lib/getinfo.c
@@ -75,6 +75,8 @@ CURLcode Curl_getinfo(struct SessionHandle *data, CURLINFO info, ...)
double *param_doublep=NULL;
char **param_charp=NULL;
struct curl_slist **param_slistp=NULL;
+ char buf;
+
va_start(arg, info);
switch(info&CURLINFO_TYPEMASK) {
@@ -197,9 +199,23 @@ CURLcode Curl_getinfo(struct SessionHandle *data, CURLINFO info, ...)
break;
case CURLINFO_LASTSOCKET:
if((data->state.lastconnect != -1) &&
- (data->state.connects[data->state.lastconnect] != NULL))
+ (data->state.connects[data->state.lastconnect] != NULL)) {
*param_longp = data->state.connects[data->state.lastconnect]->
sock[FIRSTSOCKET];
+ /* we have a socket connected, let's determine if the server shut down */
+ /* determine if ssl */
+ if(data->state.connects[data->state.lastconnect]->protocol & PROT_SSL) {
+ /* use the SSL context */
+ if (!Curl_ssl_check_cxn(data->state.connects[data->state.lastconnect]))
+ *param_longp = -1; /* FIN received */
+ }
+ else {
+ /* use the socket */
+ if(recv((int)data->state.connects[data->state.lastconnect]->
+ sock[FIRSTSOCKET], (void*)&buf, 1, MSG_PEEK) == 0)
+ *param_longp = -1; /* FIN received */
+ }
+ }
else
*param_longp = -1;
break;