diff options
author | Junio C Hamano <gitster@pobox.com> | 2014-06-03 12:06:41 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2014-06-03 12:06:41 -0700 |
commit | 9af098c29b2faa89225556258ae0e3676741c981 (patch) | |
tree | ba6752e3109e5206465c08fdf2538deb9ee4704b /cache.h | |
parent | Merge branch 'mh/ref-transaction' (diff) | |
parent | read-cache.c: verify index file before we opportunistically update it (diff) | |
download | tgif-9af098c29b2faa89225556258ae0e3676741c981.tar.xz |
Merge branch 'ym/fix-opportunistic-index-update-race'
Read-only operations such as "git status" that internally refreshes
the index write out the refreshed index to the disk to optimize
future accesses to the working tree, but this could race with a
"read-write" operation that modify the index while it is running.
Detect such a race and avoid overwriting the index.
Duy raised a good point that we may need to do the same for the
normal writeout codepath, not just the "opportunistic" update
codepath. While that is true, nobody sane would be running two
simultaneous operations that are clearly write-oriented competing
with each other against the same index file. So in that sense that
can be done as a less urgent follow-up for this topic.
* ym/fix-opportunistic-index-update-race:
read-cache.c: verify index file before we opportunistically update it
wrapper.c: add xpread() similar to xread()
Diffstat (limited to 'cache.h')
-rw-r--r-- | cache.h | 3 |
1 files changed, 3 insertions, 0 deletions
@@ -294,6 +294,7 @@ struct index_state { initialized : 1; struct hashmap name_hash; struct hashmap dir_hash; + unsigned char sha1[20]; }; extern struct index_state the_index; @@ -1337,6 +1338,8 @@ extern void fsync_or_die(int fd, const char *); extern ssize_t read_in_full(int fd, void *buf, size_t count); extern ssize_t write_in_full(int fd, const void *buf, size_t count); +extern ssize_t pread_in_full(int fd, void *buf, size_t count, off_t offset); + static inline ssize_t write_str_in_full(int fd, const char *str) { return write_in_full(fd, str, strlen(str)); |