-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Cannot get connection information when using TCP Fast Open #1332
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
That looks wrong, it doesn't write a pointer it writes a long to the address you pass it --- a Thu Mar 16 17:02:35 2017
+++ b Thu Mar 16 17:08:38 2017
@@ -13,13 +13,10 @@
res = curl_easy_perform(curl);
if(CURLE_OK == res) {
- long *ct;
+ long ct;
res = curl_easy_getinfo(curl, CURLINFO_LOCAL_PORT, &ct);
-
- if((CURLE_OK == res) && ct == NULL) {
- printf("The operating was successful but we got nothing!\n");
- } else {
- printf("We used local port: %d\n", *ct);
+ if(CURLE_OK == res) {
+ printf("We used local port: %d\n", ct);
}
}
|
(I took this as an opportunity and added this as an example to the man page in 49f7b13) |
Despite the example he still has a point, it looks like the local port isn't saved when fastopen is used, see https://github.com/curl/curl/blob/curl-7_53_1/lib/connect.c#L674 |
hm, I wonder why that was made. I can't remember any discussions around that. Surely that would all work fine even with TFO ? |
So, I don't quite remember the reasoning behind this, but one possible explanation is that when |
That said, there might be a better way of avoiding that problem. |
AFAICT it's only called after the connection is made... or at least what I interpret that to be, I'm not familiar with TFO. It's only called these two places: |
And even if it was called before the connection is made, all the function calls within |
@jay define "connection is made" :) The TCP connection is initiated on the wire when curl starts sending the HTTP request (or whatever). That is when @bagder doesn't look graceful to me, given the |
It does print a bunch of |
And even if they do fail nicely, that still leaves the problem of getinfo returning nothing. Should |
Sorry for the example, I was attempting to replicate the problem I was finding in pycurl in C. I attempted the following in sendf.c but this didn't work:
I guess this is probably not how these functions work. Edit: maybe this should have been Curl_updateconninfo() instead of Curl_persistconninfo()? |
@irl hmm, that could be caused by the fact that a non-blocking socket is used. Another experiment would be to call I can't test right now, I'll look into this later. |
Yep, non-blocking socket issue. Adding I'm playing with setting a |
Pull request #1335 should solve this, just doing a little more testing. Edit: nope, needs more work. It's the right idea, and if you drop the clearing of the flags it works, but I think the test conditions in the if statements are wrong. |
When using non-blocking sockets, such as TCP Fast Open sockets, connection information may not be available at the time the socket is "created". For TCP Fast Open, the creation can even be a NOP as far as the network is concerned. This change adds tests to the Curl_send and Curl_recv functions to make further attempts at updating the connection information for as long as local_port in the connectdata struct is zero. Once a call to Curl_updateconninfo has succeeded, and so updated the local_port field, there will be no further calls to Curl_updateconninfo. Closes: curl#1332
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This is still an issue, a PR is waiting for review in #1847. |
I did this
Using the easy interface and the CURLOPT_TCP_FASTOPEN option, fetch a webpage. Then look for CURLINFO_LOCAL_PORT.
Instead of getting a port, I got a NULL, which is suboptimal for my use case.
I expected the following
A source port.
curl/libcurl version
operating system
Debian testing (curl 7.52.1-3)
The text was updated successfully, but these errors were encountered: