{"action":"closed","issue":{"url":"https://api.github.com/repos/carllerche/mio/issues/350","repository_url":"https://api.github.com/repos/carllerche/mio","labels_url":"https://api.github.com/repos/carllerche/mio/issues/350/labels{/name}","comments_url":"https://api.github.com/repos/carllerche/mio/issues/350/comments","events_url":"https://api.github.com/repos/carllerche/mio/issues/350/events","html_url":"https://github.com/carllerche/mio/issues/350","id":132187703,"number":350,"title":"EventLoop::io_poll blocks the thread on the second run","user":{"login":"workanator","id":15566341,"avatar_url":"https://avatars.githubusercontent.com/u/15566341?v=3","gravatar_id":"","url":"https://api.github.com/users/workanator","html_url":"https://github.com/workanator","followers_url":"https://api.github.com/users/workanator/followers","following_url":"https://api.github.com/users/workanator/following{/other_user}","gists_url":"https://api.github.com/users/workanator/gists{/gist_id}","starred_url":"https://api.github.com/users/workanator/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/workanator/subscriptions","organizations_url":"https://api.github.com/users/workanator/orgs","repos_url":"https://api.github.com/users/workanator/repos","events_url":"https://api.github.com/users/workanator/events{/privacy}","received_events_url":"https://api.github.com/users/workanator/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-02-08T16:24:41Z","updated_at":"2016-02-09T04:56:19Z","closed_at":"2016-02-09T04:56:19Z","body":"Hello,  \r\nnot sure if that is mio issue but `EventLoop::io_poll` blocks the thread it running in on the second run. I migrated from the branch v0.4.x to the branch v0.5.x and encountered that issue. The branch v0.4.x did not block.  \r\n\r\nI got the latest sources of v0.5.x and added some debug output (see below).\r\n\r\n```\r\nRUN START\r\nRUN get messages\r\nRUN io_poll\r\nRUN test pending\r\nRUN get remaining messages\r\nRUN io_process\r\nRUN notify\r\nRUN timer_process\r\nRUN tick\r\nRUN END\r\nRUN START\r\nRUN get messages\r\nRUN io_poll\r\n```\r\nas you can see after `RUN io_poll` there are no more messages what makes me think it blocked the thread. And here is the source of `run_once` I added debug output to\r\n\r\n```rust\r\n    pub fn run_once(&mut self, handler: &mut H, mut timeout_ms: Option<usize>) -> io::Result<()> {\r\nprintln!(\"RUN START\");\r\n        let mut messages;\r\n\r\n        trace!(\"event loop tick\");\r\n\r\n        // Check the notify channel for any pending messages. If there are any,\r\n        // avoid blocking when polling for IO events. Messages will be\r\n        // processed after IO events.\r\nprintln!(\"RUN get messages\");\r\n        messages = self.notify.check(self.config.messages_per_tick, true);\r\n        let pending = messages > 0;\r\n\r\n        if pending {\r\n            timeout_ms = Some(0);\r\n        }\r\n\r\n        // Check the registered IO handles for any new events. Each poll\r\n        // is for one second, so a shutdown request can last as long as\r\n        // one second before it takes effect.\r\nprintln!(\"RUN io_poll\");\r\n        let events = match self.io_poll(timeout_ms) {\r\n            Ok(e) => e,\r\n            Err(err) => {\r\n                if err.kind() == io::ErrorKind::Interrupted {\r\n                    handler.interrupted(self);\r\n                    0\r\n                } else {\r\n                    return Err(err);\r\n                }\r\n            }\r\n        };\r\n\r\nprintln!(\"RUN test pending\");\r\n        if !pending {\r\n            // Indicate that the sleep period is over, also grab any additional\r\n            // messages\r\nprintln!(\"RUN get remaining messages\");\r\n            let remaining = self.config.messages_per_tick - messages;\r\n            messages += self.notify.check(remaining, false);\r\n        }\r\n\r\nprintln!(\"RUN io_process\");\r\n        self.io_process(handler, events);\r\nprintln!(\"RUN notify\");\r\n        self.notify(handler, messages);\r\nprintln!(\"RUN timer_process\");\r\n        self.timer_process(handler);\r\nprintln!(\"RUN tick\");\r\n        handler.tick(self);\r\nprintln!(\"RUN END\");\r\n        Ok(())\r\n    }\r\n```\r\n\r\nNot sure if that is important but I use the crate [chan-signal](https://crates.io/crates/chan-signal) to interrupt my program on Ctrl+C. But again with v0.4.x it works like a charm.\r\n\r\nI work on Mac OS X El Captain. Rust 1.6. The project is too big to just past the source code here but let me know if I can provide you more info."}}