Skip to content
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

Happy eyeballs fixes #1928

Closed
wants to merge 4 commits into from
Closed

Conversation

Andersbakken
Copy link
Contributor

I have two patches for happy eyeballs.

3e50c6a
Fixes a race condition that can happen if the thread running libcurl gets preempted at certain times.

The following can happen:

  • Curl_connecthost is called at 0 ms. EXPIRE_HAPPY_EYEBALLS is set at 200ms.

thread is stalled a little bit:

  • singleipconnect is called at 3 ms
    conn->connecttime is set to 3ms

  • curl_multi_perform is called at 201 ms,
    struct curltime now = Curl_tvnow(); is set to 201

  • Curl_is_connected is called at 201 ms.
    This statement is false:
    curlx_tvdiff(now, conn->connecttime) >= HAPPY_EYEBALLS_TIMEOUT) {

  • curl_multi_perform removes the happy eyeballs timer since 201 >= 200 with this statement:
    multi->timetree = Curl_splaygetbest(now, multi->timetree, &t);
    The timer never fires.

ed1fb2d

adds a feature to set customize the 200ms delay for happy eyeballs to whatever one wants.

The timer should be started after conn->connecttime is set. Otherwise
the timer could expire without this condition being true:

       /* should we try another protocol family? */
       if(i == 0 && conn->tempaddr[1] == NULL &&
         curlx_tvdiff(now, conn->connecttime) >= HAPPY_EYEBALLS_TIMEOUT) {
Copy link
Member

@bagder bagder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ugh, nice catch!

Copy link
Member

@bagder bagder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'll need to edit symbols-in-versions too and add a man page for the new option. I think this option makes perfect sence and I'm +1 on adding it, but the new option needs to wait for the feature window after the pending release but the bugfix part can be cherry-picked already now.

@Andersbakken
Copy link
Contributor Author

I added docs and updated symbols-in-versions. I assumed 7.55.3 for the version. Is that correct?

Thanks.

bagder pushed a commit that referenced this pull request Sep 29, 2017
The timer should be started after conn->connecttime is set. Otherwise
the timer could expire without this condition being true:

    /* should we try another protocol family? */
    if(i == 0 && conn->tempaddr[1] == NULL &&
      curlx_tvdiff(now, conn->connecttime) >= HAPPY_EYEBALLS_TIMEOUT) {

Ref: #1928
@bagder
Copy link
Member

bagder commented Sep 29, 2017

I cherry-picked the first commit into master now, see 49d75a4

@bagder bagder added the feature-window A merge of this requires an open feature window label Sep 29, 2017
Andersbakken added a commit to Andersbakken/curl that referenced this pull request Oct 20, 2017
@bagder bagder removed the feature-window A merge of this requires an open feature window label Oct 28, 2017
@bagder
Copy link
Member

bagder commented Oct 28, 2017

@Andersbakken: If you can rebase this and fix the conflicts, we can work on merging this PR!

@lock lock bot locked as resolved and limited conversation to collaborators May 5, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants