{"action":"created","comment":{"url":"https://api.github.com/repos/bitcoin/bitcoin/pulls/comments/168541842","pull_request_review_id":96927280,"id":168541842,"diff_hunk":"@@ -373,27 +373,50 @@ int LogPrintStr(const std::string &str)\n     return ret;\n }\n \n+/** A map that contains all the currently held directory locks. After\n+ * successful locking, these will be held here until the global destructor\n+ * cleans them up and thus automatically unlocks them, or ReleaseDirectoryLocks\n+ * is called.\n+ */\n+static std::map<std::string, std::unique_ptr<boost::interprocess::file_lock>> dir_locks;\n+/** Mutex to protect dir_locks. */\n+static std::mutex cs_dir_locks;\n+\n bool LockDirectory(const fs::path& directory, const std::string lockfile_name, bool probe_only)\n {\n+    std::lock_guard<std::mutex> ulock(cs_dir_locks);\n     fs::path pathLockFile = directory / lockfile_name;\n-    FILE* file = fsbridge::fopen(pathLockFile, \"a\"); // empty lock file; created if it doesn't exist.\n+\n+    // If a lock for this directory already exists in the map, don't try to re-lock it","path":"src/util.cpp","position":19,"original_position":19,"commit_id":"1d4cbd26e4220982f7f2f60e447199d6f62ae254","original_commit_id":"2207709e6ec18eaac3a3d14d0e00e428cbf79e2a","user":{"login":"laanwj","id":126646,"avatar_url":"https://avatars0.githubusercontent.com/u/126646?v=4","gravatar_id":"","url":"https://api.github.com/users/laanwj","html_url":"https://github.com/laanwj","followers_url":"https://api.github.com/users/laanwj/followers","following_url":"https://api.github.com/users/laanwj/following{/other_user}","gists_url":"https://api.github.com/users/laanwj/gists{/gist_id}","starred_url":"https://api.github.com/users/laanwj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/laanwj/subscriptions","organizations_url":"https://api.github.com/users/laanwj/orgs","repos_url":"https://api.github.com/users/laanwj/repos","events_url":"https://api.github.com/users/laanwj/events{/privacy}","received_events_url":"https://api.github.com/users/laanwj/received_events","type":"User","site_admin":false},"body":"I'm a bit confused here, to be honest. Does `try_emplace` avoid constructing the object entirely if it already exists in the map?","created_at":"2018-02-15T17:02:54Z","updated_at":"2018-02-15T17:02:54Z","html_url":"https://github.com/bitcoin/bitcoin/pull/12422#discussion_r168541842","pull_request_url":"https://api.github.com/repos/bitcoin/bitcoin/pulls/12422","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/bitcoin/bitcoin/pulls/comments/168541842"},"html":{"href":"https://github.com/bitcoin/bitcoin/pull/12422#discussion_r168541842"},"pull_request":{"href":"https://api.github.com/repos/bitcoin/bitcoin/pulls/12422"}},"in_reply_to_id":168311689},"pull_request":{"url":"https://api.github.com/repos/bitcoin/bitcoin/pulls/12422","id":168817553,"html_url":"https://github.com/bitcoin/bitcoin/pull/12422","diff_url":"https://github.com/bitcoin/bitcoin/pull/12422.diff","patch_url":"https://github.com/bitcoin/bitcoin/pull/12422.patch","issue_url":"https://api.github.com/repos/bitcoin/bitcoin/issues/12422","number":12422,"state":"open","locked":false,"title":"util: Make LockDirectory thread-safe, consistent, and fix OpenBSD 6.2 build","user":{"login":"laanwj","id":126646,"avatar_url":"https://avatars0.githubusercontent.com/u/126646?v=4","gravatar_id":"","url":"https://api.github.com/users/laanwj","html_url":"https://github.com/laanwj","followers_url":"https://api.github.com/users/laanwj/followers","following_url":"https://api.github.com/users/laanwj/following{/other_user}","gists_url":"https://api.github.com/users/laanwj/gists{/gist_id}","starred_url":"https://api.github.com/users/laanwj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/laanwj/subscriptions","organizations_url":"https://api.github.com/users/laanwj/orgs","repos_url":"https://api.github.com/users/laanwj/repos","events_url":"https://api.github.com/users/laanwj/events{/privacy}","received_events_url":"https://api.github.com/users/laanwj/received_events","type":"User","site_admin":false},"body":"Wrap the `boost::interprocess::file_lock` in a `std::unique_ptr` inside the map that keeps track of per-directory locks.\r\n\r\nThis fixes a build issue with the clang 4.0.0+boost-1.58.0p8 version combo on OpenBSD 6.2, and should have no effect otherwise.\r\n\r\nAlso add a unit test, make the function thread-safe, and fix Linux versus Windows behavior inconsistency.\r\n\r\nMeant to fix #12413.","created_at":"2018-02-13T11:17:18Z","updated_at":"2018-02-15T17:02:54Z","closed_at":null,"merged_at":null,"merge_commit_sha":"41d14f1b76c59be1796e36c0eab45cfcd76403c9","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":234878,"url":"https://api.github.com/repos/bitcoin/bitcoin/labels/Linux/Unix","name":"Linux/Unix","color":"770000","default":false},{"id":294841739,"url":"https://api.github.com/repos/bitcoin/bitcoin/labels/Needs%20backport","name":"Needs backport","color":"ff8200","default":false},{"id":241832923,"url":"https://api.github.com/repos/bitcoin/bitcoin/labels/Utils/log/libs","name":"Utils/log/libs","color":"5319e7","default":false}],"milestone":{"url":"https://api.github.com/repos/bitcoin/bitcoin/milestones/30","html_url":"https://github.com/bitcoin/bitcoin/milestone/30","labels_url":"https://api.github.com/repos/bitcoin/bitcoin/milestones/30/labels","id":2626187,"number":30,"title":"0.16.0","description":"This will be the release of segwit wallet. 🎉 ","creator":{"login":"laanwj","id":126646,"avatar_url":"https://avatars0.githubusercontent.com/u/126646?v=4","gravatar_id":"","url":"https://api.github.com/users/laanwj","html_url":"https://github.com/laanwj","followers_url":"https://api.github.com/users/laanwj/followers","following_url":"https://api.github.com/users/laanwj/following{/other_user}","gists_url":"https://api.github.com/users/laanwj/gists{/gist_id}","starred_url":"https://api.github.com/users/laanwj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/laanwj/subscriptions","organizations_url":"https://api.github.com/users/laanwj/orgs","repos_url":"https://api.github.com/users/laanwj/repos","events_url":"https://api.github.com/users/laanwj/events{/privacy}","received_events_url":"https://api.github.com/users/laanwj/received_events","type":"User","site_admin":false},"open_issues":4,"closed_issues":66,"state":"open","created_at":"2017-07-06T19:58:41Z","updated_at":"2018-02-15T13:34:47Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/bitcoin/bitcoin/pulls/12422/commits","review_comments_url":"https://api.github.com/repos/bitcoin/bitcoin/pulls/12422/comments","review_comment_url":"https://api.github.com/repos/bitcoin/bitcoin/pulls/comments{/number}","comments_url":"https://api.github.com/repos/bitcoin/bitcoin/issues/12422/comments","statuses_url":"https://api.github.com/repos/bitcoin/bitcoin/statuses/1d4cbd26e4220982f7f2f60e447199d6f62ae254","head":{"label":"laanwj:2018_01_openbsd_util_fix","ref":"2018_01_openbsd_util_fix","sha":"1d4cbd26e4220982f7f2f60e447199d6f62ae254","user":{"login":"laanwj","id":126646,"avatar_url":"https://avatars0.githubusercontent.com/u/126646?v=4","gravatar_id":"","url":"https://api.github.com/users/laanwj","html_url":"https://github.com/laanwj","followers_url":"https://api.github.com/users/laanwj/followers","following_url":"https://api.github.com/users/laanwj/following{/other_user}","gists_url":"https://api.github.com/users/laanwj/gists{/gist_id}","starred_url":"https://api.github.com/users/laanwj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/laanwj/subscriptions","organizations_url":"https://api.github.com/users/laanwj/orgs","repos_url":"https://api.github.com/users/laanwj/repos","events_url":"https://api.github.com/users/laanwj/events{/privacy}","received_events_url":"https://api.github.com/users/laanwj/received_events","type":"User","site_admin":false},"repo":{"id":1750308,"name":"bitcoin","full_name":"laanwj/bitcoin","owner":{"login":"laanwj","id":126646,"avatar_url":"https://avatars0.githubusercontent.com/u/126646?v=4","gravatar_id":"","url":"https://api.github.com/users/laanwj","html_url":"https://github.com/laanwj","followers_url":"https://api.github.com/users/laanwj/followers","following_url":"https://api.github.com/users/laanwj/following{/other_user}","gists_url":"https://api.github.com/users/laanwj/gists{/gist_id}","starred_url":"https://api.github.com/users/laanwj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/laanwj/subscriptions","organizations_url":"https://api.github.com/users/laanwj/orgs","repos_url":"https://api.github.com/users/laanwj/repos","events_url":"https://api.github.com/users/laanwj/events{/privacy}","received_events_url":"https://api.github.com/users/laanwj/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/laanwj/bitcoin","description":"Laanwj's Bitcoin Core fork - see README.md on master branch","fork":true,"url":"https://api.github.com/repos/laanwj/bitcoin","forks_url":"https://api.github.com/repos/laanwj/bitcoin/forks","keys_url":"https://api.github.com/repos/laanwj/bitcoin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/laanwj/bitcoin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/laanwj/bitcoin/teams","hooks_url":"https://api.github.com/repos/laanwj/bitcoin/hooks","issue_events_url":"https://api.github.com/repos/laanwj/bitcoin/issues/events{/number}","events_url":"https://api.github.com/repos/laanwj/bitcoin/events","assignees_url":"https://api.github.com/repos/laanwj/bitcoin/assignees{/user}","branches_url":"https://api.github.com/repos/laanwj/bitcoin/branches{/branch}","tags_url":"https://api.github.com/repos/laanwj/bitcoin/tags","blobs_url":"https://api.github.com/repos/laanwj/bitcoin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/laanwj/bitcoin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/laanwj/bitcoin/git/refs{/sha}","trees_url":"https://api.github.com/repos/laanwj/bitcoin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/laanwj/bitcoin/statuses/{sha}","languages_url":"https://api.github.com/repos/laanwj/bitcoin/languages","stargazers_url":"https://api.github.com/repos/laanwj/bitcoin/stargazers","contributors_url":"https://api.github.com/repos/laanwj/bitcoin/contributors","subscribers_url":"https://api.github.com/repos/laanwj/bitcoin/subscribers","subscription_url":"https://api.github.com/repos/laanwj/bitcoin/subscription","commits_url":"https://api.github.com/repos/laanwj/bitcoin/commits{/sha}","git_commits_url":"https://api.github.com/repos/laanwj/bitcoin/git/commits{/sha}","comments_url":"https://api.github.com/repos/laanwj/bitcoin/comments{/number}","issue_comment_url":"https://api.github.com/repos/laanwj/bitcoin/issues/comments{/number}","contents_url":"https://api.github.com/repos/laanwj/bitcoin/contents/{+path}","compare_url":"https://api.github.com/repos/laanwj/bitcoin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/laanwj/bitcoin/merges","archive_url":"https://api.github.com/repos/laanwj/bitcoin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/laanwj/bitcoin/downloads","issues_url":"https://api.github.com/repos/laanwj/bitcoin/issues{/number}","pulls_url":"https://api.github.com/repos/laanwj/bitcoin/pulls{/number}","milestones_url":"https://api.github.com/repos/laanwj/bitcoin/milestones{/number}","notifications_url":"https://api.github.com/repos/laanwj/bitcoin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/laanwj/bitcoin/labels{/name}","releases_url":"https://api.github.com/repos/laanwj/bitcoin/releases{/id}","deployments_url":"https://api.github.com/repos/laanwj/bitcoin/deployments","created_at":"2011-05-15T07:09:54Z","updated_at":"2017-12-18T14:03:56Z","pushed_at":"2018-02-15T15:27:39Z","git_url":"git://github.com/laanwj/bitcoin.git","ssh_url":"git@github.com:laanwj/bitcoin.git","clone_url":"https://github.com/laanwj/bitcoin.git","svn_url":"https://github.com/laanwj/bitcoin","homepage":"","size":89507,"stargazers_count":16,"watchers_count":16,"language":null,"has_issues":false,"has_projects":true,"has_downloads":false,"has_wiki":true,"has_pages":false,"forks_count":8,"mirror_url":null,"archived":false,"open_issues_count":1,"license":null,"forks":8,"open_issues":1,"watchers":16,"default_branch":"master"}},"base":{"label":"bitcoin:master","ref":"master","sha":"bfa39114e2cf4712fe74d7b19d516553f43e5fa0","user":{"login":"bitcoin","id":528860,"avatar_url":"https://avatars2.githubusercontent.com/u/528860?v=4","gravatar_id":"","url":"https://api.github.com/users/bitcoin","html_url":"https://github.com/bitcoin","followers_url":"https://api.github.com/users/bitcoin/followers","following_url":"https://api.github.com/users/bitcoin/following{/other_user}","gists_url":"https://api.github.com/users/bitcoin/gists{/gist_id}","starred_url":"https://api.github.com/users/bitcoin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bitcoin/subscriptions","organizations_url":"https://api.github.com/users/bitcoin/orgs","repos_url":"https://api.github.com/users/bitcoin/repos","events_url":"https://api.github.com/users/bitcoin/events{/privacy}","received_events_url":"https://api.github.com/users/bitcoin/received_events","type":"Organization","site_admin":false},"repo":{"id":1181927,"name":"bitcoin","full_name":"bitcoin/bitcoin","owner":{"login":"bitcoin","id":528860,"avatar_url":"https://avatars2.githubusercontent.com/u/528860?v=4","gravatar_id":"","url":"https://api.github.com/users/bitcoin","html_url":"https://github.com/bitcoin","followers_url":"https://api.github.com/users/bitcoin/followers","following_url":"https://api.github.com/users/bitcoin/following{/other_user}","gists_url":"https://api.github.com/users/bitcoin/gists{/gist_id}","starred_url":"https://api.github.com/users/bitcoin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bitcoin/subscriptions","organizations_url":"https://api.github.com/users/bitcoin/orgs","repos_url":"https://api.github.com/users/bitcoin/repos","events_url":"https://api.github.com/users/bitcoin/events{/privacy}","received_events_url":"https://api.github.com/users/bitcoin/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/bitcoin/bitcoin","description":"Bitcoin Core integration/staging tree","fork":false,"url":"https://api.github.com/repos/bitcoin/bitcoin","forks_url":"https://api.github.com/repos/bitcoin/bitcoin/forks","keys_url":"https://api.github.com/repos/bitcoin/bitcoin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bitcoin/bitcoin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bitcoin/bitcoin/teams","hooks_url":"https://api.github.com/repos/bitcoin/bitcoin/hooks","issue_events_url":"https://api.github.com/repos/bitcoin/bitcoin/issues/events{/number}","events_url":"https://api.github.com/repos/bitcoin/bitcoin/events","assignees_url":"https://api.github.com/repos/bitcoin/bitcoin/assignees{/user}","branches_url":"https://api.github.com/repos/bitcoin/bitcoin/branches{/branch}","tags_url":"https://api.github.com/repos/bitcoin/bitcoin/tags","blobs_url":"https://api.github.com/repos/bitcoin/bitcoin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bitcoin/bitcoin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bitcoin/bitcoin/git/refs{/sha}","trees_url":"https://api.github.com/repos/bitcoin/bitcoin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bitcoin/bitcoin/statuses/{sha}","languages_url":"https://api.github.com/repos/bitcoin/bitcoin/languages","stargazers_url":"https://api.github.com/repos/bitcoin/bitcoin/stargazers","contributors_url":"https://api.github.com/repos/bitcoin/bitcoin/contributors","subscribers_url":"https://api.github.com/repos/bitcoin/bitcoin/subscribers","subscription_url":"https://api.github.com/repos/bitcoin/bitcoin/subscription","commits_url":"https://api.github.com/repos/bitcoin/bitcoin/commits{/sha}","git_commits_url":"https://api.github.com/repos/bitcoin/bitcoin/git/commits{/sha}","comments_url":"https://api.github.com/repos/bitcoin/bitcoin/comments{/number}","issue_comment_url":"https://api.github.com/repos/bitcoin/bitcoin/issues/comments{/number}","contents_url":"https://api.github.com/repos/bitcoin/bitcoin/contents/{+path}","compare_url":"https://api.github.com/repos/bitcoin/bitcoin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bitcoin/bitcoin/merges","archive_url":"https://api.github.com/repos/bitcoin/bitcoin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bitcoin/bitcoin/downloads","issues_url":"https://api.github.com/repos/bitcoin/bitcoin/issues{/number}","pulls_url":"https://api.github.com/repos/bitcoin/bitcoin/pulls{/number}","milestones_url":"https://api.github.com/repos/bitcoin/bitcoin/milestones{/number}","notifications_url":"https://api.github.com/repos/bitcoin/bitcoin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bitcoin/bitcoin/labels{/name}","releases_url":"https://api.github.com/repos/bitcoin/bitcoin/releases{/id}","deployments_url":"https://api.github.com/repos/bitcoin/bitcoin/deployments","created_at":"2010-12-19T15:16:43Z","updated_at":"2018-02-15T15:58:28Z","pushed_at":"2018-02-15T16:11:41Z","git_url":"git://github.com/bitcoin/bitcoin.git","ssh_url":"git@github.com:bitcoin/bitcoin.git","clone_url":"https://github.com/bitcoin/bitcoin.git","svn_url":"https://github.com/bitcoin/bitcoin","homepage":"https://bitcoin.org/en/download","size":97480,"stargazers_count":27663,"watchers_count":27663,"language":"C++","has_issues":true,"has_projects":true,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":16382,"mirror_url":null,"archived":false,"open_issues_count":866,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":16382,"open_issues":866,"watchers":27663,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/bitcoin/bitcoin/pulls/12422"},"html":{"href":"https://github.com/bitcoin/bitcoin/pull/12422"},"issue":{"href":"https://api.github.com/repos/bitcoin/bitcoin/issues/12422"},"comments":{"href":"https://api.github.com/repos/bitcoin/bitcoin/issues/12422/comments"},"review_comments":{"href":"https://api.github.com/repos/bitcoin/bitcoin/pulls/12422/comments"},"review_comment":{"href":"https://api.github.com/repos/bitcoin/bitcoin/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/bitcoin/bitcoin/pulls/12422/commits"},"statuses":{"href":"https://api.github.com/repos/bitcoin/bitcoin/statuses/1d4cbd26e4220982f7f2f60e447199d6f62ae254"}},"author_association":"OWNER"}}
{"actor":{"display_login":"laanwj"}}