Commit 82eaa333 authored by Paul Eggert's avatar Paul Eggert
Browse files

* process.c (read_process_output): Do adaptive read buffering even if carryover.

parent bc57d757
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
(exec_sentinel): Remove vars that were set but not used. (exec_sentinel): Remove vars that were set but not used.
(create_pty): Remove unnecessary "volatile"s. (create_pty): Remove unnecessary "volatile"s.
(Fnetwork_interface_info): Avoid possibility of int overflow. (Fnetwork_interface_info): Avoid possibility of int overflow.
(read_process_output): Do adaptive read buffering even if carryover.
   
* bytecode.c (exec_byte_code): Rename local to avoid shadowing. * bytecode.c (exec_byte_code): Rename local to avoid shadowing.
   
...@@ -5162,15 +5162,22 @@ read_process_output (Lisp_Object proc, register int channel) ...@@ -5162,15 +5162,22 @@ read_process_output (Lisp_Object proc, register int channel)
} }
else else
#endif #endif
if (proc_buffered_char[channel] < 0)
{ {
int buffered = 0 <= proc_buffered_char[channel];
if (buffered)
{
chars[carryover] = proc_buffered_char[channel];
proc_buffered_char[channel] = -1;
}
#ifdef HAVE_GNUTLS #ifdef HAVE_GNUTLS
if (XPROCESS (proc)->gnutls_p) if (XPROCESS (proc)->gnutls_p)
nbytes = emacs_gnutls_read (channel, XPROCESS (proc), nbytes = emacs_gnutls_read (channel, XPROCESS (proc),
chars + carryover, readmax); chars + carryover + buffered,
readmax - buffered);
else else
#endif #endif
nbytes = emacs_read (channel, chars + carryover, readmax); nbytes = emacs_read (channel, chars + carryover + buffered,
readmax - buffered);
#ifdef ADAPTIVE_READ_BUFFERING #ifdef ADAPTIVE_READ_BUFFERING
if (nbytes > 0 && p->adaptive_read_buffering) if (nbytes > 0 && p->adaptive_read_buffering)
{ {
...@@ -5184,7 +5191,7 @@ read_process_output (Lisp_Object proc, register int channel) ...@@ -5184,7 +5191,7 @@ read_process_output (Lisp_Object proc, register int channel)
delay += READ_OUTPUT_DELAY_INCREMENT * 2; delay += READ_OUTPUT_DELAY_INCREMENT * 2;
} }
} }
else if (delay > 0 && (nbytes == readmax)) else if (delay > 0 && nbytes == readmax - buffered)
{ {
delay -= READ_OUTPUT_DELAY_INCREMENT; delay -= READ_OUTPUT_DELAY_INCREMENT;
if (delay == 0) if (delay == 0)
...@@ -5198,22 +5205,13 @@ read_process_output (Lisp_Object proc, register int channel) ...@@ -5198,22 +5205,13 @@ read_process_output (Lisp_Object proc, register int channel)
} }
} }
#endif #endif
} if (buffered)
else {
{ if (nbytes < 0)
chars[carryover] = proc_buffered_char[channel]; nbytes = 1;
proc_buffered_char[channel] = -1; else
#ifdef HAVE_GNUTLS nbytes = nbytes + 1;
if (XPROCESS (proc)->gnutls_p) }
nbytes = emacs_gnutls_read (channel, XPROCESS (proc),
chars + carryover + 1, readmax - 1);
else
#endif
nbytes = emacs_read (channel, chars + carryover + 1, readmax - 1);
if (nbytes < 0)
nbytes = 1;
else
nbytes = nbytes + 1;
} }
p->decoding_carryover = 0; p->decoding_carryover = 0;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment