Skip to content

Commit 603511c

Browse files
committed
fixup! read-cache: run verify_hdr() in background thread
Since picking up a33fc72 (read-cache: force_verify_index_checksum, 2017-04-14), we do not even check the SHA-1 of the index by default anymore, therefore we no longer need this workaround. Noticed by Ben Peart. This reverts commit 480829f. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 5d5baf9 commit 603511c

File tree

1 file changed

+0
-60
lines changed

1 file changed

+0
-60
lines changed

read-cache.c

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@
2020
#include "split-index.h"
2121
#include "utf8.h"
2222

23-
#ifndef NO_PTHREADS
24-
#include <pthread.h>
25-
#endif
26-
2723
/* Mask for the name length in ce_flags in the on-disk index */
2824

2925
#define CE_NAMEMASK (0x0fff)
@@ -1538,34 +1534,6 @@ static int verify_hdr(struct cache_header *hdr, unsigned long size)
15381534
return 0;
15391535
}
15401536

1541-
#ifndef NO_PTHREADS
1542-
/*
1543-
* Require index file to be larger than this threshold before
1544-
* we bother using a thread to verify the SHA.
1545-
* This value was arbitrarily chosen.
1546-
*/
1547-
#define VERIFY_HDR_THRESHOLD 10*1024*1024
1548-
1549-
struct verify_hdr_thread_data
1550-
{
1551-
pthread_t thread_id;
1552-
struct cache_header *hdr;
1553-
size_t size;
1554-
int result;
1555-
};
1556-
1557-
/*
1558-
* A thread proc to run the verify_hdr() computation
1559-
* in a background thread.
1560-
*/
1561-
static void *verify_hdr_thread(void *_data)
1562-
{
1563-
struct verify_hdr_thread_data *p = _data;
1564-
p->result = verify_hdr(p->hdr, (unsigned long)p->size);
1565-
return NULL;
1566-
}
1567-
#endif
1568-
15691537
static int read_index_extension(struct index_state *istate,
15701538
const char *ext, void *data, unsigned long sz)
15711539
{
@@ -1767,9 +1735,6 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist)
17671735
void *mmap;
17681736
size_t mmap_size;
17691737
struct strbuf previous_name_buf = STRBUF_INIT, *previous_name;
1770-
#ifndef NO_PTHREADS
1771-
struct verify_hdr_thread_data verify_hdr_thread_data;
1772-
#endif
17731738

17741739
if (istate->initialized)
17751740
return istate->cache_nr;
@@ -1796,23 +1761,8 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist)
17961761
close(fd);
17971762

17981763
hdr = mmap;
1799-
#ifdef NO_PTHREADS
18001764
if (verify_hdr(hdr, mmap_size) < 0)
18011765
goto unmap;
1802-
#else
1803-
if (mmap_size < VERIFY_HDR_THRESHOLD) {
1804-
if (verify_hdr(hdr, mmap_size) < 0)
1805-
goto unmap;
1806-
} else {
1807-
verify_hdr_thread_data.hdr = hdr;
1808-
verify_hdr_thread_data.size = mmap_size;
1809-
verify_hdr_thread_data.result = -1;
1810-
if (pthread_create(
1811-
&verify_hdr_thread_data.thread_id, NULL,
1812-
verify_hdr_thread, &verify_hdr_thread_data))
1813-
die_errno("unable to start verify_hdr_thread");
1814-
}
1815-
#endif
18161766

18171767
hashcpy(istate->sha1, (const unsigned char *)hdr + mmap_size - 20);
18181768
istate->version = ntohl(hdr->hdr_version);
@@ -1860,16 +1810,6 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist)
18601810
src_offset += 8;
18611811
src_offset += extsize;
18621812
}
1863-
1864-
#ifndef NO_PTHREADS
1865-
if (mmap_size >= VERIFY_HDR_THRESHOLD) {
1866-
if (pthread_join(verify_hdr_thread_data.thread_id, NULL))
1867-
die_errno("unable to join verify_hdr_thread");
1868-
if (verify_hdr_thread_data.result < 0)
1869-
goto unmap;
1870-
}
1871-
#endif
1872-
18731813
munmap(mmap, mmap_size);
18741814
return istate->cache_nr;
18751815

0 commit comments

Comments
 (0)