aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/connect.c12
-rw-r--r--lib/ftp.c1
-rw-r--r--lib/urldata.h3
-rw-r--r--tests/data/test5961
4 files changed, 11 insertions, 6 deletions
diff --git a/lib/connect.c b/lib/connect.c
index 445261754..a560c4d3b 100644
--- a/lib/connect.c
+++ b/lib/connect.c
@@ -1110,10 +1110,14 @@ curl_socket_t Curl_getconnectinfo(struct SessionHandle *data,
int Curl_closesocket(struct connectdata *conn,
curl_socket_t sock)
{
- if(conn && conn->fclosesocket)
- return conn->fclosesocket(conn->closesocket_client, sock);
- else
- return sclose(sock);
+ if(conn && conn->fclosesocket) {
+ if((sock != conn->sock[SECONDARYSOCKET]) ||
+ !conn->sock_accepted[SECONDARYSOCKET])
+ /* if this socket matches the second socket, and that was created with
+ accept, then we MUST NOT call the callback */
+ return conn->fclosesocket(conn->closesocket_client, sock);
+ }
+ return sclose(sock);
}
/*
diff --git a/lib/ftp.c b/lib/ftp.c
index 38a5f10c9..b64ef6265 100644
--- a/lib/ftp.c
+++ b/lib/ftp.c
@@ -368,6 +368,7 @@ static CURLcode AllowServerConnect(struct connectdata *conn)
conn->sock[SECONDARYSOCKET] = s;
curlx_nonblock(s, TRUE); /* enable non-blocking */
+ conn->sock_accepted[SECONDARYSOCKET] = TRUE;
return CURLE_OK;
} /* switch() */
}
diff --git a/lib/urldata.h b/lib/urldata.h
index 55f0a7b85..53df18cab 100644
--- a/lib/urldata.h
+++ b/lib/urldata.h
@@ -816,7 +816,8 @@ struct connectdata {
struct timeval created; /* creation time */
curl_socket_t sock[2]; /* two sockets, the second is used for the data
transfer when doing FTP */
-
+ bool sock_accepted[2]; /* TRUE if the socket on this index was created with
+ accept() */
Curl_recv *recv[2];
Curl_send *send[2];
diff --git a/tests/data/test596 b/tests/data/test596
index 73e8a78d5..bb5def43f 100644
--- a/tests/data/test596
+++ b/tests/data/test596
@@ -19,7 +19,6 @@ moo
[CLOSE] counter: 2
moo
[CLOSE] counter: 1
-[CLOSE] counter: 0
</datacheck>
</reply>