{"action":"created","issue":{"url":"https://api.github.com/repos/Astron/Astron/issues/309","labels_url":"https://api.github.com/repos/Astron/Astron/issues/309/labels{/name}","comments_url":"https://api.github.com/repos/Astron/Astron/issues/309/comments","events_url":"https://api.github.com/repos/Astron/Astron/issues/309/events","html_url":"https://github.com/Astron/Astron/pull/309","id":54992116,"number":309,"title":"Resolve race condition with interests","user":{"login":"CFSworks","id":700768,"avatar_url":"https://avatars.githubusercontent.com/u/700768?v=3","gravatar_id":"","url":"https://api.github.com/users/CFSworks","html_url":"https://github.com/CFSworks","followers_url":"https://api.github.com/users/CFSworks/followers","following_url":"https://api.github.com/users/CFSworks/following{/other_user}","gists_url":"https://api.github.com/users/CFSworks/gists{/gist_id}","starred_url":"https://api.github.com/users/CFSworks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CFSworks/subscriptions","organizations_url":"https://api.github.com/users/CFSworks/orgs","repos_url":"https://api.github.com/users/CFSworks/repos","events_url":"https://api.github.com/users/CFSworks/events{/privacy}","received_events_url":"https://api.github.com/users/CFSworks/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":9,"created_at":"2015-01-21T08:48:15Z","updated_at":"2015-01-28T00:46:52Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/Astron/Astron/pulls/309","html_url":"https://github.com/Astron/Astron/pull/309","diff_url":"https://github.com/Astron/Astron/pull/309.diff","patch_url":"https://github.com/Astron/Astron/pull/309.patch"},"body":"This pull request resolves a long-standing issue with interests in the client agent, where a race between an object entering a zone and the CA opening the interest would result in the CA miscounting the objects.\r\n\r\nThis issue is twofold, since the race may cause the CA to either:\r\n1. Stall indefinitely, if an object left after the count was calculated.\r\n2. Prematurely tell the client that the interest is open, if an object snuck in after the count was calculated.\r\n\r\nI have resolved the indefinite stalling by adding a timeout to InterestOperation.\r\nSome changes were necessary for this:\r\n* I had to make InterestOperation referenced by pointer, rather than copied. This way its `this` pointer would not change.\r\n* InterestOperations track the client, and have a little bit more autonomy than the basic \"struct with methods\" they (essentially) were before.\r\n* I added a \"timeout\" class to util/, which allows specification of an arbitrary timeout and callback.\r\n* I put the configuration variable `interest_timeout` in the Client (i.e. *base*) class, since this behavior is not specific to AstronClient.\r\n\r\nI resolved the premature issue by giving the parent and child objects slightly better communication about who knows what. I added a new message called `STATESERVER_OBJECT_LOCATION_ACK`, which is sent to a child when it gets factored into the zone counts. When the child announces itself to an interested peer, it uses ENTER_INTEREST if it has received a LOCATION_ACK (i.e. the parent knows it exists and included it in the count) and ENTER_LOCATION otherwise.\r\n\r\nFurthermore, I went ahead and removed the \"self-decrementing\" behavior on InterestOperations -- it's too prone to error and the timeout will catch those cases anyway.\r\n\r\nIn the future, I'd love to develop a faster anti-overcounting strategy than a timeout, but in the meantime, I feel that the timeout really is necessary."},"comment":{"url":"https://api.github.com/repos/Astron/Astron/issues/comments/71760541","html_url":"https://github.com/Astron/Astron/pull/309#issuecomment-71760541","issue_url":"https://api.github.com/repos/Astron/Astron/issues/309","id":71760541,"user":{"login":"CFSworks","id":700768,"avatar_url":"https://avatars.githubusercontent.com/u/700768?v=3","gravatar_id":"","url":"https://api.github.com/users/CFSworks","html_url":"https://github.com/CFSworks","followers_url":"https://api.github.com/users/CFSworks/followers","following_url":"https://api.github.com/users/CFSworks/following{/other_user}","gists_url":"https://api.github.com/users/CFSworks/gists{/gist_id}","starred_url":"https://api.github.com/users/CFSworks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CFSworks/subscriptions","organizations_url":"https://api.github.com/users/CFSworks/orgs","repos_url":"https://api.github.com/users/CFSworks/repos","events_url":"https://api.github.com/users/CFSworks/events{/privacy}","received_events_url":"https://api.github.com/users/CFSworks/received_events","type":"User","site_admin":false},"created_at":"2015-01-28T00:46:52Z","updated_at":"2015-01-28T00:46:52Z","body":"Just ran the tests. This gets :+1: :+1: from me. :shipit:"}}