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
base: master
from

Conversation

Projects
None yet
2 participants
@Andersbakken
Contributor

Andersbakken commented Sep 28, 2017

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.

Andersbakken added some commits Sep 28, 2017

Fix race condition with happy eyeballs timeout.
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) {
@bagder

bagder approved these changes Sep 28, 2017

Ugh, nice catch!

@bagder

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

This comment has been minimized.

Show comment
Hide comment
@Andersbakken

Andersbakken Sep 28, 2017

Contributor

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

Thanks.

Contributor

Andersbakken commented Sep 28, 2017

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

Thanks.

bagder added a commit that referenced this pull request Sep 29, 2017

connect: fix race condition with happy eyeballs timeout
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

This comment has been minimized.

Show comment
Hide comment
@bagder

bagder Sep 29, 2017

Member

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

Member

bagder commented Sep 29, 2017

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

Andersbakken added a commit to Andersbakken/curl that referenced this pull request Oct 20, 2017

@bagder

This comment has been minimized.

Show comment
Hide comment
@bagder

bagder Oct 28, 2017

Member

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

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.