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

Allow specification of the local network interface for HTTP requests. Fixes #1389. #1407

Merged
merged 8 commits into from
Feb 15, 2016

Conversation

s-ludwig
Copy link
Member

@s-ludwig s-ludwig commented Feb 8, 2016

This adds HTTPClientSettings.networkInterface and a bind_address parameter for connectTCP. See #1389.

@s-ludwig s-ludwig force-pushed the issue1389-outgoing-interface branch 2 times, most recently from cac3124 to 6dfe181 Compare February 9, 2016 17:01
@s-ludwig s-ludwig force-pushed the issue1389-outgoing-interface branch from 6dfe181 to 70b4cc5 Compare February 9, 2016 21:44
@s-ludwig
Copy link
Member Author

@japplegame: Merging this now. I'll create an alpha tag afterwards for testing. Let me know if anything is missing.

s-ludwig added a commit that referenced this pull request Feb 15, 2016
…erface

Allow specification of the local network interface for HTTP requests. Fixes #1389.
@s-ludwig s-ludwig merged commit 4d34041 into master Feb 15, 2016
@japplegame
Copy link
Contributor

Thanks. I'll test it soon.

@japplegame
Copy link
Contributor

I started testing this on our high load beta-server. vibe.d 0.7.28 + this PR.
Lets wait a few days.

@s-ludwig s-ludwig deleted the issue1389-outgoing-interface branch February 29, 2016 13:23
@etcimon
Copy link
Contributor

etcimon commented Feb 29, 2016

Does this actually work for libasync? It looks like tcp.ip is replaced by the tcp.peer assignment. I don't think there's any underlying support for this yet

@etcimon
Copy link
Contributor

etcimon commented Feb 29, 2016

Looks like a one-liner

https://idea.popcount.org/2014-04-03-bind-before-connect/

@etcimon
Copy link
Contributor

etcimon commented Feb 29, 2016

It's likely to throw on EADDRINUSE when the port is specified, should be important to document it

@japplegame
Copy link
Contributor

After about 30 minutes the server crashed.
I'm not sure that this PR is the reason, but so far I am unable to test it.
At the moment our production server runs on vibe.d 0.7.26. This version is stable enough.

Core dump backtrace:

#0  0x0000000000acff58 in rt.deh_win64_posix.terminate() ()
#1  0x0000000000a75078 in _d_throwc ()
#2  0x0000000000a6dc4a in _d_assert_msg ()
#3  0x00000000009d67d0 in vibe.core.core.VibeDriverCore.resumeCoreTask() (this=0x7fce99995900, event_exception=0x0, ctask=0x7fce46006600) at ../forks/vibe.d-0.7.28/source/vibe/core/core.d:1239
#4  0x00000000009d66b2 in vibe.core.core.VibeDriverCore.resumeTask() (this=0x7fce99995900, initial_resume=false, event_exception=0x0, task=...) at ../forks/vibe.d-0.7.28/source/vibe/core/core.d:1232
#5  0x00000000009d641c in vibe.core.core.VibeDriverCore.resumeTask() (this=0x7fce99995900, event_exception=0x0, task=...) at ../forks/vibe.d-0.7.28/source/vibe/core/core.d:1208
#6  0x00000000009da759 in vibe.core.drivers.libevent2.Libevent2Driver.processTimers() (this=0x7ffefd9e52b8, data=..., periodic=false, timer=56540) at ../forks/vibe.d-0.7.28/source/vibe/core/drivers/libevent2.d:488
#7  0x00000000009e53fb in vibe.core.drivers.timerqueue.__T10TimerQueueTS4vibe4core7drivers9libevent29TimerInfoVli10000Z.TimerQueue.consumeTimeouts() (this=..., del=..., now=...)
    at ../forks/vibe.d-0.7.28/source/vibe/core/drivers/timerqueue.d:107
#8  0x00000000009da670 in vibe.core.drivers.libevent2.Libevent2Driver.processTimers() (this=0x7fce99994500) at ../forks/vibe.d-0.7.28/source/vibe/core/drivers/libevent2.d:480
#9  0x00000000009da996 in vibe.core.drivers.libevent2.Libevent2Driver.onTimerTimeout() (_param_0=-1, events=1, userptr=0x7fce99994500) at ../forks/vibe.d-0.7.28/source/vibe/core/drivers/libevent2.d:518
#10 0x00007fce99450a14 in event_base_loop () from /lib64/libevent-2.0.so.5
#11 0x00000000009d8aff in vibe.core.drivers.libevent2.Libevent2Driver.processEvents() (this=0x7fce99994500) at ../forks/vibe.d-0.7.28/source/vibe/core/drivers/libevent2.d:215
#12 0x00000000009d6aa0 in vibe.core.core.VibeDriverCore.notifyIdle() (this=0x7fce99995900) at ../forks/vibe.d-0.7.28/source/vibe/core/core.d:1277
#13 0x00000000009d89a3 in vibe.core.drivers.libevent2.Libevent2Driver.runEventLoop() (this=0x7fce99994500) at ../forks/vibe.d-0.7.28/source/vibe/core/drivers/libevent2.d:198
#14 0x00000000009d468a in vibe.core.core.runEventLoop() () at ../forks/vibe.d-0.7.28/source/vibe/core/core.d:97
#15 0x0000000000911551 in application.ApplicationImpl.__T3runS29_D10dispatcher10__lambda21FZvZ.run() (this=0x7fce9999d940) at libs/misc/source/application.d:120
#16 0x0000000000906d4b in D main () at libs/misc/source/application.d:139
#17 0x0000000000a755c3 in rt.dmain2._d_run_main() ()
#18 0x0000000000a75519 in rt.dmain2._d_run_main() ()
#19 0x0000000000a7557f in rt.dmain2._d_run_main() ()
#20 0x0000000000a75519 in rt.dmain2._d_run_main() ()
#21 0x0000000000a75476 in _d_run_main ()
#22 0x000000000091fb10 in main ()

@japplegame
Copy link
Contributor

command used for patching:

git checkout tags/v.0.7.28
patch -p1 < 1407.diff

where 1407.diff is https://patch-diff.githubusercontent.com/raw/rejectedsoftware/vibe.d/pull/1407.diff

@s-ludwig
Copy link
Member Author

If you were running on 0.7.27/28, I would have said that it may be the newly added assertions in runCoreTask, but since it's just a patched version of 0.7.26...

But I have no idea how it could relate to this PR, except maybe that it changes the timing (connecting is slightly slower due to the additional bind call). Did you get the assertion message, or did it terminate before printing it?

@japplegame
Copy link
Contributor

No! It was patched 0.7.28 not 0.7.26.
Unfortunately 0.7.26 with this PR doesn't work at all (Peer failed the certificate validation: 20).

@japplegame
Copy link
Contributor

assertion message

Manually resuming task that is already scheduled to be resumed.

Source: https://github.com/rejectedsoftware/vibe.d/blob/v0.7.28/source/vibe/core/core.d#L1239

@japplegame
Copy link
Contributor

Also I tried 0.7.29.alpha.2 and got the same assertion.

@s-ludwig
Copy link
Member Author

Ah okay, that makes more sense then. I can't fight the feeling that the assertion is unfortunately too strict in practice. It helped to catch some bugs, but it also caused a rather bad one (#1441) and in most situations it's actually harmless to redundantly schedule a task for resumption. I'll weaken the assertion condition to only catch the actually critical cases.

s-ludwig added a commit that referenced this pull request Feb 29, 2016
This assertion got triggered in a number of harmless situations and it's not always easy to avoid. Trying to avoid it, it has already caused a rather bad task starvation bug (#1441), so at this point it seems to be better to get rid of it.

See also #1407
@s-ludwig
Copy link
Member Author

Okay, you could try to add 621e34b into the patch and do another test run.

@japplegame
Copy link
Contributor

Ok. Testing...

@japplegame
Copy link
Contributor

Well done. It works very well.

@s-ludwig
Copy link
Member Author

s-ludwig commented Mar 5, 2016

Good to know! If you should ever run into the limitation of maximum outgoing connections, we could add the more relaxed approach that Etienne linked to as an option (but for now I think the basic bind-before-connect approach is the better choice).

s-ludwig added a commit that referenced this pull request Apr 10, 2016
This assertion got triggered in a number of harmless situations and it's not always easy to avoid. Trying to avoid it, it has already caused a rather bad task starvation bug (#1441), so at this point it seems to be better to get rid of it.

See also #1407

(cherry picked from commit 621e34b)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants