aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/connect.c1
-rw-r--r--lib/tftp.c7
-rw-r--r--lib/urldata.h2
3 files changed, 7 insertions, 3 deletions
diff --git a/lib/connect.c b/lib/connect.c
index d386a1bc5..918602c2d 100644
--- a/lib/connect.c
+++ b/lib/connect.c
@@ -380,6 +380,7 @@ static CURLcode bindlocal(struct connectdata *conn,
port = ntohs(((struct sockaddr_in6 *)&add)->sin6_port);
#endif
infof(data, "Local port: %d\n", port);
+ conn->bits.bound = TRUE;
return CURLE_OK;
}
if(--portnum > 0) {
diff --git a/lib/tftp.c b/lib/tftp.c
index a3a69cf6c..938c2e239 100644
--- a/lib/tftp.c
+++ b/lib/tftp.c
@@ -598,9 +598,9 @@ CURLcode Curl_tftp_connect(struct connectdata *conn, bool *done)
tftp_set_timeouts(state);
- if(!conn->bits.reuse) {
- /* If not reused, bind to any interface, random UDP port. If it is reused,
- * this has already been done!
+ if(!conn->bits.bound) {
+ /* If not already bound, bind to any interface, random UDP port. If it is
+ * reused or a custom local port was desired, this has already been done!
*
* We once used the size of the local_addr struct as the third argument for
* bind() to better work with IPv6 or whatever size the struct could have,
@@ -619,6 +619,7 @@ CURLcode Curl_tftp_connect(struct connectdata *conn, bool *done)
Curl_strerror(conn, SOCKERRNO));
return CURLE_COULDNT_CONNECT;
}
+ conn->bits.bound = TRUE;
}
Curl_pgrsStartNow(conn->data);
diff --git a/lib/urldata.h b/lib/urldata.h
index 51844c4ba..52647a1cb 100644
--- a/lib/urldata.h
+++ b/lib/urldata.h
@@ -609,6 +609,8 @@ struct ConnectBits {
bool proxy_connect_closed; /* set true if a proxy disconnected the
connection in a CONNECT request with auth, so
that libcurl should reconnect and continue. */
+ bool bound; /* set true if bind() has already been done on this socket/
+ connection */
};
struct hostname {