{"action":"created","issue":{"url":"https://api.github.com/repos/cesanta/mongoose/issues/637","repository_url":"https://api.github.com/repos/cesanta/mongoose","labels_url":"https://api.github.com/repos/cesanta/mongoose/issues/637/labels{/name}","comments_url":"https://api.github.com/repos/cesanta/mongoose/issues/637/comments","events_url":"https://api.github.com/repos/cesanta/mongoose/issues/637/events","html_url":"https://github.com/cesanta/mongoose/pull/637","id":145795012,"number":637,"title":"Fix epoll() accept bug.","user":{"login":"marayl","id":53999,"avatar_url":"https://avatars.githubusercontent.com/u/53999?v=3","gravatar_id":"","url":"https://api.github.com/users/marayl","html_url":"https://github.com/marayl","followers_url":"https://api.github.com/users/marayl/followers","following_url":"https://api.github.com/users/marayl/following{/other_user}","gists_url":"https://api.github.com/users/marayl/gists{/gist_id}","starred_url":"https://api.github.com/users/marayl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marayl/subscriptions","organizations_url":"https://api.github.com/users/marayl/orgs","repos_url":"https://api.github.com/users/marayl/repos","events_url":"https://api.github.com/users/marayl/events{/privacy}","received_events_url":"https://api.github.com/users/marayl/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-04-04T20:29:57Z","updated_at":"2016-04-05T08:55:13Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/cesanta/mongoose/pulls/637","html_url":"https://github.com/cesanta/mongoose/pull/637","diff_url":"https://github.com/cesanta/mongoose/pull/637.diff","patch_url":"https://github.com/cesanta/mongoose/pull/637.patch"},"body":"The `mg_ev_mgr_epoll_ctl()` function calls `abort()` after encountering the following error when a client TCP connection is accepted:\r\n\r\n`epoll_ctl(5, EPOLL_CTL_MOD, 7, {EPOLLIN, {u32=20605408, u64=749695152056800}}) = -1 ENOENT (No such file or directory)`\r\n\r\nN.B. `-DMG_MGR_EV_MGR=1` is used to enable `epoll()` on Linux.\r\n\r\nThe problem is that `mg_add_conn()` is called in `mg_if_accept_new_conn()` before `mg_sock_set()` has set the socket descriptor for the new connection:\r\n\r\n`mg_ev_mgr_epoll_ctl  0x144c9e0 -1 1`\r\n`mg_if_accept_new_conn 0x144fa68 0x144c9e0 -1 0, (nil) (nil)`\r\n`mg_sock_set          0x144c9e0 7`\r\n\r\nCaveat: the extent of my testing has been limited to plain TCP sockets, so similar problems may exist elsewhere (such as SSL).\n\n<!-- Reviewable:start -->\n---\nThis change is [<img src=\"https://reviewable.io/review_button.svg\" height=\"35\" align=\"absmiddle\" alt=\"Reviewable\"/>](https://reviewable.io/reviews/cesanta/mongoose/637)\n<!-- Reviewable:end -->\n"},"comment":{"url":"https://api.github.com/repos/cesanta/mongoose/issues/comments/205720143","html_url":"https://github.com/cesanta/mongoose/pull/637#issuecomment-205720143","issue_url":"https://api.github.com/repos/cesanta/mongoose/issues/637","id":205720143,"user":{"login":"rojer","id":531307,"avatar_url":"https://avatars.githubusercontent.com/u/531307?v=3","gravatar_id":"","url":"https://api.github.com/users/rojer","html_url":"https://github.com/rojer","followers_url":"https://api.github.com/users/rojer/followers","following_url":"https://api.github.com/users/rojer/following{/other_user}","gists_url":"https://api.github.com/users/rojer/gists{/gist_id}","starred_url":"https://api.github.com/users/rojer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rojer/subscriptions","organizations_url":"https://api.github.com/users/rojer/orgs","repos_url":"https://api.github.com/users/rojer/repos","events_url":"https://api.github.com/users/rojer/events{/privacy}","received_events_url":"https://api.github.com/users/rojer/received_events","type":"User","site_admin":false},"created_at":"2016-04-05T08:55:12Z","updated_at":"2016-04-05T08:55:12Z","body":"the truth is, epoll support is broken, in more ways than one.\r\nit also does not bring much benefit, as we still have to walk the list of connections to deliver polls.\r\ndo you see a big difference versus select()?"}}