{"action":"created","comment":{"url":"https://api.github.com/repos/NebulousLabs/Sia/pulls/comments/70020665","id":70020665,"diff_hunk":"@@ -65,7 +65,13 @@ func (hd *Downloader) Sector(root crypto.Hash) (modules.RenterContract, []byte,\n \n \t// send the revision to the host for approval\n \tsignedTxn, err := negotiateRevision(hd.conn, rev, hd.contract.SecretKey)\n-\tif err != nil {\n+\tif err == modules.ErrStopResponse {\n+\t\t// if host gracefully closed, close our connection as well; this will\n+\t\t// cause the next operation will fail. We also need to set SaveFn to\n+\t\t// nil to prevent saving a revision that the host can't see.\n+\t\the.conn.Close()\n+\t\the.SaveFn = nil","path":"modules/renter/proto/downloader.go","position":null,"original_position":10,"commit_id":"34dfa9dd6b80a5d78d7bb84553bbadd565669dec","original_commit_id":"56cec3541fca79dcb1ff2149d4a37db8acd1651c","user":{"login":"mnsl","id":14918275,"avatar_url":"https://avatars.githubusercontent.com/u/14918275?v=3","gravatar_id":"","url":"https://api.github.com/users/mnsl","html_url":"https://github.com/mnsl","followers_url":"https://api.github.com/users/mnsl/followers","following_url":"https://api.github.com/users/mnsl/following{/other_user}","gists_url":"https://api.github.com/users/mnsl/gists{/gist_id}","starred_url":"https://api.github.com/users/mnsl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mnsl/subscriptions","organizations_url":"https://api.github.com/users/mnsl/orgs","repos_url":"https://api.github.com/users/mnsl/repos","events_url":"https://api.github.com/users/mnsl/events{/privacy}","received_events_url":"https://api.github.com/users/mnsl/received_events","type":"User","site_admin":false},"body":"Why not return here?","created_at":"2016-07-08T03:13:32Z","updated_at":"2016-07-08T03:13:32Z","html_url":"https://github.com/NebulousLabs/Sia/pull/1347#discussion_r70020665","pull_request_url":"https://api.github.com/repos/NebulousLabs/Sia/pulls/1347","_links":{"self":{"href":"https://api.github.com/repos/NebulousLabs/Sia/pulls/comments/70020665"},"html":{"href":"https://github.com/NebulousLabs/Sia/pull/1347#discussion_r70020665"},"pull_request":{"href":"https://api.github.com/repos/NebulousLabs/Sia/pulls/1347"}}},"pull_request":{"url":"https://api.github.com/repos/NebulousLabs/Sia/pulls/1347","id":76657134,"html_url":"https://github.com/NebulousLabs/Sia/pull/1347","diff_url":"https://github.com/NebulousLabs/Sia/pull/1347.diff","patch_url":"https://github.com/NebulousLabs/Sia/pull/1347.patch","issue_url":"https://api.github.com/repos/NebulousLabs/Sia/issues/1347","number":1347,"state":"open","locked":false,"title":"Handle StopResponse correctly in proto","user":{"login":"lukechampine","id":3344749,"avatar_url":"https://avatars.githubusercontent.com/u/3344749?v=3","gravatar_id":"","url":"https://api.github.com/users/lukechampine","html_url":"https://github.com/lukechampine","followers_url":"https://api.github.com/users/lukechampine/followers","following_url":"https://api.github.com/users/lukechampine/following{/other_user}","gists_url":"https://api.github.com/users/lukechampine/gists{/gist_id}","starred_url":"https://api.github.com/users/lukechampine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lukechampine/subscriptions","organizations_url":"https://api.github.com/users/lukechampine/orgs","repos_url":"https://api.github.com/users/lukechampine/repos","events_url":"https://api.github.com/users/lukechampine/events{/privacy}","received_events_url":"https://api.github.com/users/lukechampine/received_events","type":"User","site_admin":false},"body":"As reported in #1346, the renter protocol was not properly handling `StopResponse` during revision. The correct behavior is to apply the revision and then gracefully terminate. Instead, the renter treated `StopResponse` as an error and exited early without applying the revision. This caused the renter and host to desync.\r\n\r\nNote that in this implementation, the renter will not know that the host has closed the connection until it tries to perform another revision operation. An alternative approach would bubble the `ErrStopResponse` error all the way up to `Upload`, `Delete`, etc., and the caller would have to check for this error specifically and handle it correctly -- namely, they would have to recognize that the other return values were still valid, despite `err != nil`. I opted not to take this approach, because there is little benefit and the renter needs to be safeguarded against random host disconnects anyway.\r\n\r\nOn that note, this PR should also fix a subtle bug affecting cached revisions. Previously, `SaveFn` was called before doing any network I/O. This meant that if the host had silently disconnected, the renter would cache the revision before finding out. By itself, this shouldn't cause the renter to desync (since it will first try the current revision, not the cached revision), but it may have compounded other issues.","created_at":"2016-07-07T20:09:47Z","updated_at":"2016-07-08T03:13:32Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9f61d7e7b83b1cad6f9a394d78232ecddc6c8ccf","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/NebulousLabs/Sia/pulls/1347/commits","review_comments_url":"https://api.github.com/repos/NebulousLabs/Sia/pulls/1347/comments","review_comment_url":"https://api.github.com/repos/NebulousLabs/Sia/pulls/comments{/number}","comments_url":"https://api.github.com/repos/NebulousLabs/Sia/issues/1347/comments","statuses_url":"https://api.github.com/repos/NebulousLabs/Sia/statuses/34dfa9dd6b80a5d78d7bb84553bbadd565669dec","head":{"label":"NebulousLabs:stop-response","ref":"stop-response","sha":"34dfa9dd6b80a5d78d7bb84553bbadd565669dec","user":{"login":"NebulousLabs","id":7471422,"avatar_url":"https://avatars.githubusercontent.com/u/7471422?v=3","gravatar_id":"","url":"https://api.github.com/users/NebulousLabs","html_url":"https://github.com/NebulousLabs","followers_url":"https://api.github.com/users/NebulousLabs/followers","following_url":"https://api.github.com/users/NebulousLabs/following{/other_user}","gists_url":"https://api.github.com/users/NebulousLabs/gists{/gist_id}","starred_url":"https://api.github.com/users/NebulousLabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NebulousLabs/subscriptions","organizations_url":"https://api.github.com/users/NebulousLabs/orgs","repos_url":"https://api.github.com/users/NebulousLabs/repos","events_url":"https://api.github.com/users/NebulousLabs/events{/privacy}","received_events_url":"https://api.github.com/users/NebulousLabs/received_events","type":"Organization","site_admin":false},"repo":{"id":25370072,"name":"Sia","full_name":"NebulousLabs/Sia","owner":{"login":"NebulousLabs","id":7471422,"avatar_url":"https://avatars.githubusercontent.com/u/7471422?v=3","gravatar_id":"","url":"https://api.github.com/users/NebulousLabs","html_url":"https://github.com/NebulousLabs","followers_url":"https://api.github.com/users/NebulousLabs/followers","following_url":"https://api.github.com/users/NebulousLabs/following{/other_user}","gists_url":"https://api.github.com/users/NebulousLabs/gists{/gist_id}","starred_url":"https://api.github.com/users/NebulousLabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NebulousLabs/subscriptions","organizations_url":"https://api.github.com/users/NebulousLabs/orgs","repos_url":"https://api.github.com/users/NebulousLabs/repos","events_url":"https://api.github.com/users/NebulousLabs/events{/privacy}","received_events_url":"https://api.github.com/users/NebulousLabs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/NebulousLabs/Sia","description":"Blockchain-based marketplace for file storage","fork":false,"url":"https://api.github.com/repos/NebulousLabs/Sia","forks_url":"https://api.github.com/repos/NebulousLabs/Sia/forks","keys_url":"https://api.github.com/repos/NebulousLabs/Sia/keys{/key_id}","collaborators_url":"https://api.github.com/repos/NebulousLabs/Sia/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/NebulousLabs/Sia/teams","hooks_url":"https://api.github.com/repos/NebulousLabs/Sia/hooks","issue_events_url":"https://api.github.com/repos/NebulousLabs/Sia/issues/events{/number}","events_url":"https://api.github.com/repos/NebulousLabs/Sia/events","assignees_url":"https://api.github.com/repos/NebulousLabs/Sia/assignees{/user}","branches_url":"https://api.github.com/repos/NebulousLabs/Sia/branches{/branch}","tags_url":"https://api.github.com/repos/NebulousLabs/Sia/tags","blobs_url":"https://api.github.com/repos/NebulousLabs/Sia/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/NebulousLabs/Sia/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/NebulousLabs/Sia/git/refs{/sha}","trees_url":"https://api.github.com/repos/NebulousLabs/Sia/git/trees{/sha}","statuses_url":"https://api.github.com/repos/NebulousLabs/Sia/statuses/{sha}","languages_url":"https://api.github.com/repos/NebulousLabs/Sia/languages","stargazers_url":"https://api.github.com/repos/NebulousLabs/Sia/stargazers","contributors_url":"https://api.github.com/repos/NebulousLabs/Sia/contributors","subscribers_url":"https://api.github.com/repos/NebulousLabs/Sia/subscribers","subscription_url":"https://api.github.com/repos/NebulousLabs/Sia/subscription","commits_url":"https://api.github.com/repos/NebulousLabs/Sia/commits{/sha}","git_commits_url":"https://api.github.com/repos/NebulousLabs/Sia/git/commits{/sha}","comments_url":"https://api.github.com/repos/NebulousLabs/Sia/comments{/number}","issue_comment_url":"https://api.github.com/repos/NebulousLabs/Sia/issues/comments{/number}","contents_url":"https://api.github.com/repos/NebulousLabs/Sia/contents/{+path}","compare_url":"https://api.github.com/repos/NebulousLabs/Sia/compare/{base}...{head}","merges_url":"https://api.github.com/repos/NebulousLabs/Sia/merges","archive_url":"https://api.github.com/repos/NebulousLabs/Sia/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/NebulousLabs/Sia/downloads","issues_url":"https://api.github.com/repos/NebulousLabs/Sia/issues{/number}","pulls_url":"https://api.github.com/repos/NebulousLabs/Sia/pulls{/number}","milestones_url":"https://api.github.com/repos/NebulousLabs/Sia/milestones{/number}","notifications_url":"https://api.github.com/repos/NebulousLabs/Sia/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/NebulousLabs/Sia/labels{/name}","releases_url":"https://api.github.com/repos/NebulousLabs/Sia/releases{/id}","deployments_url":"https://api.github.com/repos/NebulousLabs/Sia/deployments","created_at":"2014-10-17T17:50:25Z","updated_at":"2016-07-07T13:55:08Z","pushed_at":"2016-07-07T21:13:34Z","git_url":"git://github.com/NebulousLabs/Sia.git","ssh_url":"git@github.com:NebulousLabs/Sia.git","clone_url":"https://github.com/NebulousLabs/Sia.git","svn_url":"https://github.com/NebulousLabs/Sia","homepage":"https://sia.tech","size":29359,"stargazers_count":305,"watchers_count":305,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":47,"mirror_url":null,"open_issues_count":45,"forks":47,"open_issues":45,"watchers":305,"default_branch":"master"}},"base":{"label":"NebulousLabs:master","ref":"master","sha":"585443a36c8af373d5dadef560f3419ef775c805","user":{"login":"NebulousLabs","id":7471422,"avatar_url":"https://avatars.githubusercontent.com/u/7471422?v=3","gravatar_id":"","url":"https://api.github.com/users/NebulousLabs","html_url":"https://github.com/NebulousLabs","followers_url":"https://api.github.com/users/NebulousLabs/followers","following_url":"https://api.github.com/users/NebulousLabs/following{/other_user}","gists_url":"https://api.github.com/users/NebulousLabs/gists{/gist_id}","starred_url":"https://api.github.com/users/NebulousLabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NebulousLabs/subscriptions","organizations_url":"https://api.github.com/users/NebulousLabs/orgs","repos_url":"https://api.github.com/users/NebulousLabs/repos","events_url":"https://api.github.com/users/NebulousLabs/events{/privacy}","received_events_url":"https://api.github.com/users/NebulousLabs/received_events","type":"Organization","site_admin":false},"repo":{"id":25370072,"name":"Sia","full_name":"NebulousLabs/Sia","owner":{"login":"NebulousLabs","id":7471422,"avatar_url":"https://avatars.githubusercontent.com/u/7471422?v=3","gravatar_id":"","url":"https://api.github.com/users/NebulousLabs","html_url":"https://github.com/NebulousLabs","followers_url":"https://api.github.com/users/NebulousLabs/followers","following_url":"https://api.github.com/users/NebulousLabs/following{/other_user}","gists_url":"https://api.github.com/users/NebulousLabs/gists{/gist_id}","starred_url":"https://api.github.com/users/NebulousLabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NebulousLabs/subscriptions","organizations_url":"https://api.github.com/users/NebulousLabs/orgs","repos_url":"https://api.github.com/users/NebulousLabs/repos","events_url":"https://api.github.com/users/NebulousLabs/events{/privacy}","received_events_url":"https://api.github.com/users/NebulousLabs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/NebulousLabs/Sia","description":"Blockchain-based marketplace for file storage","fork":false,"url":"https://api.github.com/repos/NebulousLabs/Sia","forks_url":"https://api.github.com/repos/NebulousLabs/Sia/forks","keys_url":"https://api.github.com/repos/NebulousLabs/Sia/keys{/key_id}","collaborators_url":"https://api.github.com/repos/NebulousLabs/Sia/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/NebulousLabs/Sia/teams","hooks_url":"https://api.github.com/repos/NebulousLabs/Sia/hooks","issue_events_url":"https://api.github.com/repos/NebulousLabs/Sia/issues/events{/number}","events_url":"https://api.github.com/repos/NebulousLabs/Sia/events","assignees_url":"https://api.github.com/repos/NebulousLabs/Sia/assignees{/user}","branches_url":"https://api.github.com/repos/NebulousLabs/Sia/branches{/branch}","tags_url":"https://api.github.com/repos/NebulousLabs/Sia/tags","blobs_url":"https://api.github.com/repos/NebulousLabs/Sia/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/NebulousLabs/Sia/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/NebulousLabs/Sia/git/refs{/sha}","trees_url":"https://api.github.com/repos/NebulousLabs/Sia/git/trees{/sha}","statuses_url":"https://api.github.com/repos/NebulousLabs/Sia/statuses/{sha}","languages_url":"https://api.github.com/repos/NebulousLabs/Sia/languages","stargazers_url":"https://api.github.com/repos/NebulousLabs/Sia/stargazers","contributors_url":"https://api.github.com/repos/NebulousLabs/Sia/contributors","subscribers_url":"https://api.github.com/repos/NebulousLabs/Sia/subscribers","subscription_url":"https://api.github.com/repos/NebulousLabs/Sia/subscription","commits_url":"https://api.github.com/repos/NebulousLabs/Sia/commits{/sha}","git_commits_url":"https://api.github.com/repos/NebulousLabs/Sia/git/commits{/sha}","comments_url":"https://api.github.com/repos/NebulousLabs/Sia/comments{/number}","issue_comment_url":"https://api.github.com/repos/NebulousLabs/Sia/issues/comments{/number}","contents_url":"https://api.github.com/repos/NebulousLabs/Sia/contents/{+path}","compare_url":"https://api.github.com/repos/NebulousLabs/Sia/compare/{base}...{head}","merges_url":"https://api.github.com/repos/NebulousLabs/Sia/merges","archive_url":"https://api.github.com/repos/NebulousLabs/Sia/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/NebulousLabs/Sia/downloads","issues_url":"https://api.github.com/repos/NebulousLabs/Sia/issues{/number}","pulls_url":"https://api.github.com/repos/NebulousLabs/Sia/pulls{/number}","milestones_url":"https://api.github.com/repos/NebulousLabs/Sia/milestones{/number}","notifications_url":"https://api.github.com/repos/NebulousLabs/Sia/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/NebulousLabs/Sia/labels{/name}","releases_url":"https://api.github.com/repos/NebulousLabs/Sia/releases{/id}","deployments_url":"https://api.github.com/repos/NebulousLabs/Sia/deployments","created_at":"2014-10-17T17:50:25Z","updated_at":"2016-07-07T13:55:08Z","pushed_at":"2016-07-07T21:13:34Z","git_url":"git://github.com/NebulousLabs/Sia.git","ssh_url":"git@github.com:NebulousLabs/Sia.git","clone_url":"https://github.com/NebulousLabs/Sia.git","svn_url":"https://github.com/NebulousLabs/Sia","homepage":"https://sia.tech","size":29359,"stargazers_count":305,"watchers_count":305,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":47,"mirror_url":null,"open_issues_count":45,"forks":47,"open_issues":45,"watchers":305,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/NebulousLabs/Sia/pulls/1347"},"html":{"href":"https://github.com/NebulousLabs/Sia/pull/1347"},"issue":{"href":"https://api.github.com/repos/NebulousLabs/Sia/issues/1347"},"comments":{"href":"https://api.github.com/repos/NebulousLabs/Sia/issues/1347/comments"},"review_comments":{"href":"https://api.github.com/repos/NebulousLabs/Sia/pulls/1347/comments"},"review_comment":{"href":"https://api.github.com/repos/NebulousLabs/Sia/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/NebulousLabs/Sia/pulls/1347/commits"},"statuses":{"href":"https://api.github.com/repos/NebulousLabs/Sia/statuses/34dfa9dd6b80a5d78d7bb84553bbadd565669dec"}}}}
{"actor":{"display_login":"mnsl"}}