git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH nd/threaded-index-pack] index-pack: disable threading if NO_PREAD is defined
@ 2012-04-19 14:05 Nguyễn Thái Ngọc Duy
  2012-04-19 20:44 ` Junio C Hamano
  2012-04-20  6:25 ` Johannes Sixt
  0 siblings, 2 replies; 4+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2012-04-19 14:05 UTC (permalink / raw)
  To: git
  Cc: kusmabite, Johannes Sixt, Ramsay Jones, Junio C Hamano,
	Nguyễn Thái Ngọc Duy

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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-04-20 19:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-04-19 14:05 [PATCH nd/threaded-index-pack] index-pack: disable threading if NO_PREAD is defined Nguyễn Thái Ngọc Duy
2012-04-19 20:44 ` Junio C Hamano
2012-04-20  6:25 ` Johannes Sixt
2012-04-20 19:49   ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).