git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 5/6] On Solaris nanosleep() is not in libc but in librt

From
Junio C Hamano <junkio@cox.net>
Date
Aug 15, 2006, 10:35 UTC
Message-ID
<7vzme670dm.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<20060815090129.5223.17174.stgit@leonov.stosberg.net>
Dennis Stosberg <dennis@stosberg.net> writes:
Show 6 quoted lines
> -# Define NEEDS_SOCKET if linking with libc is not enough (SunOS,
> -# Patrick Mauritz).
> +# Define NEEDS_SOCKET if linking with libc is not enough for socket()
> +# (SunOS, Patrick Mauritz).
> +#
> +# Define NEEDS_RT if linking with libc is not enough for nanosleep() (SunOS)

Ah, nanosleep(2) was my fault, and we should be able to just use straight sleep(3) there. 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.

How exotic is -lrt on SunOS? I suspect it is not worth depending on it only for that single use in read-cache.c

We might want to yank out the whole "racy-git avoidance is costly later 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.

In any case, an obvious tentative patch is here.
diff --git a/read-cache.c b/read-cache.c
index b18f9f7..ec4dd5a 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -5,7 +5,6 @@
  */
 #include "cache.h"
 #include "cache-tree.h"
-#include <time.h>
 
 /* Index extensions.
  *
@@ -1033,11 +1032,8 @@ #if 0
 			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) ||
Previous: Dennis StosbergNext: Alex Riesen
Message 7 of 10 in “Configuration tweaks for Solaris”
  1. 0/6 Configuration tweaks for SolarisDennis Stosberg, Aug 15, 2006
  2. 1/6 Solaris has strlcpy() at least since version 8Dennis Stosberg, Aug 15, 2006
  3. 2/6 Solaris does not support C99 format strings before version 10Dennis Stosberg, Aug 15, 2006
  4. 3/6 Look for sockaddr_storage in sys/socket.hDennis Stosberg, Aug 15, 2006
  5. 4/6 Fix detection of ipv6 on SolarisDennis Stosberg, Aug 15, 2006
  6. 5/6 On Solaris nanosleep() is not in libc but in librtDennis Stosberg, Aug 15, 2006
  7. Junio C HamanoAug 15, 2006
  8. Alex RiesenAug 15, 2006
  9. Documentation/technical/racy-git.txtJunio C Hamano, Aug 15, 2006
  10. 6/6 Fix compilation with Sun CCDennis Stosberg, Aug 15, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.