{"action":"created","comment":{"url":"https://api.github.com/repos/bitcoin/bitcoin/pulls/comments/155022256","pull_request_review_id":81254743,"id":155022256,"diff_hunk":"@@ -168,22 +169,27 @@ class SCOPED_LOCKABLE CCriticalBlock\n \n     ~CCriticalBlock() UNLOCK_FUNCTION()\n     {\n-        if (lock.owns_lock())\n+        if (Base::owns_lock())\n             LeaveCritical();\n     }\n \n     operator bool()\n     {\n-        return lock.owns_lock();\n+        return Base::owns_lock();\n     }\n };\n \n+template<typename MutexArg>\n+using DebugLock = CCriticalBlock<typename std::remove_reference<typename std::remove_pointer<MutexArg>::type>::type>;\n+\n #define PASTE(x, y) x ## y\n #define PASTE2(x, y) PASTE(x, y)\n \n-#define LOCK(cs) CCriticalBlock PASTE2(criticalblock, __COUNTER__)(cs, #cs, __FILE__, __LINE__)\n-#define LOCK2(cs1, cs2) CCriticalBlock criticalblock1(cs1, #cs1, __FILE__, __LINE__), criticalblock2(cs2, #cs2, __FILE__, __LINE__)\n-#define TRY_LOCK(cs, name) CCriticalBlock name(cs, #cs, __FILE__, __LINE__, true)\n+#define LOCK(cs) DebugLock<decltype(cs)> PASTE2(criticalblock, __COUNTER__)(cs, #cs, __FILE__, __LINE__)\n+#define LOCK2(cs1, cs2)                                               \\\n+    DebugLock<decltype(cs1)> criticalblock1(cs1, #cs1, __FILE__, __LINE__); \\","path":"src/sync.h","position":147,"original_position":133,"commit_id":"6e3d96e0aae2040dc0d92adf02c901522bf28289","original_commit_id":"0e218b400f6428cafd312696ac1ab913388eac29","user":{"login":"TheBlueMatt","id":649246,"avatar_url":"https://avatars0.githubusercontent.com/u/649246?v=4","gravatar_id":"","url":"https://api.github.com/users/TheBlueMatt","html_url":"https://github.com/TheBlueMatt","followers_url":"https://api.github.com/users/TheBlueMatt/followers","following_url":"https://api.github.com/users/TheBlueMatt/following{/other_user}","gists_url":"https://api.github.com/users/TheBlueMatt/gists{/gist_id}","starred_url":"https://api.github.com/users/TheBlueMatt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TheBlueMatt/subscriptions","organizations_url":"https://api.github.com/users/TheBlueMatt/orgs","repos_url":"https://api.github.com/users/TheBlueMatt/repos","events_url":"https://api.github.com/users/TheBlueMatt/events{/privacy}","received_events_url":"https://api.github.com/users/TheBlueMatt/received_events","type":"User","site_admin":false},"body":"Isnt it considered bad practice to turn a #define into two statements (asking, I dont know, I've just always seen people bend over to avoid it).","created_at":"2017-12-05T17:40:28Z","updated_at":"2017-12-05T17:42:07Z","html_url":"https://github.com/bitcoin/bitcoin/pull/11640#discussion_r155022256","pull_request_url":"https://api.github.com/repos/bitcoin/bitcoin/pulls/11640","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/bitcoin/bitcoin/pulls/comments/155022256"},"html":{"href":"https://github.com/bitcoin/bitcoin/pull/11640#discussion_r155022256"},"pull_request":{"href":"https://api.github.com/repos/bitcoin/bitcoin/pulls/11640"}}},"pull_request":{"url":"https://api.github.com/repos/bitcoin/bitcoin/pulls/11640","id":151503589,"html_url":"https://github.com/bitcoin/bitcoin/pull/11640","diff_url":"https://github.com/bitcoin/bitcoin/pull/11640.diff","patch_url":"https://github.com/bitcoin/bitcoin/pull/11640.patch","issue_url":"https://api.github.com/repos/bitcoin/bitcoin/issues/11640","number":11640,"state":"open","locked":false,"title":"Make LOCK, LOCK2, TRY_LOCK work with CWaitableCriticalSection","user":{"login":"ryanofsky","id":7133040,"avatar_url":"https://avatars2.githubusercontent.com/u/7133040?v=4","gravatar_id":"","url":"https://api.github.com/users/ryanofsky","html_url":"https://github.com/ryanofsky","followers_url":"https://api.github.com/users/ryanofsky/followers","following_url":"https://api.github.com/users/ryanofsky/following{/other_user}","gists_url":"https://api.github.com/users/ryanofsky/gists{/gist_id}","starred_url":"https://api.github.com/users/ryanofsky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ryanofsky/subscriptions","organizations_url":"https://api.github.com/users/ryanofsky/orgs","repos_url":"https://api.github.com/users/ryanofsky/repos","events_url":"https://api.github.com/users/ryanofsky/events{/privacy}","received_events_url":"https://api.github.com/users/ryanofsky/received_events","type":"User","site_admin":false},"body":"Make LOCK macros work with non-recursive mutexes, and use wherever possible for better deadlock detection.\r\n\r\nAlso add unit test for DEBUG_LOCKORDER code.","created_at":"2017-11-08T21:44:04Z","updated_at":"2017-12-05T17:42:07Z","closed_at":null,"merged_at":null,"merge_commit_sha":"16012bffdea8944865f224f36171169a5be1b1d0","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/bitcoin/bitcoin/pulls/11640/commits","review_comments_url":"https://api.github.com/repos/bitcoin/bitcoin/pulls/11640/comments","review_comment_url":"https://api.github.com/repos/bitcoin/bitcoin/pulls/comments{/number}","comments_url":"https://api.github.com/repos/bitcoin/bitcoin/issues/11640/comments","statuses_url":"https://api.github.com/repos/bitcoin/bitcoin/statuses/6e3d96e0aae2040dc0d92adf02c901522bf28289","head":{"label":"ryanofsky:pr/dead","ref":"pr/dead","sha":"6e3d96e0aae2040dc0d92adf02c901522bf28289","user":{"login":"ryanofsky","id":7133040,"avatar_url":"https://avatars2.githubusercontent.com/u/7133040?v=4","gravatar_id":"","url":"https://api.github.com/users/ryanofsky","html_url":"https://github.com/ryanofsky","followers_url":"https://api.github.com/users/ryanofsky/followers","following_url":"https://api.github.com/users/ryanofsky/following{/other_user}","gists_url":"https://api.github.com/users/ryanofsky/gists{/gist_id}","starred_url":"https://api.github.com/users/ryanofsky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ryanofsky/subscriptions","organizations_url":"https://api.github.com/users/ryanofsky/orgs","repos_url":"https://api.github.com/users/ryanofsky/repos","events_url":"https://api.github.com/users/ryanofsky/events{/privacy}","received_events_url":"https://api.github.com/users/ryanofsky/received_events","type":"User","site_admin":false},"repo":{"id":69901633,"name":"bitcoin","full_name":"ryanofsky/bitcoin","owner":{"login":"ryanofsky","id":7133040,"avatar_url":"https://avatars2.githubusercontent.com/u/7133040?v=4","gravatar_id":"","url":"https://api.github.com/users/ryanofsky","html_url":"https://github.com/ryanofsky","followers_url":"https://api.github.com/users/ryanofsky/followers","following_url":"https://api.github.com/users/ryanofsky/following{/other_user}","gists_url":"https://api.github.com/users/ryanofsky/gists{/gist_id}","starred_url":"https://api.github.com/users/ryanofsky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ryanofsky/subscriptions","organizations_url":"https://api.github.com/users/ryanofsky/orgs","repos_url":"https://api.github.com/users/ryanofsky/repos","events_url":"https://api.github.com/users/ryanofsky/events{/privacy}","received_events_url":"https://api.github.com/users/ryanofsky/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ryanofsky/bitcoin","description":"Bitcoin Core integration/staging tree","fork":true,"url":"https://api.github.com/repos/ryanofsky/bitcoin","forks_url":"https://api.github.com/repos/ryanofsky/bitcoin/forks","keys_url":"https://api.github.com/repos/ryanofsky/bitcoin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ryanofsky/bitcoin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ryanofsky/bitcoin/teams","hooks_url":"https://api.github.com/repos/ryanofsky/bitcoin/hooks","issue_events_url":"https://api.github.com/repos/ryanofsky/bitcoin/issues/events{/number}","events_url":"https://api.github.com/repos/ryanofsky/bitcoin/events","assignees_url":"https://api.github.com/repos/ryanofsky/bitcoin/assignees{/user}","branches_url":"https://api.github.com/repos/ryanofsky/bitcoin/branches{/branch}","tags_url":"https://api.github.com/repos/ryanofsky/bitcoin/tags","blobs_url":"https://api.github.com/repos/ryanofsky/bitcoin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ryanofsky/bitcoin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ryanofsky/bitcoin/git/refs{/sha}","trees_url":"https://api.github.com/repos/ryanofsky/bitcoin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ryanofsky/bitcoin/statuses/{sha}","languages_url":"https://api.github.com/repos/ryanofsky/bitcoin/languages","stargazers_url":"https://api.github.com/repos/ryanofsky/bitcoin/stargazers","contributors_url":"https://api.github.com/repos/ryanofsky/bitcoin/contributors","subscribers_url":"https://api.github.com/repos/ryanofsky/bitcoin/subscribers","subscription_url":"https://api.github.com/repos/ryanofsky/bitcoin/subscription","commits_url":"https://api.github.com/repos/ryanofsky/bitcoin/commits{/sha}","git_commits_url":"https://api.github.com/repos/ryanofsky/bitcoin/git/commits{/sha}","comments_url":"https://api.github.com/repos/ryanofsky/bitcoin/comments{/number}","issue_comment_url":"https://api.github.com/repos/ryanofsky/bitcoin/issues/comments{/number}","contents_url":"https://api.github.com/repos/ryanofsky/bitcoin/contents/{+path}","compare_url":"https://api.github.com/repos/ryanofsky/bitcoin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ryanofsky/bitcoin/merges","archive_url":"https://api.github.com/repos/ryanofsky/bitcoin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ryanofsky/bitcoin/downloads","issues_url":"https://api.github.com/repos/ryanofsky/bitcoin/issues{/number}","pulls_url":"https://api.github.com/repos/ryanofsky/bitcoin/pulls{/number}","milestones_url":"https://api.github.com/repos/ryanofsky/bitcoin/milestones{/number}","notifications_url":"https://api.github.com/repos/ryanofsky/bitcoin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ryanofsky/bitcoin/labels{/name}","releases_url":"https://api.github.com/repos/ryanofsky/bitcoin/releases{/id}","deployments_url":"https://api.github.com/repos/ryanofsky/bitcoin/deployments","created_at":"2016-10-03T19:05:43Z","updated_at":"2017-01-13T07:55:29Z","pushed_at":"2017-12-01T22:29:16Z","git_url":"git://github.com/ryanofsky/bitcoin.git","ssh_url":"git@github.com:ryanofsky/bitcoin.git","clone_url":"https://github.com/ryanofsky/bitcoin.git","svn_url":"https://github.com/ryanofsky/bitcoin","homepage":"https://bitcoin.org/en/download","size":90815,"stargazers_count":1,"watchers_count":1,"language":"C++","has_issues":false,"has_projects":true,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":1,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":1,"open_issues":0,"watchers":1,"default_branch":"export"}},"base":{"label":"bitcoin:master","ref":"master","sha":"a89221873a3ee2451c73b41bbe2d99d36f439d31","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":"2017-12-05T17:31:25Z","pushed_at":"2017-12-05T15:41:02Z","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":90614,"stargazers_count":20499,"watchers_count":20499,"language":"C++","has_issues":true,"has_projects":true,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":12045,"mirror_url":null,"archived":false,"open_issues_count":774,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":12045,"open_issues":774,"watchers":20499,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/bitcoin/bitcoin/pulls/11640"},"html":{"href":"https://github.com/bitcoin/bitcoin/pull/11640"},"issue":{"href":"https://api.github.com/repos/bitcoin/bitcoin/issues/11640"},"comments":{"href":"https://api.github.com/repos/bitcoin/bitcoin/issues/11640/comments"},"review_comments":{"href":"https://api.github.com/repos/bitcoin/bitcoin/pulls/11640/comments"},"review_comment":{"href":"https://api.github.com/repos/bitcoin/bitcoin/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/bitcoin/bitcoin/pulls/11640/commits"},"statuses":{"href":"https://api.github.com/repos/bitcoin/bitcoin/statuses/6e3d96e0aae2040dc0d92adf02c901522bf28289"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"TheBlueMatt"}}