Commit 1e90ae77 by Vicent Martí

Merge pull request #860 from schu/thread-safety

odb_pack: make sure to search all backends
parents 70341b09 3d7617e4
...@@ -267,9 +267,10 @@ static int pack_entry_find(struct git_pack_entry *e, struct pack_backend *backen ...@@ -267,9 +267,10 @@ static int pack_entry_find(struct git_pack_entry *e, struct pack_backend *backen
{ {
int error; int error;
unsigned int i; unsigned int i;
struct git_pack_file *last_found = backend->last_found;
if (backend->last_found && if (last_found &&
git_pack_entry_find(e, backend->last_found, oid, GIT_OID_HEXSZ) == 0) git_pack_entry_find(e, last_found, oid, GIT_OID_HEXSZ) == 0)
return 0; return 0;
if ((error = packfile_refresh_all(backend)) < 0) if ((error = packfile_refresh_all(backend)) < 0)
...@@ -279,7 +280,7 @@ static int pack_entry_find(struct git_pack_entry *e, struct pack_backend *backen ...@@ -279,7 +280,7 @@ static int pack_entry_find(struct git_pack_entry *e, struct pack_backend *backen
struct git_pack_file *p; struct git_pack_file *p;
p = git_vector_get(&backend->packs, i); p = git_vector_get(&backend->packs, i);
if (p == backend->last_found) if (p == last_found)
continue; continue;
if (git_pack_entry_find(e, p, oid, GIT_OID_HEXSZ) == 0) { if (git_pack_entry_find(e, p, oid, GIT_OID_HEXSZ) == 0) {
...@@ -300,12 +301,13 @@ static int pack_entry_find_prefix( ...@@ -300,12 +301,13 @@ static int pack_entry_find_prefix(
int error; int error;
unsigned int i; unsigned int i;
unsigned found = 0; unsigned found = 0;
struct git_pack_file *last_found = backend->last_found;
if ((error = packfile_refresh_all(backend)) < 0) if ((error = packfile_refresh_all(backend)) < 0)
return error; return error;
if (backend->last_found) { if (last_found) {
error = git_pack_entry_find(e, backend->last_found, short_oid, len); error = git_pack_entry_find(e, last_found, short_oid, len);
if (error == GIT_EAMBIGUOUS) if (error == GIT_EAMBIGUOUS)
return error; return error;
if (!error) if (!error)
...@@ -316,7 +318,7 @@ static int pack_entry_find_prefix( ...@@ -316,7 +318,7 @@ static int pack_entry_find_prefix(
struct git_pack_file *p; struct git_pack_file *p;
p = git_vector_get(&backend->packs, i); p = git_vector_get(&backend->packs, i);
if (p == backend->last_found) if (p == last_found)
continue; continue;
error = git_pack_entry_find(e, p, short_oid, len); error = git_pack_entry_find(e, p, short_oid, len);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment