comparison src/process.c @ 90043:e24e2e78deda

Revision: miles@gnu.org--gnu-2004/emacs--unicode--0--patch-69 Merge from emacs--cvs-trunk--0 Patches applied: * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-643 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-649 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-650 Merge from gnus--rel--5.10 * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-651 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-655 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-656 Update from CVS: lisp/man.el (Man-xref-normal-file): Fix help-echo. * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-657 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-658 Merge from gnus--rel--5.10 * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-659 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-660 Merge from gnus--rel--5.10 * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-661 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-667 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668 Merge from gnus--rel--5.10 * miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-61 - miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-68 Update from CVS
author Miles Bader <miles@gnu.org>
date Thu, 04 Nov 2004 08:55:40 +0000
parents d8411455de48 8abbe69dfdb2
children cb7f41387eb3
comparison
equal deleted inserted replaced
90042:003d95404d71 90043:e24e2e78deda
308 308
309 /* Mask that excludes process input descriptor (s). */ 309 /* Mask that excludes process input descriptor (s). */
310 310
311 static SELECT_TYPE non_process_wait_mask; 311 static SELECT_TYPE non_process_wait_mask;
312 312
313 #ifdef NON_BLOCKING_CONNECT
313 /* Mask of bits indicating the descriptors that we wait for connect to 314 /* Mask of bits indicating the descriptors that we wait for connect to
314 complete on. Once they complete, they are removed from this mask 315 complete on. Once they complete, they are removed from this mask
315 and added to the input_wait_mask and non_keyboard_wait_mask. */ 316 and added to the input_wait_mask and non_keyboard_wait_mask. */
316 317
317 static SELECT_TYPE connect_wait_mask; 318 static SELECT_TYPE connect_wait_mask;
318 319
319 /* Number of bits set in connect_wait_mask. */ 320 /* Number of bits set in connect_wait_mask. */
320 static int num_pending_connects; 321 static int num_pending_connects;
322
323 #define IF_NON_BLOCKING_CONNECT(s) s
324 #else
325 #define IF_NON_BLOCKING_CONNECT(s)
326 #endif
321 327
322 /* The largest descriptor currently in use for a process object. */ 328 /* The largest descriptor currently in use for a process object. */
323 static int max_process_desc; 329 static int max_process_desc;
324 330
325 /* The largest descriptor currently in use for keyboard input. */ 331 /* The largest descriptor currently in use for keyboard input. */
3671 } 3677 }
3672 #endif 3678 #endif
3673 chan_process[inchannel] = Qnil; 3679 chan_process[inchannel] = Qnil;
3674 FD_CLR (inchannel, &input_wait_mask); 3680 FD_CLR (inchannel, &input_wait_mask);
3675 FD_CLR (inchannel, &non_keyboard_wait_mask); 3681 FD_CLR (inchannel, &non_keyboard_wait_mask);
3682 #ifdef NON_BLOCKING_CONNECT
3676 if (FD_ISSET (inchannel, &connect_wait_mask)) 3683 if (FD_ISSET (inchannel, &connect_wait_mask))
3677 { 3684 {
3678 FD_CLR (inchannel, &connect_wait_mask); 3685 FD_CLR (inchannel, &connect_wait_mask);
3679 if (--num_pending_connects < 0) 3686 if (--num_pending_connects < 0)
3680 abort (); 3687 abort ();
3681 } 3688 }
3689 #endif
3682 if (inchannel == max_process_desc) 3690 if (inchannel == max_process_desc)
3683 { 3691 {
3684 int i; 3692 int i;
3685 /* We just closed the highest-numbered process input descriptor, 3693 /* We just closed the highest-numbered process input descriptor,
3686 so recompute the highest-numbered one now. */ 3694 so recompute the highest-numbered one now. */
4037 struct Lisp_Process *wait_proc; 4045 struct Lisp_Process *wait_proc;
4038 int just_wait_proc; 4046 int just_wait_proc;
4039 { 4047 {
4040 register int channel, nfds; 4048 register int channel, nfds;
4041 SELECT_TYPE Available; 4049 SELECT_TYPE Available;
4050 #ifdef NON_BLOCKING_CONNECT
4042 SELECT_TYPE Connecting; 4051 SELECT_TYPE Connecting;
4043 int check_connect, check_delay, no_avail; 4052 int check_connect;
4053 #endif
4054 int check_delay, no_avail;
4044 int xerrno; 4055 int xerrno;
4045 Lisp_Object proc; 4056 Lisp_Object proc;
4046 EMACS_TIME timeout, end_time; 4057 EMACS_TIME timeout, end_time;
4047 int wait_channel = -1; 4058 int wait_channel = -1;
4048 int got_some_input = 0; 4059 int got_some_input = 0;
4049 /* Either nil or a cons cell, the car of which is of interest and 4060 /* Either nil or a cons cell, the car of which is of interest and
4050 may be changed outside of this routine. */ 4061 may be changed outside of this routine. */
4051 int saved_waiting_for_user_input_p = waiting_for_user_input_p; 4062 int saved_waiting_for_user_input_p = waiting_for_user_input_p;
4052 4063
4053 FD_ZERO (&Available); 4064 FD_ZERO (&Available);
4065 #ifdef NON_BLOCKING_CONNECT
4054 FD_ZERO (&Connecting); 4066 FD_ZERO (&Connecting);
4067 #endif
4055 4068
4056 /* If wait_proc is a process to watch, set wait_channel accordingly. */ 4069 /* If wait_proc is a process to watch, set wait_channel accordingly. */
4057 if (wait_proc != NULL) 4070 if (wait_proc != NULL)
4058 wait_channel = XINT (wait_proc->infd); 4071 wait_channel = XINT (wait_proc->infd);
4059 4072
4186 available, notify the user of the change right away. After 4199 available, notify the user of the change right away. After
4187 this explicit check, we'll let the SIGCHLD handler zap 4200 this explicit check, we'll let the SIGCHLD handler zap
4188 timeout to get our attention. */ 4201 timeout to get our attention. */
4189 if (update_tick != process_tick && do_display) 4202 if (update_tick != process_tick && do_display)
4190 { 4203 {
4191 SELECT_TYPE Atemp, Ctemp; 4204 SELECT_TYPE Atemp;
4205 #ifdef NON_BLOCKING_CONNECT
4206 SELECT_TYPE Ctemp;
4207 #endif
4192 4208
4193 Atemp = input_wait_mask; 4209 Atemp = input_wait_mask;
4194 #if 0 4210 #if 0
4195 /* On Mac OS X 10.0, the SELECT system call always says input is 4211 /* On Mac OS X 10.0, the SELECT system call always says input is
4196 present (for reading) at stdin, even when none is. This 4212 present (for reading) at stdin, even when none is. This
4198 status_notify not to be called. As a result output of 4214 status_notify not to be called. As a result output of
4199 subprocesses are incorrectly discarded. 4215 subprocesses are incorrectly discarded.
4200 */ 4216 */
4201 FD_CLR (0, &Atemp); 4217 FD_CLR (0, &Atemp);
4202 #endif 4218 #endif
4203 Ctemp = connect_wait_mask; 4219 IF_NON_BLOCKING_CONNECT (Ctemp = connect_wait_mask);
4220
4204 EMACS_SET_SECS_USECS (timeout, 0, 0); 4221 EMACS_SET_SECS_USECS (timeout, 0, 0);
4205 if ((select (max (max_process_desc, max_keyboard_desc) + 1, 4222 if ((select (max (max_process_desc, max_keyboard_desc) + 1,
4206 &Atemp, 4223 &Atemp,
4224 #ifdef NON_BLOCKING_CONNECT
4207 (num_pending_connects > 0 ? &Ctemp : (SELECT_TYPE *)0), 4225 (num_pending_connects > 0 ? &Ctemp : (SELECT_TYPE *)0),
4226 #else
4227 (SELECT_TYPE *)0,
4228 #endif
4208 (SELECT_TYPE *)0, &timeout) 4229 (SELECT_TYPE *)0, &timeout)
4209 <= 0)) 4230 <= 0))
4210 { 4231 {
4211 /* It's okay for us to do this and then continue with 4232 /* It's okay for us to do this and then continue with
4212 the loop, since timeout has already been zeroed out. */ 4233 the loop, since timeout has already been zeroed out. */
4262 if (wait_proc && just_wait_proc) 4283 if (wait_proc && just_wait_proc)
4263 { 4284 {
4264 if (XINT (wait_proc->infd) < 0) /* Terminated */ 4285 if (XINT (wait_proc->infd) < 0) /* Terminated */
4265 break; 4286 break;
4266 FD_SET (XINT (wait_proc->infd), &Available); 4287 FD_SET (XINT (wait_proc->infd), &Available);
4267 check_connect = check_delay = 0; 4288 check_delay = 0;
4289 IF_NON_BLOCKING_CONNECT (check_connect = 0);
4268 } 4290 }
4269 else if (!NILP (wait_for_cell)) 4291 else if (!NILP (wait_for_cell))
4270 { 4292 {
4271 Available = non_process_wait_mask; 4293 Available = non_process_wait_mask;
4272 check_connect = check_delay = 0; 4294 check_delay = 0;
4295 IF_NON_BLOCKING_CONNECT (check_connect = 0);
4273 } 4296 }
4274 else 4297 else
4275 { 4298 {
4276 if (! read_kbd) 4299 if (! read_kbd)
4277 Available = non_keyboard_wait_mask; 4300 Available = non_keyboard_wait_mask;
4278 else 4301 else
4279 Available = input_wait_mask; 4302 Available = input_wait_mask;
4280 check_connect = (num_pending_connects > 0); 4303 IF_NON_BLOCKING_CONNECT (check_connect = (num_pending_connects > 0));
4281 check_delay = wait_channel >= 0 ? 0 : process_output_delay_count; 4304 check_delay = wait_channel >= 0 ? 0 : process_output_delay_count;
4282 } 4305 }
4283 4306
4284 /* If frame size has changed or the window is newly mapped, 4307 /* If frame size has changed or the window is newly mapped,
4285 redisplay now, before we start to wait. There is a race 4308 redisplay now, before we start to wait. There is a race
4300 nfds = 0; 4323 nfds = 0;
4301 no_avail = 1; 4324 no_avail = 1;
4302 } 4325 }
4303 else 4326 else
4304 { 4327 {
4328 #ifdef NON_BLOCKING_CONNECT
4305 if (check_connect) 4329 if (check_connect)
4306 Connecting = connect_wait_mask; 4330 Connecting = connect_wait_mask;
4331 #endif
4307 4332
4308 #ifdef ADAPTIVE_READ_BUFFERING 4333 #ifdef ADAPTIVE_READ_BUFFERING
4309 if (process_output_skip && check_delay > 0) 4334 if (process_output_skip && check_delay > 0)
4310 { 4335 {
4311 int usecs = EMACS_USECS (timeout); 4336 int usecs = EMACS_USECS (timeout);
4332 } 4357 }
4333 #endif 4358 #endif
4334 4359
4335 nfds = select (max (max_process_desc, max_keyboard_desc) + 1, 4360 nfds = select (max (max_process_desc, max_keyboard_desc) + 1,
4336 &Available, 4361 &Available,
4362 #ifdef NON_BLOCKING_CONNECT
4337 (check_connect ? &Connecting : (SELECT_TYPE *)0), 4363 (check_connect ? &Connecting : (SELECT_TYPE *)0),
4364 #else
4365 (SELECT_TYPE *)0,
4366 #endif
4338 (SELECT_TYPE *)0, &timeout); 4367 (SELECT_TYPE *)0, &timeout);
4339 } 4368 }
4340 4369
4341 xerrno = errno; 4370 xerrno = errno;
4342 4371
4388 } 4417 }
4389 4418
4390 if (no_avail) 4419 if (no_avail)
4391 { 4420 {
4392 FD_ZERO (&Available); 4421 FD_ZERO (&Available);
4393 check_connect = 0; 4422 IF_NON_BLOCKING_CONNECT (check_connect = 0);
4394 } 4423 }
4395 4424
4396 #if defined(sun) && !defined(USG5_4) 4425 #if defined(sun) && !defined(USG5_4)
4397 if (nfds > 0 && keyboard_bit_set (&Available) 4426 if (nfds > 0 && keyboard_bit_set (&Available)
4398 && interrupt_input) 4427 && interrupt_input)
6623 6652
6624 FD_ZERO (&input_wait_mask); 6653 FD_ZERO (&input_wait_mask);
6625 FD_ZERO (&non_keyboard_wait_mask); 6654 FD_ZERO (&non_keyboard_wait_mask);
6626 FD_ZERO (&non_process_wait_mask); 6655 FD_ZERO (&non_process_wait_mask);
6627 max_process_desc = 0; 6656 max_process_desc = 0;
6657
6658 #ifdef NON_BLOCKING_CONNECT
6659 FD_ZERO (&connect_wait_mask);
6660 num_pending_connects = 0;
6661 #endif
6628 6662
6629 #ifdef ADAPTIVE_READ_BUFFERING 6663 #ifdef ADAPTIVE_READ_BUFFERING
6630 process_output_delay_count = 0; 6664 process_output_delay_count = 0;
6631 process_output_skip = 0; 6665 process_output_skip = 0;
6632 #endif 6666 #endif