diff options
author | Junio C Hamano <gitster@pobox.com> | 2022-09-13 21:21:08 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2022-09-13 21:21:08 +0200 |
commit | aa31cb89743a9ba4efd43f5160bfea0a4cbe5858 (patch) | |
tree | 0c70668c1d69a88696f9e40c5bc4d90617170286 /git-compat-util.h | |
parent | Merge branch 'jk/is-promisor-object-keep-tree-in-use' into maint (diff) | |
parent | pipe_command(): mark stdin descriptor as non-blocking (diff) | |
download | git-aa31cb89743a9ba4efd43f5160bfea0a4cbe5858.tar.xz git-aa31cb89743a9ba4efd43f5160bfea0a4cbe5858.zip |
Merge branch 'jk/pipe-command-nonblock' into maint
Fix deadlocks between main Git process and subprocess spawned via
the pipe_command() API, that can kill "git add -p" that was
reimplemented in C recently.
* jk/pipe-command-nonblock:
pipe_command(): mark stdin descriptor as non-blocking
pipe_command(): handle ENOSPC when writing to a pipe
pipe_command(): avoid xwrite() for writing to pipe
git-compat-util: make MAX_IO_SIZE define globally available
nonblock: support Windows
compat: add function to enable nonblocking pipes
Diffstat (limited to 'git-compat-util.h')
-rw-r--r-- | git-compat-util.h | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/git-compat-util.h b/git-compat-util.h index 36a25ae252..6aee4d92e7 100644 --- a/git-compat-util.h +++ b/git-compat-util.h @@ -998,6 +998,28 @@ static inline unsigned long cast_size_t_to_ulong(size_t a) return (unsigned long)a; } +/* + * Limit size of IO chunks, because huge chunks only cause pain. OS X + * 64-bit is buggy, returning EINVAL if len >= INT_MAX; and even in + * the absence of bugs, large chunks can result in bad latencies when + * you decide to kill the process. + * + * We pick 8 MiB as our default, but if the platform defines SSIZE_MAX + * that is smaller than that, clip it to SSIZE_MAX, as a call to + * read(2) or write(2) larger than that is allowed to fail. As the last + * resort, we allow a port to pass via CFLAGS e.g. "-DMAX_IO_SIZE=value" + * to override this, if the definition of SSIZE_MAX given by the platform + * is broken. + */ +#ifndef MAX_IO_SIZE +# define MAX_IO_SIZE_DEFAULT (8*1024*1024) +# if defined(SSIZE_MAX) && (SSIZE_MAX < MAX_IO_SIZE_DEFAULT) +# define MAX_IO_SIZE SSIZE_MAX +# else +# define MAX_IO_SIZE MAX_IO_SIZE_DEFAULT +# endif +#endif + #ifdef HAVE_ALLOCA_H # include <alloca.h> # define xalloca(size) (alloca(size)) |