aboutsummaryrefslogtreecommitdiff
path: root/lib/connect.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2011-12-05 11:42:10 +0100
committerDaniel Stenberg <daniel@haxx.se>2011-12-05 11:42:10 +0100
commit088ba97a2471c97e90fe7153dff0ce119faab4ef (patch)
tree20244866a27849b1b2126875f55d3c972aee6ea9 /lib/connect.c
parent9109cdec11ee5a19f132fd7bdf2e9ceefea4de41 (diff)
FTP: call opensocket callback properly
When the new socket is created for an active connection, it is now done using the open socket callback. Test case 596 was modified to run fine, although it hides the fact that the close callback is still called too many times, as it also gets called for closing sockets that were created with accept().
Diffstat (limited to 'lib/connect.c')
-rw-r--r--lib/connect.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/lib/connect.c b/lib/connect.c
index 2eef242d4..445261754 100644
--- a/lib/connect.c
+++ b/lib/connect.c
@@ -1119,8 +1119,10 @@ int Curl_closesocket(struct connectdata *conn,
/*
* Create a socket based on info from 'conn' and 'ai'.
*
- * Fill in 'addr' and 'sockfd' accordingly if OK is returned. If the open
- * socket callback is set, used that!
+ * 'addr' should be a pointer to the correct struct to get data back, or NULL.
+ * 'sockfd' must be a pointer to a socket descriptor.
+ *
+ * If the open socket callback is set, used that!
*
*/
CURLcode Curl_socket(struct connectdata *conn,
@@ -1129,9 +1131,11 @@ CURLcode Curl_socket(struct connectdata *conn,
curl_socket_t *sockfd)
{
struct SessionHandle *data = conn->data;
-#if defined(ENABLE_IPV6) && defined(HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID)
- struct sockaddr_in6 * const sa6 = (void *)&addr->sa_addr;
-#endif
+ struct Curl_sockaddr_ex dummy;
+
+ if(!addr)
+ /* if the caller doesn't want info back, use a local temp copy */
+ addr = &dummy;
/*
* The Curl_sockaddr_ex structure is basically libcurl's external API
@@ -1172,8 +1176,10 @@ CURLcode Curl_socket(struct connectdata *conn,
return CURLE_FAILED_INIT;
#if defined(ENABLE_IPV6) && defined(HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID)
- if(conn->scope && (addr->family == AF_INET6))
+ if(conn->scope && (addr->family == AF_INET6)) {
+ struct sockaddr_in6 * const sa6 = (void *)&addr->sa_addr;
sa6->sin6_scope_id = conn->scope;
+ }
#endif
return CURLE_OK;