mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-27 15:52:00 -08:00
Allow control of data amount read from subprocess in one chunk
* src/process.c (syms_of_process) <read-process-output-max>: New variable. (read_process_output): Use it instead of the hard-coded constant 4096. (Bug#38561) Use SAFE_ALLOCA to support large buffers for reading process output. * etc/NEWS: Mention 'read-process-output-max'.
This commit is contained in:
parent
0f7e3430bb
commit
cc78faee7d
2 changed files with 22 additions and 5 deletions
8
etc/NEWS
8
etc/NEWS
|
|
@ -2724,6 +2724,14 @@ overlays. This is only done on 'display' properties that have the
|
|||
** 'process-contact' now takes an optional NO-BLOCK argument to allow
|
||||
not waiting for a process to be set up.
|
||||
|
||||
---
|
||||
** New variable 'read-process-output-max' controls sub-process throughput.
|
||||
This variable determines how many bytes can be read from a sub-process
|
||||
in one read operation. The default, 4096 bytes, was previously a
|
||||
hard-coded constant. Setting it to a larger value might enhance
|
||||
throughput of reading from sub-processes that produces vast
|
||||
(megabytes) amounts of data in one go.
|
||||
|
||||
+++
|
||||
** The new user option 'quit-window-hook' is now run first when
|
||||
executing the 'quit-window' command.
|
||||
|
|
|
|||
|
|
@ -6008,7 +6008,7 @@ read_and_dispose_of_process_output (struct Lisp_Process *p, char *chars,
|
|||
Yield number of decoded characters read,
|
||||
or -1 (setting errno) if there is a read error.
|
||||
|
||||
This function reads at most 4096 characters.
|
||||
This function reads at most read_process_output_max bytes.
|
||||
If you want to read all available subprocess output,
|
||||
you must call it repeatedly until it returns zero.
|
||||
|
||||
|
|
@ -6022,10 +6022,13 @@ read_process_output (Lisp_Object proc, int channel)
|
|||
struct Lisp_Process *p = XPROCESS (proc);
|
||||
struct coding_system *coding = proc_decode_coding_system[channel];
|
||||
int carryover = p->decoding_carryover;
|
||||
enum { readmax = 4096 };
|
||||
ptrdiff_t readmax = clip_to_bounds (1, read_process_output_max, PTRDIFF_MAX);
|
||||
ptrdiff_t count = SPECPDL_INDEX ();
|
||||
Lisp_Object odeactivate;
|
||||
char chars[sizeof coding->carryover + readmax];
|
||||
char *chars;
|
||||
|
||||
USE_SAFE_ALLOCA;
|
||||
chars = SAFE_ALLOCA (sizeof coding->carryover + readmax);
|
||||
|
||||
if (carryover)
|
||||
/* See the comment above. */
|
||||
|
|
@ -6092,7 +6095,7 @@ read_process_output (Lisp_Object proc, int channel)
|
|||
if (nbytes <= 0)
|
||||
{
|
||||
if (nbytes < 0 || coding->mode & CODING_MODE_LAST_BLOCK)
|
||||
return nbytes;
|
||||
return SAFE_FREE_UNBIND_TO (count, nbytes);
|
||||
coding->mode |= CODING_MODE_LAST_BLOCK;
|
||||
}
|
||||
|
||||
|
|
@ -6116,7 +6119,7 @@ read_process_output (Lisp_Object proc, int channel)
|
|||
/* Handling the process output should not deactivate the mark. */
|
||||
Vdeactivate_mark = odeactivate;
|
||||
|
||||
unbind_to (count, Qnil);
|
||||
SAFE_FREE_UNBIND_TO (count, Qnil);
|
||||
return nbytes;
|
||||
}
|
||||
|
||||
|
|
@ -8442,6 +8445,12 @@ returns non-`nil'. */);
|
|||
doc: /* Name of external socket passed to Emacs, or nil if none. */);
|
||||
Vinternal__daemon_sockname = Qnil;
|
||||
|
||||
DEFVAR_INT ("read-process-output-max", read_process_output_max,
|
||||
doc: /* Maximum number of bytes to read from subprocess in a single chunk.
|
||||
Enlarge the value only if the subprocess generates very large (megabytes)
|
||||
amounts of data in one go. */);
|
||||
read_process_output_max = 4096;
|
||||
|
||||
DEFSYM (Qinternal_default_interrupt_process,
|
||||
"internal-default-interrupt-process");
|
||||
DEFSYM (Qinterrupt_process_functions, "interrupt-process-functions");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue