aboutsummaryrefslogtreecommitdiffstats
path: root/src/process.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/process.c')
-rw-r--r--src/process.c40
1 files changed, 24 insertions, 16 deletions
diff --git a/src/process.c b/src/process.c
index 41e46c53dc9..dd13138e273 100644
--- a/src/process.c
+++ b/src/process.c
@@ -272,17 +272,19 @@ int update_tick;
272#define READ_OUTPUT_DELAY_MAX (READ_OUTPUT_DELAY_INCREMENT * 5) 272#define READ_OUTPUT_DELAY_MAX (READ_OUTPUT_DELAY_INCREMENT * 5)
273#define READ_OUTPUT_DELAY_MAX_MAX (READ_OUTPUT_DELAY_INCREMENT * 7) 273#define READ_OUTPUT_DELAY_MAX_MAX (READ_OUTPUT_DELAY_INCREMENT * 7)
274 274
275/* Number of processes which might be delayed. */ 275/* Number of processes which have a non-zero read_output_delay,
276 and therefore might be delayed for adaptive read buffering. */
276 277
277static int process_output_delay_count; 278static int process_output_delay_count;
278 279
279/* Non-zero if any process has non-nil process_output_skip. */ 280/* Non-zero if any process has non-nil read_output_skip. */
280 281
281static int process_output_skip; 282static int process_output_skip;
282 283
283/* Non-nil means to delay reading process output to improve buffering. 284/* Non-nil means to delay reading process output to improve buffering.
284 A value of t means that delay is reset after each send, any other 285 A value of t means that delay is reset after each send, any other
285 non-nil value does not reset the delay. */ 286 non-nil value does not reset the delay. A value of nil disables
287 adaptive read buffering completely. */
286static Lisp_Object Vprocess_adaptive_read_buffering; 288static Lisp_Object Vprocess_adaptive_read_buffering;
287#else 289#else
288#define process_output_delay_count 0 290#define process_output_delay_count 0
@@ -1535,7 +1537,6 @@ usage: (start-process NAME BUFFER PROGRAM &rest PROGRAM-ARGS) */)
1535 1537
1536 XPROCESS (proc)->childp = Qt; 1538 XPROCESS (proc)->childp = Qt;
1537 XPROCESS (proc)->plist = Qnil; 1539 XPROCESS (proc)->plist = Qnil;
1538 XPROCESS (proc)->command_channel_p = Qnil;
1539 XPROCESS (proc)->buffer = buffer; 1540 XPROCESS (proc)->buffer = buffer;
1540 XPROCESS (proc)->sentinel = Qnil; 1541 XPROCESS (proc)->sentinel = Qnil;
1541 XPROCESS (proc)->filter = Qnil; 1542 XPROCESS (proc)->filter = Qnil;
@@ -4319,6 +4320,11 @@ wait_reading_process_output (time_limit, microsecs, read_kbd, do_display,
4319#endif 4320#endif
4320 4321
4321#ifdef ADAPTIVE_READ_BUFFERING 4322#ifdef ADAPTIVE_READ_BUFFERING
4323 /* Set the timeout for adaptive read buffering if any
4324 process has non-nil read_output_skip and non-zero
4325 read_output_delay, and we are not reading output for a
4326 specific wait_channel. It is not executed if
4327 Vprocess_adaptive_read_buffering is nil. */
4322 if (process_output_skip && check_delay > 0) 4328 if (process_output_skip && check_delay > 0)
4323 { 4329 {
4324 int usecs = EMACS_USECS (timeout); 4330 int usecs = EMACS_USECS (timeout);
@@ -4329,6 +4335,8 @@ wait_reading_process_output (time_limit, microsecs, read_kbd, do_display,
4329 proc = chan_process[channel]; 4335 proc = chan_process[channel];
4330 if (NILP (proc)) 4336 if (NILP (proc))
4331 continue; 4337 continue;
4338 /* Find minimum non-zero read_output_delay among the
4339 processes with non-nil read_output_skip. */
4332 if (XINT (XPROCESS (proc)->read_output_delay) > 0) 4340 if (XINT (XPROCESS (proc)->read_output_delay) > 0)
4333 { 4341 {
4334 check_delay--; 4342 check_delay--;
@@ -4879,10 +4887,10 @@ read_process_output (proc, channel)
4879 { 4887 {
4880 Lisp_Object tem; 4888 Lisp_Object tem;
4881 /* Don't clobber the CURRENT match data, either! */ 4889 /* Don't clobber the CURRENT match data, either! */
4882 tem = Fmatch_data (Qnil, Qnil); 4890 tem = Fmatch_data (Qnil, Qnil, Qnil);
4883 restore_match_data (); 4891 restore_search_regs ();
4884 record_unwind_protect (Fset_match_data, Fmatch_data (Qnil, Qnil)); 4892 record_unwind_save_match_data ();
4885 Fset_match_data (tem); 4893 Fset_match_data (tem, Qt);
4886 } 4894 }
4887 4895
4888 /* For speed, if a search happens within this code, 4896 /* For speed, if a search happens within this code,
@@ -4936,7 +4944,7 @@ read_process_output (proc, channel)
4936 read_process_output_error_handler); 4944 read_process_output_error_handler);
4937 4945
4938 /* If we saved the match data nonrecursively, restore it now. */ 4946 /* If we saved the match data nonrecursively, restore it now. */
4939 restore_match_data (); 4947 restore_search_regs ();
4940 running_asynch_code = outer_running_asynch_code; 4948 running_asynch_code = outer_running_asynch_code;
4941 4949
4942 /* Handling the process output should not deactivate the mark. */ 4950 /* Handling the process output should not deactivate the mark. */
@@ -6340,10 +6348,10 @@ exec_sentinel (proc, reason)
6340 if (outer_running_asynch_code) 6348 if (outer_running_asynch_code)
6341 { 6349 {
6342 Lisp_Object tem; 6350 Lisp_Object tem;
6343 tem = Fmatch_data (Qnil, Qnil); 6351 tem = Fmatch_data (Qnil, Qnil, Qnil);
6344 restore_match_data (); 6352 restore_search_regs ();
6345 record_unwind_protect (Fset_match_data, Fmatch_data (Qnil, Qnil)); 6353 record_unwind_save_match_data ();
6346 Fset_match_data (tem); 6354 Fset_match_data (tem, Qt);
6347 } 6355 }
6348 6356
6349 /* For speed, if a search happens within this code, 6357 /* For speed, if a search happens within this code,
@@ -6357,7 +6365,7 @@ exec_sentinel (proc, reason)
6357 exec_sentinel_error_handler); 6365 exec_sentinel_error_handler);
6358 6366
6359 /* If we saved the match data nonrecursively, restore it now. */ 6367 /* If we saved the match data nonrecursively, restore it now. */
6360 restore_match_data (); 6368 restore_search_regs ();
6361 running_asynch_code = outer_running_asynch_code; 6369 running_asynch_code = outer_running_asynch_code;
6362 6370
6363 Vdeactivate_mark = odeactivate; 6371 Vdeactivate_mark = odeactivate;
@@ -6708,7 +6716,7 @@ init_process ()
6708#endif /* HAVE_SOCKETS */ 6716#endif /* HAVE_SOCKETS */
6709 6717
6710#if defined (DARWIN) || defined (MAC_OSX) 6718#if defined (DARWIN) || defined (MAC_OSX)
6711 /* PTYs are broken on Darwin < 6, but are sometimes useful for interactive 6719 /* PTYs are broken on Darwin < 6, but are sometimes useful for interactive
6712 processes. As such, we only change the default value. */ 6720 processes. As such, we only change the default value. */
6713 if (initialized) 6721 if (initialized)
6714 { 6722 {
@@ -6813,7 +6821,7 @@ The value takes effect when `start-process' is called. */);
6813 doc: /* If non-nil, improve receive buffering by delaying after short reads. 6821 doc: /* If non-nil, improve receive buffering by delaying after short reads.
6814On some systems, when Emacs reads the output from a subprocess, the output data 6822On some systems, when Emacs reads the output from a subprocess, the output data
6815is read in very small blocks, potentially resulting in very poor performance. 6823is read in very small blocks, potentially resulting in very poor performance.
6816This behaviour can be remedied to some extent by setting this variable to a 6824This behavior can be remedied to some extent by setting this variable to a
6817non-nil value, as it will automatically delay reading from such processes, to 6825non-nil value, as it will automatically delay reading from such processes, to
6818allowing them to produce more output before Emacs tries to read it. 6826allowing them to produce more output before Emacs tries to read it.
6819If the value is t, the delay is reset after each write to the process; any other 6827If the value is t, the delay is reset after each write to the process; any other