{"action":"created","comment":{"url":"https://api.github.com/repos/arvidn/libtorrent/pulls/comments/55932255","id":55932255,"diff_hunk":"@@ -1074,9 +1088,12 @@ namespace libtorrent\n \t\t\t// don't evict write jobs if at least one other thread\n \t\t\t// is flushing right now. Doing so could result in\n \t\t\t// unnecessary flushing of the wrong pieces\n-\t\t\tif (evict > 0 && m_stats_counters[counters::num_writing_threads] == 0)\n+\t\t\tif (evict > 0)\n \t\t\t{\n-\t\t\t\ttry_flush_write_blocks(evict, completed_jobs, l);\n+\t\t\t\tmutex::scoped_lock f(m_flush_mutex);\n+\t\t\t\twhile (m_stats_counters[counters::num_writing_threads] != 0)","path":"src/disk_io_thread.cpp","position":68,"original_position":68,"commit_id":"c2625f6f78bcf89c2de59841dcfcda1e241fc66e","original_commit_id":"c2625f6f78bcf89c2de59841dcfcda1e241fc66e","user":{"login":"ssiloti","id":155790,"avatar_url":"https://avatars.githubusercontent.com/u/155790?v=3","gravatar_id":"","url":"https://api.github.com/users/ssiloti","html_url":"https://github.com/ssiloti","followers_url":"https://api.github.com/users/ssiloti/followers","following_url":"https://api.github.com/users/ssiloti/following{/other_user}","gists_url":"https://api.github.com/users/ssiloti/gists{/gist_id}","starred_url":"https://api.github.com/users/ssiloti/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ssiloti/subscriptions","organizations_url":"https://api.github.com/users/ssiloti/orgs","repos_url":"https://api.github.com/users/ssiloti/repos","events_url":"https://api.github.com/users/ssiloti/events{/privacy}","received_events_url":"https://api.github.com/users/ssiloti/received_events","type":"User","site_admin":false},"body":"We can't just skip the flushing. The other thread could itself be in `try_flush_write_blocks` so if we bail out here we may leave dirty buffers with nothing to flush them. This causes a deadlock if the dirty buffers exceed `m_max_use` and all `peer_connection`s are blocked waiting to allocate more buffers.\r\n\r\nPosting a deferred job would work. I think I like that better than what's here now.","created_at":"2016-03-13T05:08:09Z","updated_at":"2016-03-13T05:08:09Z","html_url":"https://github.com/arvidn/libtorrent/pull/536#discussion_r55932255","pull_request_url":"https://api.github.com/repos/arvidn/libtorrent/pulls/536","_links":{"self":{"href":"https://api.github.com/repos/arvidn/libtorrent/pulls/comments/55932255"},"html":{"href":"https://github.com/arvidn/libtorrent/pull/536#discussion_r55932255"},"pull_request":{"href":"https://api.github.com/repos/arvidn/libtorrent/pulls/536"}}},"pull_request":{"url":"https://api.github.com/repos/arvidn/libtorrent/pulls/536","id":62660870,"html_url":"https://github.com/arvidn/libtorrent/pull/536","diff_url":"https://github.com/arvidn/libtorrent/pull/536.diff","patch_url":"https://github.com/arvidn/libtorrent/pull/536.patch","issue_url":"https://api.github.com/repos/arvidn/libtorrent/issues/536","number":536,"state":"open","locked":false,"title":"Always cache writes","user":{"login":"ssiloti","id":155790,"avatar_url":"https://avatars.githubusercontent.com/u/155790?v=3","gravatar_id":"","url":"https://api.github.com/users/ssiloti","html_url":"https://github.com/ssiloti","followers_url":"https://api.github.com/users/ssiloti/followers","following_url":"https://api.github.com/users/ssiloti/following{/other_user}","gists_url":"https://api.github.com/users/ssiloti/gists{/gist_id}","starred_url":"https://api.github.com/users/ssiloti/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ssiloti/subscriptions","organizations_url":"https://api.github.com/users/ssiloti/orgs","repos_url":"https://api.github.com/users/ssiloti/repos","events_url":"https://api.github.com/users/ssiloti/events{/privacy}","received_events_url":"https://api.github.com/users/ssiloti/received_events","type":"User","site_admin":false},"body":"Fixes #530","created_at":"2016-03-13T03:52:14Z","updated_at":"2016-03-13T05:08:09Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4a7c65ae68000c8e361a0a766e690e60405d0d93","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/arvidn/libtorrent/pulls/536/commits","review_comments_url":"https://api.github.com/repos/arvidn/libtorrent/pulls/536/comments","review_comment_url":"https://api.github.com/repos/arvidn/libtorrent/pulls/comments{/number}","comments_url":"https://api.github.com/repos/arvidn/libtorrent/issues/536/comments","statuses_url":"https://api.github.com/repos/arvidn/libtorrent/statuses/c2625f6f78bcf89c2de59841dcfcda1e241fc66e","head":{"label":"ssiloti:always-cache-writes-1.1","ref":"always-cache-writes-1.1","sha":"c2625f6f78bcf89c2de59841dcfcda1e241fc66e","user":{"login":"ssiloti","id":155790,"avatar_url":"https://avatars.githubusercontent.com/u/155790?v=3","gravatar_id":"","url":"https://api.github.com/users/ssiloti","html_url":"https://github.com/ssiloti","followers_url":"https://api.github.com/users/ssiloti/followers","following_url":"https://api.github.com/users/ssiloti/following{/other_user}","gists_url":"https://api.github.com/users/ssiloti/gists{/gist_id}","starred_url":"https://api.github.com/users/ssiloti/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ssiloti/subscriptions","organizations_url":"https://api.github.com/users/ssiloti/orgs","repos_url":"https://api.github.com/users/ssiloti/repos","events_url":"https://api.github.com/users/ssiloti/events{/privacy}","received_events_url":"https://api.github.com/users/ssiloti/received_events","type":"User","site_admin":false},"repo":{"id":37429203,"name":"libtorrent","full_name":"ssiloti/libtorrent","owner":{"login":"ssiloti","id":155790,"avatar_url":"https://avatars.githubusercontent.com/u/155790?v=3","gravatar_id":"","url":"https://api.github.com/users/ssiloti","html_url":"https://github.com/ssiloti","followers_url":"https://api.github.com/users/ssiloti/followers","following_url":"https://api.github.com/users/ssiloti/following{/other_user}","gists_url":"https://api.github.com/users/ssiloti/gists{/gist_id}","starred_url":"https://api.github.com/users/ssiloti/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ssiloti/subscriptions","organizations_url":"https://api.github.com/users/ssiloti/orgs","repos_url":"https://api.github.com/users/ssiloti/repos","events_url":"https://api.github.com/users/ssiloti/events{/privacy}","received_events_url":"https://api.github.com/users/ssiloti/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ssiloti/libtorrent","description":"an efficient feature complete C++ bittorrent implementation","fork":true,"url":"https://api.github.com/repos/ssiloti/libtorrent","forks_url":"https://api.github.com/repos/ssiloti/libtorrent/forks","keys_url":"https://api.github.com/repos/ssiloti/libtorrent/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ssiloti/libtorrent/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ssiloti/libtorrent/teams","hooks_url":"https://api.github.com/repos/ssiloti/libtorrent/hooks","issue_events_url":"https://api.github.com/repos/ssiloti/libtorrent/issues/events{/number}","events_url":"https://api.github.com/repos/ssiloti/libtorrent/events","assignees_url":"https://api.github.com/repos/ssiloti/libtorrent/assignees{/user}","branches_url":"https://api.github.com/repos/ssiloti/libtorrent/branches{/branch}","tags_url":"https://api.github.com/repos/ssiloti/libtorrent/tags","blobs_url":"https://api.github.com/repos/ssiloti/libtorrent/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ssiloti/libtorrent/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ssiloti/libtorrent/git/refs{/sha}","trees_url":"https://api.github.com/repos/ssiloti/libtorrent/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ssiloti/libtorrent/statuses/{sha}","languages_url":"https://api.github.com/repos/ssiloti/libtorrent/languages","stargazers_url":"https://api.github.com/repos/ssiloti/libtorrent/stargazers","contributors_url":"https://api.github.com/repos/ssiloti/libtorrent/contributors","subscribers_url":"https://api.github.com/repos/ssiloti/libtorrent/subscribers","subscription_url":"https://api.github.com/repos/ssiloti/libtorrent/subscription","commits_url":"https://api.github.com/repos/ssiloti/libtorrent/commits{/sha}","git_commits_url":"https://api.github.com/repos/ssiloti/libtorrent/git/commits{/sha}","comments_url":"https://api.github.com/repos/ssiloti/libtorrent/comments{/number}","issue_comment_url":"https://api.github.com/repos/ssiloti/libtorrent/issues/comments{/number}","contents_url":"https://api.github.com/repos/ssiloti/libtorrent/contents/{+path}","compare_url":"https://api.github.com/repos/ssiloti/libtorrent/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ssiloti/libtorrent/merges","archive_url":"https://api.github.com/repos/ssiloti/libtorrent/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ssiloti/libtorrent/downloads","issues_url":"https://api.github.com/repos/ssiloti/libtorrent/issues{/number}","pulls_url":"https://api.github.com/repos/ssiloti/libtorrent/pulls{/number}","milestones_url":"https://api.github.com/repos/ssiloti/libtorrent/milestones{/number}","notifications_url":"https://api.github.com/repos/ssiloti/libtorrent/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ssiloti/libtorrent/labels{/name}","releases_url":"https://api.github.com/repos/ssiloti/libtorrent/releases{/id}","deployments_url":"https://api.github.com/repos/ssiloti/libtorrent/deployments","created_at":"2015-06-14T20:53:10Z","updated_at":"2016-01-11T16:39:40Z","pushed_at":"2016-03-13T03:45:54Z","git_url":"git://github.com/ssiloti/libtorrent.git","ssh_url":"git@github.com:ssiloti/libtorrent.git","clone_url":"https://github.com/ssiloti/libtorrent.git","svn_url":"https://github.com/ssiloti/libtorrent","homepage":"http://libtorrent.org","size":42555,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"arvidn:RC_1_1","ref":"RC_1_1","sha":"71e3fb8941ddeaa6af0cc833e51e8149f475990d","user":{"login":"arvidn","id":661450,"avatar_url":"https://avatars.githubusercontent.com/u/661450?v=3","gravatar_id":"","url":"https://api.github.com/users/arvidn","html_url":"https://github.com/arvidn","followers_url":"https://api.github.com/users/arvidn/followers","following_url":"https://api.github.com/users/arvidn/following{/other_user}","gists_url":"https://api.github.com/users/arvidn/gists{/gist_id}","starred_url":"https://api.github.com/users/arvidn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arvidn/subscriptions","organizations_url":"https://api.github.com/users/arvidn/orgs","repos_url":"https://api.github.com/users/arvidn/repos","events_url":"https://api.github.com/users/arvidn/events{/privacy}","received_events_url":"https://api.github.com/users/arvidn/received_events","type":"User","site_admin":false},"repo":{"id":36781769,"name":"libtorrent","full_name":"arvidn/libtorrent","owner":{"login":"arvidn","id":661450,"avatar_url":"https://avatars.githubusercontent.com/u/661450?v=3","gravatar_id":"","url":"https://api.github.com/users/arvidn","html_url":"https://github.com/arvidn","followers_url":"https://api.github.com/users/arvidn/followers","following_url":"https://api.github.com/users/arvidn/following{/other_user}","gists_url":"https://api.github.com/users/arvidn/gists{/gist_id}","starred_url":"https://api.github.com/users/arvidn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arvidn/subscriptions","organizations_url":"https://api.github.com/users/arvidn/orgs","repos_url":"https://api.github.com/users/arvidn/repos","events_url":"https://api.github.com/users/arvidn/events{/privacy}","received_events_url":"https://api.github.com/users/arvidn/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/arvidn/libtorrent","description":"an efficient feature complete C++ bittorrent implementation","fork":false,"url":"https://api.github.com/repos/arvidn/libtorrent","forks_url":"https://api.github.com/repos/arvidn/libtorrent/forks","keys_url":"https://api.github.com/repos/arvidn/libtorrent/keys{/key_id}","collaborators_url":"https://api.github.com/repos/arvidn/libtorrent/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/arvidn/libtorrent/teams","hooks_url":"https://api.github.com/repos/arvidn/libtorrent/hooks","issue_events_url":"https://api.github.com/repos/arvidn/libtorrent/issues/events{/number}","events_url":"https://api.github.com/repos/arvidn/libtorrent/events","assignees_url":"https://api.github.com/repos/arvidn/libtorrent/assignees{/user}","branches_url":"https://api.github.com/repos/arvidn/libtorrent/branches{/branch}","tags_url":"https://api.github.com/repos/arvidn/libtorrent/tags","blobs_url":"https://api.github.com/repos/arvidn/libtorrent/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/arvidn/libtorrent/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/arvidn/libtorrent/git/refs{/sha}","trees_url":"https://api.github.com/repos/arvidn/libtorrent/git/trees{/sha}","statuses_url":"https://api.github.com/repos/arvidn/libtorrent/statuses/{sha}","languages_url":"https://api.github.com/repos/arvidn/libtorrent/languages","stargazers_url":"https://api.github.com/repos/arvidn/libtorrent/stargazers","contributors_url":"https://api.github.com/repos/arvidn/libtorrent/contributors","subscribers_url":"https://api.github.com/repos/arvidn/libtorrent/subscribers","subscription_url":"https://api.github.com/repos/arvidn/libtorrent/subscription","commits_url":"https://api.github.com/repos/arvidn/libtorrent/commits{/sha}","git_commits_url":"https://api.github.com/repos/arvidn/libtorrent/git/commits{/sha}","comments_url":"https://api.github.com/repos/arvidn/libtorrent/comments{/number}","issue_comment_url":"https://api.github.com/repos/arvidn/libtorrent/issues/comments{/number}","contents_url":"https://api.github.com/repos/arvidn/libtorrent/contents/{+path}","compare_url":"https://api.github.com/repos/arvidn/libtorrent/compare/{base}...{head}","merges_url":"https://api.github.com/repos/arvidn/libtorrent/merges","archive_url":"https://api.github.com/repos/arvidn/libtorrent/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/arvidn/libtorrent/downloads","issues_url":"https://api.github.com/repos/arvidn/libtorrent/issues{/number}","pulls_url":"https://api.github.com/repos/arvidn/libtorrent/pulls{/number}","milestones_url":"https://api.github.com/repos/arvidn/libtorrent/milestones{/number}","notifications_url":"https://api.github.com/repos/arvidn/libtorrent/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/arvidn/libtorrent/labels{/name}","releases_url":"https://api.github.com/repos/arvidn/libtorrent/releases{/id}","deployments_url":"https://api.github.com/repos/arvidn/libtorrent/deployments","created_at":"2015-06-03T05:22:03Z","updated_at":"2016-03-13T02:32:43Z","pushed_at":"2016-03-13T04:23:13Z","git_url":"git://github.com/arvidn/libtorrent.git","ssh_url":"git@github.com:arvidn/libtorrent.git","clone_url":"https://github.com/arvidn/libtorrent.git","svn_url":"https://github.com/arvidn/libtorrent","homepage":"http://libtorrent.org","size":65721,"stargazers_count":334,"watchers_count":334,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":102,"mirror_url":null,"open_issues_count":55,"forks":102,"open_issues":55,"watchers":334,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/arvidn/libtorrent/pulls/536"},"html":{"href":"https://github.com/arvidn/libtorrent/pull/536"},"issue":{"href":"https://api.github.com/repos/arvidn/libtorrent/issues/536"},"comments":{"href":"https://api.github.com/repos/arvidn/libtorrent/issues/536/comments"},"review_comments":{"href":"https://api.github.com/repos/arvidn/libtorrent/pulls/536/comments"},"review_comment":{"href":"https://api.github.com/repos/arvidn/libtorrent/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/arvidn/libtorrent/pulls/536/commits"},"statuses":{"href":"https://api.github.com/repos/arvidn/libtorrent/statuses/c2625f6f78bcf89c2de59841dcfcda1e241fc66e"}}}}