{"action":"created","comment":{"url":"https://api.github.com/repos/brodie/libgit2/pulls/comments/24548644","id":24548644,"diff_hunk":"@@ -617,9 +609,26 @@ static int refdb_fs_backend__iterator(\n \titer->parent.next_name = refdb_fs_backend__iterator_next_name;\n \titer->parent.free = refdb_fs_backend__iterator_free;\n \n+\t/* Loose refs must be read before reloading the packed refs to\n+\t * avoid a race condition in which loose refs are being packed\n+\t * by another process.\n+         */","path":"src/refdb_fs.c","position":41,"original_position":41,"commit_id":"8d1e155dee3f43a34986f3ad53329c948b19a7c2","original_commit_id":"8d1e155dee3f43a34986f3ad53329c948b19a7c2","user":{"login":"erikvanzijst","id":63338,"avatar_url":"https://avatars.githubusercontent.com/u/63338?v=3","gravatar_id":"","url":"https://api.github.com/users/erikvanzijst","html_url":"https://github.com/erikvanzijst","followers_url":"https://api.github.com/users/erikvanzijst/followers","following_url":"https://api.github.com/users/erikvanzijst/following{/other_user}","gists_url":"https://api.github.com/users/erikvanzijst/gists{/gist_id}","starred_url":"https://api.github.com/users/erikvanzijst/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/erikvanzijst/subscriptions","organizations_url":"https://api.github.com/users/erikvanzijst/orgs","repos_url":"https://api.github.com/users/erikvanzijst/repos","events_url":"https://api.github.com/users/erikvanzijst/events{/privacy}","received_events_url":"https://api.github.com/users/erikvanzijst/received_events","type":"User","site_admin":false},"body":"Indentation.","created_at":"2015-02-12T00:30:26Z","updated_at":"2015-02-12T00:30:26Z","html_url":"https://github.com/brodie/libgit2/pull/1#discussion_r24548644","pull_request_url":"https://api.github.com/repos/brodie/libgit2/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/brodie/libgit2/pulls/comments/24548644"},"html":{"href":"https://github.com/brodie/libgit2/pull/1#discussion_r24548644"},"pull_request":{"href":"https://api.github.com/repos/brodie/libgit2/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/brodie/libgit2/pulls/1","id":29139289,"html_url":"https://github.com/brodie/libgit2/pull/1","diff_url":"https://github.com/brodie/libgit2/pull/1.diff","patch_url":"https://github.com/brodie/libgit2/pull/1.patch","issue_url":"https://api.github.com/repos/brodie/libgit2/issues/1","number":1,"state":"open","locked":false,"title":"Race condition in fs refs iterator when refs are packed by another process","user":{"login":"csomme","id":666623,"avatar_url":"https://avatars.githubusercontent.com/u/666623?v=3","gravatar_id":"","url":"https://api.github.com/users/csomme","html_url":"https://github.com/csomme","followers_url":"https://api.github.com/users/csomme/followers","following_url":"https://api.github.com/users/csomme/following{/other_user}","gists_url":"https://api.github.com/users/csomme/gists{/gist_id}","starred_url":"https://api.github.com/users/csomme/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/csomme/subscriptions","organizations_url":"https://api.github.com/users/csomme/orgs","repos_url":"https://api.github.com/users/csomme/repos","events_url":"https://api.github.com/users/csomme/events{/privacy}","received_events_url":"https://api.github.com/users/csomme/received_events","type":"User","site_admin":false},"body":"When refs are packed, a new pack file is created containing all previously\r\npacked refs as well as any newly packed loose refs. The existing pack file is\r\nthen replaced by the new pack file, and any included loose refs are deleted.\r\n\r\nIn order to avoid a race condition when another process is packing refs, the\r\nloose refs must be loaded before the pack file is loaded.\r\n\r\nThe bug can be demonstrated in the current code by placing a sleep after the\r\ncall to packed_reload and packing the refs in another process. As a result,\r\nany refs that were transitioning from loose to packed will be omited from the\r\nlist of refs returned by the iterator.","created_at":"2015-02-11T23:32:42Z","updated_at":"2015-02-12T00:30:26Z","closed_at":null,"merged_at":null,"merge_commit_sha":"61615caaee09b6b2d7a6a99f90f85f972b75162f","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/brodie/libgit2/pulls/1/commits","review_comments_url":"https://api.github.com/repos/brodie/libgit2/pulls/1/comments","review_comment_url":"https://api.github.com/repos/brodie/libgit2/pulls/comments/{number}","comments_url":"https://api.github.com/repos/brodie/libgit2/issues/1/comments","statuses_url":"https://api.github.com/repos/brodie/libgit2/statuses/8d1e155dee3f43a34986f3ad53329c948b19a7c2","head":{"label":"csomme:csomme/packed-refs-race-condition","ref":"csomme/packed-refs-race-condition","sha":"8d1e155dee3f43a34986f3ad53329c948b19a7c2","user":{"login":"csomme","id":666623,"avatar_url":"https://avatars.githubusercontent.com/u/666623?v=3","gravatar_id":"","url":"https://api.github.com/users/csomme","html_url":"https://github.com/csomme","followers_url":"https://api.github.com/users/csomme/followers","following_url":"https://api.github.com/users/csomme/following{/other_user}","gists_url":"https://api.github.com/users/csomme/gists{/gist_id}","starred_url":"https://api.github.com/users/csomme/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/csomme/subscriptions","organizations_url":"https://api.github.com/users/csomme/orgs","repos_url":"https://api.github.com/users/csomme/repos","events_url":"https://api.github.com/users/csomme/events{/privacy}","received_events_url":"https://api.github.com/users/csomme/received_events","type":"User","site_admin":false},"repo":{"id":30674567,"name":"libgit2","full_name":"csomme/libgit2","owner":{"login":"csomme","id":666623,"avatar_url":"https://avatars.githubusercontent.com/u/666623?v=3","gravatar_id":"","url":"https://api.github.com/users/csomme","html_url":"https://github.com/csomme","followers_url":"https://api.github.com/users/csomme/followers","following_url":"https://api.github.com/users/csomme/following{/other_user}","gists_url":"https://api.github.com/users/csomme/gists{/gist_id}","starred_url":"https://api.github.com/users/csomme/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/csomme/subscriptions","organizations_url":"https://api.github.com/users/csomme/orgs","repos_url":"https://api.github.com/users/csomme/repos","events_url":"https://api.github.com/users/csomme/events{/privacy}","received_events_url":"https://api.github.com/users/csomme/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/csomme/libgit2","description":"The Library","fork":true,"url":"https://api.github.com/repos/csomme/libgit2","forks_url":"https://api.github.com/repos/csomme/libgit2/forks","keys_url":"https://api.github.com/repos/csomme/libgit2/keys{/key_id}","collaborators_url":"https://api.github.com/repos/csomme/libgit2/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/csomme/libgit2/teams","hooks_url":"https://api.github.com/repos/csomme/libgit2/hooks","issue_events_url":"https://api.github.com/repos/csomme/libgit2/issues/events{/number}","events_url":"https://api.github.com/repos/csomme/libgit2/events","assignees_url":"https://api.github.com/repos/csomme/libgit2/assignees{/user}","branches_url":"https://api.github.com/repos/csomme/libgit2/branches{/branch}","tags_url":"https://api.github.com/repos/csomme/libgit2/tags","blobs_url":"https://api.github.com/repos/csomme/libgit2/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/csomme/libgit2/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/csomme/libgit2/git/refs{/sha}","trees_url":"https://api.github.com/repos/csomme/libgit2/git/trees{/sha}","statuses_url":"https://api.github.com/repos/csomme/libgit2/statuses/{sha}","languages_url":"https://api.github.com/repos/csomme/libgit2/languages","stargazers_url":"https://api.github.com/repos/csomme/libgit2/stargazers","contributors_url":"https://api.github.com/repos/csomme/libgit2/contributors","subscribers_url":"https://api.github.com/repos/csomme/libgit2/subscribers","subscription_url":"https://api.github.com/repos/csomme/libgit2/subscription","commits_url":"https://api.github.com/repos/csomme/libgit2/commits{/sha}","git_commits_url":"https://api.github.com/repos/csomme/libgit2/git/commits{/sha}","comments_url":"https://api.github.com/repos/csomme/libgit2/comments{/number}","issue_comment_url":"https://api.github.com/repos/csomme/libgit2/issues/comments/{number}","contents_url":"https://api.github.com/repos/csomme/libgit2/contents/{+path}","compare_url":"https://api.github.com/repos/csomme/libgit2/compare/{base}...{head}","merges_url":"https://api.github.com/repos/csomme/libgit2/merges","archive_url":"https://api.github.com/repos/csomme/libgit2/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/csomme/libgit2/downloads","issues_url":"https://api.github.com/repos/csomme/libgit2/issues{/number}","pulls_url":"https://api.github.com/repos/csomme/libgit2/pulls{/number}","milestones_url":"https://api.github.com/repos/csomme/libgit2/milestones{/number}","notifications_url":"https://api.github.com/repos/csomme/libgit2/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/csomme/libgit2/labels{/name}","releases_url":"https://api.github.com/repos/csomme/libgit2/releases{/id}","created_at":"2015-02-11T23:07:06Z","updated_at":"2015-02-11T23:07:08Z","pushed_at":"2015-02-11T23:27:53Z","git_url":"git://github.com/csomme/libgit2.git","ssh_url":"git@github.com:csomme/libgit2.git","clone_url":"https://github.com/csomme/libgit2.git","svn_url":"https://github.com/csomme/libgit2","homepage":"http://libgit2.github.com","size":11271,"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":"brodie:brodie/handle-null-on-free","ref":"brodie/handle-null-on-free","sha":"2fcc0d07d050a6d70d85c510cef7aea4845e340f","user":{"login":"brodie","id":42407,"avatar_url":"https://avatars.githubusercontent.com/u/42407?v=3","gravatar_id":"","url":"https://api.github.com/users/brodie","html_url":"https://github.com/brodie","followers_url":"https://api.github.com/users/brodie/followers","following_url":"https://api.github.com/users/brodie/following{/other_user}","gists_url":"https://api.github.com/users/brodie/gists{/gist_id}","starred_url":"https://api.github.com/users/brodie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brodie/subscriptions","organizations_url":"https://api.github.com/users/brodie/orgs","repos_url":"https://api.github.com/users/brodie/repos","events_url":"https://api.github.com/users/brodie/events{/privacy}","received_events_url":"https://api.github.com/users/brodie/received_events","type":"User","site_admin":false},"repo":{"id":2183229,"name":"libgit2","full_name":"brodie/libgit2","owner":{"login":"brodie","id":42407,"avatar_url":"https://avatars.githubusercontent.com/u/42407?v=3","gravatar_id":"","url":"https://api.github.com/users/brodie","html_url":"https://github.com/brodie","followers_url":"https://api.github.com/users/brodie/followers","following_url":"https://api.github.com/users/brodie/following{/other_user}","gists_url":"https://api.github.com/users/brodie/gists{/gist_id}","starred_url":"https://api.github.com/users/brodie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brodie/subscriptions","organizations_url":"https://api.github.com/users/brodie/orgs","repos_url":"https://api.github.com/users/brodie/repos","events_url":"https://api.github.com/users/brodie/events{/privacy}","received_events_url":"https://api.github.com/users/brodie/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/brodie/libgit2","description":"The Library","fork":true,"url":"https://api.github.com/repos/brodie/libgit2","forks_url":"https://api.github.com/repos/brodie/libgit2/forks","keys_url":"https://api.github.com/repos/brodie/libgit2/keys{/key_id}","collaborators_url":"https://api.github.com/repos/brodie/libgit2/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/brodie/libgit2/teams","hooks_url":"https://api.github.com/repos/brodie/libgit2/hooks","issue_events_url":"https://api.github.com/repos/brodie/libgit2/issues/events{/number}","events_url":"https://api.github.com/repos/brodie/libgit2/events","assignees_url":"https://api.github.com/repos/brodie/libgit2/assignees{/user}","branches_url":"https://api.github.com/repos/brodie/libgit2/branches{/branch}","tags_url":"https://api.github.com/repos/brodie/libgit2/tags","blobs_url":"https://api.github.com/repos/brodie/libgit2/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/brodie/libgit2/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/brodie/libgit2/git/refs{/sha}","trees_url":"https://api.github.com/repos/brodie/libgit2/git/trees{/sha}","statuses_url":"https://api.github.com/repos/brodie/libgit2/statuses/{sha}","languages_url":"https://api.github.com/repos/brodie/libgit2/languages","stargazers_url":"https://api.github.com/repos/brodie/libgit2/stargazers","contributors_url":"https://api.github.com/repos/brodie/libgit2/contributors","subscribers_url":"https://api.github.com/repos/brodie/libgit2/subscribers","subscription_url":"https://api.github.com/repos/brodie/libgit2/subscription","commits_url":"https://api.github.com/repos/brodie/libgit2/commits{/sha}","git_commits_url":"https://api.github.com/repos/brodie/libgit2/git/commits{/sha}","comments_url":"https://api.github.com/repos/brodie/libgit2/comments{/number}","issue_comment_url":"https://api.github.com/repos/brodie/libgit2/issues/comments/{number}","contents_url":"https://api.github.com/repos/brodie/libgit2/contents/{+path}","compare_url":"https://api.github.com/repos/brodie/libgit2/compare/{base}...{head}","merges_url":"https://api.github.com/repos/brodie/libgit2/merges","archive_url":"https://api.github.com/repos/brodie/libgit2/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/brodie/libgit2/downloads","issues_url":"https://api.github.com/repos/brodie/libgit2/issues{/number}","pulls_url":"https://api.github.com/repos/brodie/libgit2/pulls{/number}","milestones_url":"https://api.github.com/repos/brodie/libgit2/milestones{/number}","notifications_url":"https://api.github.com/repos/brodie/libgit2/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/brodie/libgit2/labels{/name}","releases_url":"https://api.github.com/repos/brodie/libgit2/releases{/id}","created_at":"2011-08-10T03:58:25Z","updated_at":"2014-01-13T14:09:34Z","pushed_at":"2014-01-13T07:34:38Z","git_url":"git://github.com/brodie/libgit2.git","ssh_url":"git@github.com:brodie/libgit2.git","clone_url":"https://github.com/brodie/libgit2.git","svn_url":"https://github.com/brodie/libgit2","homepage":"http://libgit2.github.com","size":11271,"stargazers_count":3,"watchers_count":3,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/brodie/libgit2/pulls/1"},"html":{"href":"https://github.com/brodie/libgit2/pull/1"},"issue":{"href":"https://api.github.com/repos/brodie/libgit2/issues/1"},"comments":{"href":"https://api.github.com/repos/brodie/libgit2/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/brodie/libgit2/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/brodie/libgit2/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/brodie/libgit2/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/brodie/libgit2/statuses/8d1e155dee3f43a34986f3ad53329c948b19a7c2"}}}}