From 789a09b4874ae2616987794e0e739b8227957175 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Tue, 15 Aug 2006 03:39:47 -0700 Subject: [PATCH] avoid nanosleep(2) On Solaris nanosleep(2) is not available in libc; you need to link with -lrt to get it. The purpose of the loop is to wait until the next filesystem timestamp granularity, and the code uses subsecond sleep in the hope that it can shorten the delay to 0.5 seconds on average instead of a full second. It is probably not worth depending on an extra library for this. We might want to yank out the whole "racy-git avoidance is costly later at runtime, so let's delay writing the index out" codepath later, but that is a separate issue and needs some testing on large trees to figure it out. After playing with the kernel tree, I have a feeling that the whole thing may not be worth it. Signed-off-by: Junio C Hamano --- read-cache.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/read-cache.c b/read-cache.c index b18f9f72d9..ec4dd5ae6c 100644 --- a/read-cache.c +++ b/read-cache.c @@ -5,7 +5,6 @@ */ #include "cache.h" #include "cache-tree.h" -#include /* Index extensions. * @@ -1033,11 +1032,8 @@ int write_cache(int newfd, struct cache_entry **cache, int entries) fprintf(stderr, "now %lu\n", now); #endif while (!fstat(newfd, &st) && st.st_mtime <= now) { - struct timespec rq, rm; off_t where = lseek(newfd, 0, SEEK_CUR); - rq.tv_sec = 0; - rq.tv_nsec = 250000000; - nanosleep(&rq, &rm); + sleep(1); if ((where == (off_t) -1) || (write(newfd, "", 1) != 1) || (lseek(newfd, -1, SEEK_CUR) != where) ||