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

[PATCH nd/threaded-index-pack] index-pack: disable threading if NO_PREAD is defined

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
Apr 19, 2012, 14:05 UTC
Message-ID
<1334844329-24557-1-git-send-email-pclouds@gmail.com>

NO_PREAD simulates pread() as a sequence of seek, read, seek in compat/pread.c. The simulation is not thread-safe because another thread could move the file offset away in the middle of pread operation. Do not allow threading in that case.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin/index-pack.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/builtin/index-pack.c b/builtin/index-pack.c
index 847dbb3..c1c3c81 100644
--- a/builtin/index-pack.c
+++ b/builtin/index-pack.c
@@ -39,6 +39,11 @@ struct base_data {
 	int ofs_first, ofs_last;
 };
 
+#if !defined(NO_PTHREADS) && defined(NO_PREAD)
+/* NO_PREAD uses compat/pread.c, which is not thread-safe. Disable threading. */
+#define NO_PTHREADS
+#endif
+
 struct thread_local {
 #ifndef NO_PTHREADS
 	pthread_t thread;
-- 
1.7.8.36.g69ee2
Next: Junio C Hamano
Message 1 of 4 in “index-pack: disable threading if NO_PREAD is defined”
  1. index-pack: disable threading if NO_PREAD is definedNguyễn Thái Ngọc Duy, Apr 19, 2012
  2. Junio C HamanoApr 19, 2012
  3. Johannes SixtApr 20, 2012
  4. Junio C HamanoApr 20, 2012

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.