{"action":"created","issue":{"url":"https://api.github.com/repos/heroku/logplex/issues/175","repository_url":"https://api.github.com/repos/heroku/logplex","labels_url":"https://api.github.com/repos/heroku/logplex/issues/175/labels{/name}","comments_url":"https://api.github.com/repos/heroku/logplex/issues/175/comments","events_url":"https://api.github.com/repos/heroku/logplex/issues/175/events","html_url":"https://github.com/heroku/logplex/pull/175","id":171745634,"number":175,"title":" Enable SO_REUSEADDR for backend connections","user":{"login":"ferd","id":111141,"avatar_url":"https://avatars.githubusercontent.com/u/111141?v=3","gravatar_id":"","url":"https://api.github.com/users/ferd","html_url":"https://github.com/ferd","followers_url":"https://api.github.com/users/ferd/followers","following_url":"https://api.github.com/users/ferd/following{/other_user}","gists_url":"https://api.github.com/users/ferd/gists{/gist_id}","starred_url":"https://api.github.com/users/ferd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ferd/subscriptions","organizations_url":"https://api.github.com/users/ferd/orgs","repos_url":"https://api.github.com/users/ferd/repos","events_url":"https://api.github.com/users/ferd/events{/privacy}","received_events_url":"https://api.github.com/users/ferd/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-08-17T19:55:44Z","updated_at":"2016-08-17T20:04:51Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/heroku/logplex/pulls/175","html_url":"https://github.com/heroku/logplex/pull/175","diff_url":"https://github.com/heroku/logplex/pull/175.diff","patch_url":"https://github.com/heroku/logplex/pull/175.patch"},"body":"The Erlang TCP stack translates a TCP `connect` call to a set of\r\nstandard operations in the linux kernel:\r\n\r\n- open a socket\r\n- bind(Socket, \"0.0.0.0\", 0)\r\n- connect(Socket, Ip, Port)\r\n\r\nSurprisingly enough, that `bind` call always happens and has the\r\nunfortunate side-effect of picking one of the currently unassigned ports\r\nin the ephemeral port range.\r\n\r\nThe negative aspect here is that despite TCP identifying connections by\r\n4-tuple (`{LocalIp, LocalPort, RemoteIp, RemotePort}`), which would let\r\nus use the entire ephemeral port range for each remote `IP:Port` combo,\r\nthe way Erlang uses them forces us to only the ephemeral port range due\r\nto the `bind` call's limitations.\r\n\r\nBy passing in `SO_REUSEADDR` (or in the case of Erlang, `{reuseaddr,\r\ntrue}`) we allow the bind call to reuse the ephemeral port. The check\r\nwill then be done by the connect syscall to see if the value is valid or\r\nnot (against the 4-tuple mapping). If the value is not valid, the error\r\nreturned will then be the POSIX code for `EADDRNOTAVAIL` (or just\r\n`eaddrnotavail` in Erlang).\r\n\r\nThis frees up the full port range and isolates one endpoint being\r\noverloaded from others suffering the same fate.\r\n\r\nOther clients (TCP and SSL log drains) already had the options on."},"comment":{"url":"https://api.github.com/repos/heroku/logplex/issues/comments/240530584","html_url":"https://github.com/heroku/logplex/pull/175#issuecomment-240530584","issue_url":"https://api.github.com/repos/heroku/logplex/issues/175","id":240530584,"user":{"login":"ferd","id":111141,"avatar_url":"https://avatars.githubusercontent.com/u/111141?v=3","gravatar_id":"","url":"https://api.github.com/users/ferd","html_url":"https://github.com/ferd","followers_url":"https://api.github.com/users/ferd/followers","following_url":"https://api.github.com/users/ferd/following{/other_user}","gists_url":"https://api.github.com/users/ferd/gists{/gist_id}","starred_url":"https://api.github.com/users/ferd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ferd/subscriptions","organizations_url":"https://api.github.com/users/ferd/orgs","repos_url":"https://api.github.com/users/ferd/repos","events_url":"https://api.github.com/users/ferd/events{/privacy}","received_events_url":"https://api.github.com/users/ferd/received_events","type":"User","site_admin":false},"created_at":"2016-08-17T20:04:51Z","updated_at":"2016-08-17T20:04:51Z","body":"@voidlock that's the basic fix but with tests failing I'd like to get through this with you when you're back in action."}}
{"actor":{"display_login":"ferd"}}