getconnectinfo: Don't call recv(2) if socket == -1

Closes #528
This commit is contained in:
Anders Bakken 2015-11-16 12:50:41 -08:00 committed by Daniel Stenberg
parent 6c5f4303fe
commit a72207ecf0
1 changed files with 2 additions and 2 deletions

View File

@ -1242,10 +1242,10 @@ curl_socket_t Curl_getconnectinfo(struct SessionHandle *data,
}
/* Minix 3.1 doesn't support any flags on recv; just assume socket is OK */
#ifdef MSG_PEEK
else {
else if(sockfd != CURL_SOCKET_BAD) {
/* use the socket */
char buf;
if(recv((RECV_TYPE_ARG1)c->sock[FIRSTSOCKET], (RECV_TYPE_ARG2)&buf,
if(recv((RECV_TYPE_ARG1)sockfd, (RECV_TYPE_ARG2)&buf,
(RECV_TYPE_ARG3)1, (RECV_TYPE_ARG4)MSG_PEEK) == 0) {
return CURL_SOCKET_BAD; /* FIN received */
}