summaryrefslogtreecommitdiff
path: root/lib/connect.c
diff options
context:
space:
mode:
authorBjörn Stenberg <bjorn@haxx.se>2018-02-10 15:13:15 +0100
committerDaniel Stenberg <daniel@haxx.se>2018-02-15 09:36:03 +0100
commitb46cfbc068ebe90f18e9777b9e877e4934c1b5e3 (patch)
tree4d88b0f4d9492f51a93251e488400ff7a8abba62 /lib/connect.c
parent43a50a2580db2bfb28483a96964ae27b584472da (diff)
downloadcurl-b46cfbc068ebe90f18e9777b9e877e4934c1b5e3.tar.gz
TODO fixed: Detect when called from within callbacks
Closes #2302
Diffstat (limited to 'lib/connect.c')
-rw-r--r--lib/connect.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/connect.c b/lib/connect.c
index 3edb71eb7..d56cf2f16 100644
--- a/lib/connect.c
+++ b/lib/connect.c
@@ -1033,9 +1033,11 @@ static CURLcode singleipconnect(struct connectdata *conn,
if(data->set.fsockopt) {
/* activate callback for setting socket options */
+ Curl_set_in_callback(data, true);
error = data->set.fsockopt(data->set.sockopt_client,
sockfd,
CURLSOCKTYPE_IPCXN);
+ Curl_set_in_callback(data, false);
if(error == CURL_SOCKOPT_ALREADY_CONNECTED)
isconnected = TRUE;
@@ -1311,8 +1313,12 @@ int Curl_closesocket(struct connectdata *conn,
status */
conn->sock_accepted[SECONDARYSOCKET] = FALSE;
else {
+ int rc;
Curl_multi_closed(conn, sock);
- return conn->fclosesocket(conn->closesocket_client, sock);
+ Curl_set_in_callback(conn->data, true);
+ rc = conn->fclosesocket(conn->closesocket_client, sock);
+ Curl_set_in_callback(conn->data, false);
+ return rc;
}
}
@@ -1363,7 +1369,7 @@ CURLcode Curl_socket(struct connectdata *conn,
addr->addrlen = sizeof(struct Curl_sockaddr_storage);
memcpy(&addr->sa_addr, ai->ai_addr, addr->addrlen);
- if(data->set.fopensocket)
+ if(data->set.fopensocket) {
/*
* If the opensocket callback is set, all the destination address
* information is passed to the callback. Depending on this information the
@@ -1373,9 +1379,12 @@ CURLcode Curl_socket(struct connectdata *conn,
* might have been changed and this 'new' address will actually be used
* here to connect.
*/
+ Curl_set_in_callback(data, true);
*sockfd = data->set.fopensocket(data->set.opensocket_client,
CURLSOCKTYPE_IPCXN,
(struct curl_sockaddr *)addr);
+ Curl_set_in_callback(data, false);
+ }
else
/* opensocket callback not set, so simply create the socket now */
*sockfd = socket(addr->family, addr->socktype, addr->protocol);