{"action":"created","issue":{"url":"https://api.github.com/repos/carllerche/mio/issues/219","labels_url":"https://api.github.com/repos/carllerche/mio/issues/219/labels{/name}","comments_url":"https://api.github.com/repos/carllerche/mio/issues/219/comments","events_url":"https://api.github.com/repos/carllerche/mio/issues/219/events","html_url":"https://github.com/carllerche/mio/issues/219","id":97207138,"number":219,"title":"Does deregister clear events already pending delivery? Should it?","user":{"login":"dpc","id":9209,"avatar_url":"https://avatars.githubusercontent.com/u/9209?v=3","gravatar_id":"","url":"https://api.github.com/users/dpc","html_url":"https://github.com/dpc","followers_url":"https://api.github.com/users/dpc/followers","following_url":"https://api.github.com/users/dpc/following{/other_user}","gists_url":"https://api.github.com/users/dpc/gists{/gist_id}","starred_url":"https://api.github.com/users/dpc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dpc/subscriptions","organizations_url":"https://api.github.com/users/dpc/orgs","repos_url":"https://api.github.com/users/dpc/repos","events_url":"https://api.github.com/users/dpc/events{/privacy}","received_events_url":"https://api.github.com/users/dpc/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":9,"created_at":"2015-07-25T08:06:36Z","updated_at":"2015-07-31T21:39:26Z","closed_at":null,"body":"Let's say I have two event sources registered, both of them fired at the same time and landed in pending events list for current iteration.\r\n\r\nWhile handling the first event, I do `deregister` on the other one. Will I still get it? It seems to me that I will, which is very inconvenient, as it makes hard (impossible?) to safely deregister events other than the one that just fired.\r\n\r\nA spin of the above case is: What if I do `deregister` and right after used `register_opt` on different event source, using the same token.\r\n\r\nAnother spinoff is: What if I do `reregister` using different interest.\r\n\r\nIf I am not missing anything, it seems to me that either: the end of each event delivery iteration should have a notification, during which calls like `deregister` and `reregister` can be safely used, or `deregister` and `reregister` should make sure to remove any events that are not to be delivered anymore."},"comment":{"url":"https://api.github.com/repos/carllerche/mio/issues/comments/126817951","html_url":"https://github.com/carllerche/mio/issues/219#issuecomment-126817951","issue_url":"https://api.github.com/repos/carllerche/mio/issues/219","id":126817951,"user":{"login":"carllerche","id":6180,"avatar_url":"https://avatars.githubusercontent.com/u/6180?v=3","gravatar_id":"","url":"https://api.github.com/users/carllerche","html_url":"https://github.com/carllerche","followers_url":"https://api.github.com/users/carllerche/followers","following_url":"https://api.github.com/users/carllerche/following{/other_user}","gists_url":"https://api.github.com/users/carllerche/gists{/gist_id}","starred_url":"https://api.github.com/users/carllerche/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/carllerche/subscriptions","organizations_url":"https://api.github.com/users/carllerche/orgs","repos_url":"https://api.github.com/users/carllerche/repos","events_url":"https://api.github.com/users/carllerche/events{/privacy}","received_events_url":"https://api.github.com/users/carllerche/received_events","type":"User","site_admin":false},"created_at":"2015-07-31T21:39:26Z","updated_at":"2015-07-31T21:39:26Z","body":"So, I haven't hit the issue in question yet, so I need some help trying to understand.\r\n\r\nFor cases where sockets aren't interrelated, there isn't an issue. The EventLoop won't produce any further events with the token.\r\n\r\nFor cases where multiple sockets *are* interrelated, say a proxy, where if one end closes, you want to close both ends. The issue seems to be that the tokens for both sockets are \"released\" back to the pool, thus any further notifications using the token will be problematic.\r\n\r\nHaving `deregister` guarantee that no further events happen w/ the token is not actually enough, because it doesn't handle the case where the socket is closed w/o `deregister` being called.\r\n\r\n@tailhook I don't understand why point #3 is a problem. If you **temporarily** deregister a socket, you aren't releasing the token back into the pool, so there will be no token conflict."}}