diff options
author | Daniel Stenberg <daniel@haxx.se> | 2011-02-09 15:46:41 +0100 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2011-02-17 22:32:01 +0100 |
commit | 1c3c0162c62e2788373261a43f484ff401017d8a (patch) | |
tree | 4ab9b9b3e7ceb5db385c1e7377f4ffed7d14a597 /lib | |
parent | a40f58d2efac45dad7e12ea53870f42c825bcf0d (diff) |
SOCKOPTFUNCTION: callback can say already-connected
Introducing a few CURL_SOCKOPT* defines for conveniance. The new
CURL_SOCKOPT_ALREADY_CONNECTED signals to libcurl that the socket is to
be treated as already connected and thus it will skip the connect()
call.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/connect.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/connect.c b/lib/connect.c index fb21fb7df..261b2150e 100644 --- a/lib/connect.c +++ b/lib/connect.c @@ -837,7 +837,7 @@ singleipconnect(struct connectdata *conn, struct Curl_sockaddr_ex addr; int rc; int error; - bool isconnected; + bool isconnected = FALSE; struct SessionHandle *data = conn->data; curl_socket_t sockfd; CURLcode res = CURLE_OK; @@ -924,7 +924,10 @@ singleipconnect(struct connectdata *conn, error = data->set.fsockopt(data->set.sockopt_client, sockfd, CURLSOCKTYPE_IPCXN); - if(error) { + + if(error == CURL_SOCKOPT_ALREADY_CONNECTED) + isconnected = TRUE; + else if(error) { sclose(sockfd); /* close the socket and bail out */ return CURLE_ABORTED_BY_CALLBACK; } @@ -941,7 +944,7 @@ singleipconnect(struct connectdata *conn, curlx_nonblock(sockfd, TRUE); /* Connect TCP sockets, bind UDP */ - if(conn->socktype == SOCK_STREAM) { + if(!isconnected && (conn->socktype == SOCK_STREAM)) { rc = connect(sockfd, &addr.sa_addr, addr.addrlen); conn->connecttime = Curl_tvnow(); if(conn->num_addr > 1) @@ -989,7 +992,8 @@ singleipconnect(struct connectdata *conn, return CURLE_OK; } - isconnected = verifyconnect(sockfd, &error); + if(!isconnected) + isconnected = verifyconnect(sockfd, &error); if(!rc && isconnected) { /* we are connected, awesome! */ |