diff options
Diffstat (limited to 'src/process.c')
| -rw-r--r-- | src/process.c | 48 |
1 files changed, 41 insertions, 7 deletions
diff --git a/src/process.c b/src/process.c index 688f97dc199..76967cd7ac2 100644 --- a/src/process.c +++ b/src/process.c | |||
| @@ -310,6 +310,7 @@ static SELECT_TYPE non_keyboard_wait_mask; | |||
| 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. */ |
| @@ -319,6 +320,11 @@ static SELECT_TYPE connect_wait_mask; | |||
| 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; |
| 321 | 322 | ||
| 323 | #define IF_NON_BLOCKING_CONNECT(s) s | ||
| 324 | #else | ||
| 325 | #define IF_NON_BLOCKING_CONNECT(s) | ||
| 326 | #endif | ||
| 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 | ||
| @@ -3673,12 +3679,14 @@ deactivate_process (proc) | |||
| 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; |
| @@ -4039,8 +4047,11 @@ wait_reading_process_output (time_limit, microsecs, read_kbd, do_display, | |||
| 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; |
| @@ -4051,7 +4062,9 @@ wait_reading_process_output (time_limit, microsecs, read_kbd, do_display, | |||
| 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) |
| @@ -4188,7 +4201,10 @@ wait_reading_process_output (time_limit, microsecs, read_kbd, do_display, | |||
| 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 |
| @@ -4200,11 +4216,16 @@ wait_reading_process_output (time_limit, microsecs, read_kbd, do_display, | |||
| 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 | { |
| @@ -4264,12 +4285,14 @@ wait_reading_process_output (time_limit, microsecs, read_kbd, do_display, | |||
| 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 | { |
| @@ -4277,7 +4300,7 @@ wait_reading_process_output (time_limit, microsecs, read_kbd, do_display, | |||
| 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 | ||
| @@ -4302,8 +4325,10 @@ wait_reading_process_output (time_limit, microsecs, read_kbd, do_display, | |||
| 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) |
| @@ -4334,7 +4359,11 @@ wait_reading_process_output (time_limit, microsecs, read_kbd, do_display, | |||
| 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 | ||
| @@ -4390,7 +4419,7 @@ wait_reading_process_output (time_limit, microsecs, read_kbd, do_display, | |||
| 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) |
| @@ -6626,6 +6655,11 @@ init_process () | |||
| 6626 | FD_ZERO (&non_process_wait_mask); | 6655 | FD_ZERO (&non_process_wait_mask); |
| 6627 | max_process_desc = 0; | 6656 | max_process_desc = 0; |
| 6628 | 6657 | ||
| 6658 | #ifdef NON_BLOCKING_CONNECT | ||
| 6659 | FD_ZERO (&connect_wait_mask); | ||
| 6660 | num_pending_connects = 0; | ||
| 6661 | #endif | ||
| 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; |