#include "charset.h"
#include "coding.h"
#include "process.h"
+#include "frame.h"
#include "termhooks.h"
#include "termopts.h"
#include "commands.h"
#include "keyboard.h"
-#include "frame.h"
#include "blockinput.h"
#include "dispextern.h"
#include "composite.h"
#define READ_OUTPUT_DELAY_MAX (READ_OUTPUT_DELAY_INCREMENT * 5)
#define READ_OUTPUT_DELAY_MAX_MAX (READ_OUTPUT_DELAY_INCREMENT * 7)
-/* Number of processes which might be delayed. */
+/* Number of processes which have a non-zero read_output_delay,
+ and therefore might be delayed for adaptive read buffering. */
static int process_output_delay_count;
-/* Non-zero if any process has non-nil process_output_skip. */
+/* Non-zero if any process has non-nil read_output_skip. */
static int process_output_skip;
/* Non-nil means to delay reading process output to improve buffering.
A value of t means that delay is reset after each send, any other
- non-nil value does not reset the delay. */
+ non-nil value does not reset the delay. A value of nil disables
+ adaptive read buffering completely. */
static Lisp_Object Vprocess_adaptive_read_buffering;
#else
#define process_output_delay_count 0
static SELECT_TYPE input_wait_mask;
-/* Mask that excludes keyboard input descriptor (s). */
+/* Mask that excludes keyboard input descriptor(s). */
static SELECT_TYPE non_keyboard_wait_mask;
-/* Mask that excludes process input descriptor (s). */
+/* Mask that excludes process input descriptor(s). */
static SELECT_TYPE non_process_wait_mask;
XPROCESS (proc)->childp = Qt;
XPROCESS (proc)->plist = Qnil;
- XPROCESS (proc)->command_channel_p = Qnil;
XPROCESS (proc)->buffer = buffer;
XPROCESS (proc)->sentinel = Qnil;
XPROCESS (proc)->filter = Qnil;
In Emacs, network connections are represented by process objects, so
input and output work as for subprocesses and `delete-process' closes
a network connection. However, a network process has no process id,
-it cannot be signalled, and the status codes are different from normal
+it cannot be signaled, and the status codes are different from normal
processes.
Arguments are specified as keyword/argument pairs. The following
#endif
#ifdef ADAPTIVE_READ_BUFFERING
+ /* Set the timeout for adaptive read buffering if any
+ process has non-nil read_output_skip and non-zero
+ read_output_delay, and we are not reading output for a
+ specific wait_channel. It is not executed if
+ Vprocess_adaptive_read_buffering is nil. */
if (process_output_skip && check_delay > 0)
{
int usecs = EMACS_USECS (timeout);
proc = chan_process[channel];
if (NILP (proc))
continue;
+ /* Find minimum non-zero read_output_delay among the
+ processes with non-nil read_output_skip. */
if (XINT (XPROCESS (proc)->read_output_delay) > 0)
{
check_delay--;
{
Lisp_Object tem;
/* Don't clobber the CURRENT match data, either! */
- tem = Fmatch_data (Qnil, Qnil);
- restore_match_data ();
- record_unwind_protect (Fset_match_data, Fmatch_data (Qnil, Qnil));
- Fset_match_data (tem);
+ tem = Fmatch_data (Qnil, Qnil, Qnil);
+ restore_search_regs ();
+ record_unwind_save_match_data ();
+ Fset_match_data (tem, Qt);
}
/* For speed, if a search happens within this code,
read_process_output_error_handler);
/* If we saved the match data nonrecursively, restore it now. */
- restore_match_data ();
+ restore_search_regs ();
running_asynch_code = outer_running_asynch_code;
/* Handling the process output should not deactivate the mark. */
int rv;
struct coding_system *coding;
struct gcpro gcpro1;
- SIGTYPE (*old_sigpipe) ();
+ SIGTYPE (*volatile old_sigpipe) ();
GCPRO1 (object);
if (outer_running_asynch_code)
{
Lisp_Object tem;
- tem = Fmatch_data (Qnil, Qnil);
- restore_match_data ();
- record_unwind_protect (Fset_match_data, Fmatch_data (Qnil, Qnil));
- Fset_match_data (tem);
+ tem = Fmatch_data (Qnil, Qnil, Qnil);
+ restore_search_regs ();
+ record_unwind_save_match_data ();
+ Fset_match_data (tem, Qt);
}
/* For speed, if a search happens within this code,
exec_sentinel_error_handler);
/* If we saved the match data nonrecursively, restore it now. */
- restore_match_data ();
+ restore_search_regs ();
running_asynch_code = outer_running_asynch_code;
Vdeactivate_mark = odeactivate;
\f
-/* The first time this is called, assume keyboard input comes from DESC
- instead of from where we used to expect it.
- Subsequent calls mean assume input keyboard can come from DESC
- in addition to other places. */
-
-static int add_keyboard_wait_descriptor_called_flag;
+/* Add DESC to the set of keyboard input descriptors. */
void
add_keyboard_wait_descriptor (desc)
int desc;
{
- if (! add_keyboard_wait_descriptor_called_flag)
- FD_CLR (0, &input_wait_mask);
- add_keyboard_wait_descriptor_called_flag = 1;
FD_SET (desc, &input_wait_mask);
FD_SET (desc, &non_process_wait_mask);
if (desc > max_keyboard_desc)
process_output_skip = 0;
#endif
+ /* Don't do this, it caused infinite select loops. The display
+ method should call add_keyboard_wait_descriptor on stdin if it
+ needs that. */
+#if 0
FD_SET (0, &input_wait_mask);
+#endif
Vprocess_alist = Qnil;
for (i = 0; i < MAXDESC; i++)
#endif /* HAVE_SOCKETS */
#if defined (DARWIN) || defined (MAC_OSX)
- /* PTYs are broken on Darwin < 6, but are sometimes useful for interactive
+ /* PTYs are broken on Darwin < 6, but are sometimes useful for interactive
processes. As such, we only change the default value. */
if (initialized)
{
doc: /* If non-nil, improve receive buffering by delaying after short reads.
On some systems, when Emacs reads the output from a subprocess, the output data
is read in very small blocks, potentially resulting in very poor performance.
-This behaviour can be remedied to some extent by setting this variable to a
+This behavior can be remedied to some extent by setting this variable to a
non-nil value, as it will automatically delay reading from such processes, to
allowing them to produce more output before Emacs tries to read it.
If the value is t, the delay is reset after each write to the process; any other