310 |
|
|
311 |
static SELECT_TYPE non_process_wait_mask; |
static SELECT_TYPE non_process_wait_mask; |
312 |
|
|
313 |
|
#ifdef NON_BLOCKING_CONNECT |
314 |
/* Mask of bits indicating the descriptors that we wait for connect to |
/* Mask of bits indicating the descriptors that we wait for connect to |
315 |
complete on. Once they complete, they are removed from this mask |
complete on. Once they complete, they are removed from this mask |
316 |
and added to the input_wait_mask and non_keyboard_wait_mask. */ |
and added to the input_wait_mask and non_keyboard_wait_mask. */ |
320 |
/* Number of bits set in connect_wait_mask. */ |
/* Number of bits set in connect_wait_mask. */ |
321 |
static int num_pending_connects; |
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 |
327 |
|
|
328 |
/* The largest descriptor currently in use for a process object. */ |
/* The largest descriptor currently in use for a process object. */ |
329 |
static int max_process_desc; |
static int max_process_desc; |
330 |
|
|
3678 |
chan_process[inchannel] = Qnil; |
chan_process[inchannel] = Qnil; |
3679 |
FD_CLR (inchannel, &input_wait_mask); |
FD_CLR (inchannel, &input_wait_mask); |
3680 |
FD_CLR (inchannel, &non_keyboard_wait_mask); |
FD_CLR (inchannel, &non_keyboard_wait_mask); |
3681 |
|
#ifdef NON_BLOCKING_CONNECT |
3682 |
if (FD_ISSET (inchannel, &connect_wait_mask)) |
if (FD_ISSET (inchannel, &connect_wait_mask)) |
3683 |
{ |
{ |
3684 |
FD_CLR (inchannel, &connect_wait_mask); |
FD_CLR (inchannel, &connect_wait_mask); |
3685 |
if (--num_pending_connects < 0) |
if (--num_pending_connects < 0) |
3686 |
abort (); |
abort (); |
3687 |
} |
} |
3688 |
|
#endif |
3689 |
if (inchannel == max_process_desc) |
if (inchannel == max_process_desc) |
3690 |
{ |
{ |
3691 |
int i; |
int i; |
4046 |
{ |
{ |
4047 |
register int channel, nfds; |
register int channel, nfds; |
4048 |
SELECT_TYPE Available; |
SELECT_TYPE Available; |
4049 |
|
#ifdef NON_BLOCKING_CONNECT |
4050 |
SELECT_TYPE Connecting; |
SELECT_TYPE Connecting; |
4051 |
int check_connect, check_delay, no_avail; |
int check_connect; |
4052 |
|
#endif |
4053 |
|
int check_delay, no_avail; |
4054 |
int xerrno; |
int xerrno; |
4055 |
Lisp_Object proc; |
Lisp_Object proc; |
4056 |
EMACS_TIME timeout, end_time; |
EMACS_TIME timeout, end_time; |
4061 |
int saved_waiting_for_user_input_p = waiting_for_user_input_p; |
int saved_waiting_for_user_input_p = waiting_for_user_input_p; |
4062 |
|
|
4063 |
FD_ZERO (&Available); |
FD_ZERO (&Available); |
4064 |
|
#ifdef NON_BLOCKING_CONNECT |
4065 |
FD_ZERO (&Connecting); |
FD_ZERO (&Connecting); |
4066 |
|
#endif |
4067 |
|
|
4068 |
/* If wait_proc is a process to watch, set wait_channel accordingly. */ |
/* If wait_proc is a process to watch, set wait_channel accordingly. */ |
4069 |
if (wait_proc != NULL) |
if (wait_proc != NULL) |
4200 |
timeout to get our attention. */ |
timeout to get our attention. */ |
4201 |
if (update_tick != process_tick && do_display) |
if (update_tick != process_tick && do_display) |
4202 |
{ |
{ |
4203 |
SELECT_TYPE Atemp, Ctemp; |
SELECT_TYPE Atemp; |
4204 |
|
#ifdef NON_BLOCKING_CONNECT |
4205 |
|
SELECT_TYPE Ctemp; |
4206 |
|
#endif |
4207 |
|
|
4208 |
Atemp = input_wait_mask; |
Atemp = input_wait_mask; |
4209 |
#if 0 |
#if 0 |
4215 |
*/ |
*/ |
4216 |
FD_CLR (0, &Atemp); |
FD_CLR (0, &Atemp); |
4217 |
#endif |
#endif |
4218 |
Ctemp = connect_wait_mask; |
IF_NON_BLOCKING_CONNECT (Ctemp = connect_wait_mask); |
4219 |
|
|
4220 |
EMACS_SET_SECS_USECS (timeout, 0, 0); |
EMACS_SET_SECS_USECS (timeout, 0, 0); |
4221 |
if ((select (max (max_process_desc, max_keyboard_desc) + 1, |
if ((select (max (max_process_desc, max_keyboard_desc) + 1, |
4222 |
&Atemp, |
&Atemp, |
4223 |
|
#ifdef NON_BLOCKING_CONNECT |
4224 |
(num_pending_connects > 0 ? &Ctemp : (SELECT_TYPE *)0), |
(num_pending_connects > 0 ? &Ctemp : (SELECT_TYPE *)0), |
4225 |
|
#else |
4226 |
|
(SELECT_TYPE *)0, |
4227 |
|
#endif |
4228 |
(SELECT_TYPE *)0, &timeout) |
(SELECT_TYPE *)0, &timeout) |
4229 |
<= 0)) |
<= 0)) |
4230 |
{ |
{ |
4284 |
if (XINT (wait_proc->infd) < 0) /* Terminated */ |
if (XINT (wait_proc->infd) < 0) /* Terminated */ |
4285 |
break; |
break; |
4286 |
FD_SET (XINT (wait_proc->infd), &Available); |
FD_SET (XINT (wait_proc->infd), &Available); |
4287 |
check_connect = check_delay = 0; |
check_delay = 0; |
4288 |
|
IF_NON_BLOCKING_CONNECT (check_connect = 0); |
4289 |
} |
} |
4290 |
else if (!NILP (wait_for_cell)) |
else if (!NILP (wait_for_cell)) |
4291 |
{ |
{ |
4292 |
Available = non_process_wait_mask; |
Available = non_process_wait_mask; |
4293 |
check_connect = check_delay = 0; |
check_delay = 0; |
4294 |
|
IF_NON_BLOCKING_CONNECT (check_connect = 0); |
4295 |
} |
} |
4296 |
else |
else |
4297 |
{ |
{ |
4299 |
Available = non_keyboard_wait_mask; |
Available = non_keyboard_wait_mask; |
4300 |
else |
else |
4301 |
Available = input_wait_mask; |
Available = input_wait_mask; |
4302 |
check_connect = (num_pending_connects > 0); |
IF_NON_BLOCKING_CONNECT (check_connect = (num_pending_connects > 0)); |
4303 |
check_delay = wait_channel >= 0 ? 0 : process_output_delay_count; |
check_delay = wait_channel >= 0 ? 0 : process_output_delay_count; |
4304 |
} |
} |
4305 |
|
|
4324 |
} |
} |
4325 |
else |
else |
4326 |
{ |
{ |
4327 |
|
#ifdef NON_BLOCKING_CONNECT |
4328 |
if (check_connect) |
if (check_connect) |
4329 |
Connecting = connect_wait_mask; |
Connecting = connect_wait_mask; |
4330 |
|
#endif |
4331 |
|
|
4332 |
#ifdef ADAPTIVE_READ_BUFFERING |
#ifdef ADAPTIVE_READ_BUFFERING |
4333 |
if (process_output_skip && check_delay > 0) |
if (process_output_skip && check_delay > 0) |
4358 |
|
|
4359 |
nfds = select (max (max_process_desc, max_keyboard_desc) + 1, |
nfds = select (max (max_process_desc, max_keyboard_desc) + 1, |
4360 |
&Available, |
&Available, |
4361 |
|
#ifdef NON_BLOCKING_CONNECT |
4362 |
(check_connect ? &Connecting : (SELECT_TYPE *)0), |
(check_connect ? &Connecting : (SELECT_TYPE *)0), |
4363 |
|
#else |
4364 |
|
(SELECT_TYPE *)0, |
4365 |
|
#endif |
4366 |
(SELECT_TYPE *)0, &timeout); |
(SELECT_TYPE *)0, &timeout); |
4367 |
} |
} |
4368 |
|
|
4418 |
if (no_avail) |
if (no_avail) |
4419 |
{ |
{ |
4420 |
FD_ZERO (&Available); |
FD_ZERO (&Available); |
4421 |
check_connect = 0; |
IF_NON_BLOCKING_CONNECT (check_connect = 0); |
4422 |
} |
} |
4423 |
|
|
4424 |
#if defined(sun) && !defined(USG5_4) |
#if defined(sun) && !defined(USG5_4) |
6657 |
FD_ZERO (&non_process_wait_mask); |
FD_ZERO (&non_process_wait_mask); |
6658 |
max_process_desc = 0; |
max_process_desc = 0; |
6659 |
|
|
6660 |
|
#ifdef NON_BLOCKING_CONNECT |
6661 |
|
FD_ZERO (&connect_wait_mask); |
6662 |
|
num_pending_connects = 0; |
6663 |
|
#endif |
6664 |
|
|
6665 |
#ifdef ADAPTIVE_READ_BUFFERING |
#ifdef ADAPTIVE_READ_BUFFERING |
6666 |
process_output_delay_count = 0; |
process_output_delay_count = 0; |
6667 |
process_output_skip = 0; |
process_output_skip = 0; |