{"action":"created","issue":{"url":"https://api.github.com/repos/lxc/lxd/issues/2141","repository_url":"https://api.github.com/repos/lxc/lxd","labels_url":"https://api.github.com/repos/lxc/lxd/issues/2141/labels{/name}","comments_url":"https://api.github.com/repos/lxc/lxd/issues/2141/comments","events_url":"https://api.github.com/repos/lxc/lxd/issues/2141/events","html_url":"https://github.com/lxc/lxd/pull/2141","id":161292631,"number":2141,"title":"Use defer to undo changes on failed update","user":{"login":"sean-jc","id":18535971,"avatar_url":"https://avatars.githubusercontent.com/u/18535971?v=3","gravatar_id":"","url":"https://api.github.com/users/sean-jc","html_url":"https://github.com/sean-jc","followers_url":"https://api.github.com/users/sean-jc/followers","following_url":"https://api.github.com/users/sean-jc/following{/other_user}","gists_url":"https://api.github.com/users/sean-jc/gists{/gist_id}","starred_url":"https://api.github.com/users/sean-jc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sean-jc/subscriptions","organizations_url":"https://api.github.com/users/sean-jc/orgs","repos_url":"https://api.github.com/users/sean-jc/repos","events_url":"https://api.github.com/users/sean-jc/events{/privacy}","received_events_url":"https://api.github.com/users/sean-jc/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2016-06-20T20:56:42Z","updated_at":"2016-06-21T14:37:50Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/lxc/lxd/pulls/2141","html_url":"https://github.com/lxc/lxd/pull/2141","diff_url":"https://github.com/lxc/lxd/pull/2141.diff","patch_url":"https://github.com/lxc/lxd/pull/2141.patch"},"body":"Defer the function to undo changes and track whether or not the changes\r\nshould be kept using a closure over a bool.  This eliminates the need to\r\nexplicitly call undoChanges() in every failing return path.\r\n\r\nSigned-off-by: Sean Christopherson <sean.j.christopherson@intel.com>"},"comment":{"url":"https://api.github.com/repos/lxc/lxd/issues/comments/227460199","html_url":"https://github.com/lxc/lxd/pull/2141#issuecomment-227460199","issue_url":"https://api.github.com/repos/lxc/lxd/issues/2141","id":227460199,"user":{"login":"tych0","id":785111,"avatar_url":"https://avatars.githubusercontent.com/u/785111?v=3","gravatar_id":"","url":"https://api.github.com/users/tych0","html_url":"https://github.com/tych0","followers_url":"https://api.github.com/users/tych0/followers","following_url":"https://api.github.com/users/tych0/following{/other_user}","gists_url":"https://api.github.com/users/tych0/gists{/gist_id}","starred_url":"https://api.github.com/users/tych0/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tych0/subscriptions","organizations_url":"https://api.github.com/users/tych0/orgs","repos_url":"https://api.github.com/users/tych0/repos","events_url":"https://api.github.com/users/tych0/events{/privacy}","received_events_url":"https://api.github.com/users/tych0/received_events","type":"User","site_admin":false},"created_at":"2016-06-21T14:37:50Z","updated_at":"2016-06-21T14:37:50Z","body":"On Mon, Jun 20, 2016 at 02:17:02PM -0700, Sean Christopherson wrote:\n> > One problem with using defer like this is that it's not run\n> immediately after the function returns, but is scheduled in some other\n> goroutine at some time later on in execution, which can lead to race\n> conditions.\n> \n> Is this documented somewhere?  My understanding is that deferred functions are stored as a list on the current function's stack, i.e. deferred functions are executed in the context of the surrounding function before the function's stack is unwound.  \n\nOh, I thought they were just closed over the function's locals, and\ndidn't necessarily execute in the same stack.\n\n> Things like changing the return value of a function via a closure in a deferred function, which is an [example](https://golang.org/ref/spec#Defer_statements) in the official documentation, would not work if the deferred function were executed in a separate goroutine.\n\nYeah, the word \"before\" sounds like you're right here. Unfortunately,\nI've had issues with this (viz.\neb2a87f8d939499a556b6e1c409ea2abd096318e), which is why I brought it\nup. If you're sure it won't cause issues I'm fine with it, but I've\nhad something that smelled funny around this in the past :)\n\n> ---\n> You are receiving this because you commented.\n> Reply to this email directly or view it on GitHub:\n> https://github.com/lxc/lxd/pull/2141#issuecomment-227272196\n"}}
{"actor":{"display_login":"tych0"}}