diff options
| author | Eli Zaretskii | 2016-12-07 21:01:40 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2016-12-07 21:01:40 +0200 |
| commit | fa7d1f075fb862ae4ca28390abf33d625dbd2813 (patch) | |
| tree | 68c81214177fc82c3834216cb309d334e7253224 /src/process.c | |
| parent | 16ac7c0fc91b5eb09f2a129fc2c01281369f897a (diff) | |
| download | emacs-fa7d1f075fb862ae4ca28390abf33d625dbd2813.tar.gz emacs-fa7d1f075fb862ae4ca28390abf33d625dbd2813.zip | |
Fix network streams.
The original code messed up flags in fd_callback_data[], and also
didn't call add_process_read_fd for process-related file descriptors.
Diffstat (limited to 'src/process.c')
| -rw-r--r-- | src/process.c | 41 |
1 files changed, 24 insertions, 17 deletions
diff --git a/src/process.c b/src/process.c index e800bf278bc..7d3cf19d57f 100644 --- a/src/process.c +++ b/src/process.c | |||
| @@ -454,6 +454,8 @@ add_non_keyboard_read_fd (int fd) | |||
| 454 | { | 454 | { |
| 455 | eassert (fd >= 0 && fd < FD_SETSIZE); | 455 | eassert (fd >= 0 && fd < FD_SETSIZE); |
| 456 | eassert (fd_callback_info[fd].func == NULL); | 456 | eassert (fd_callback_info[fd].func == NULL); |
| 457 | |||
| 458 | fd_callback_info[fd].flags &= ~KEYBOARD_FD; | ||
| 457 | fd_callback_info[fd].flags |= FOR_READ; | 459 | fd_callback_info[fd].flags |= FOR_READ; |
| 458 | if (fd > max_desc) | 460 | if (fd > max_desc) |
| 459 | max_desc = fd; | 461 | max_desc = fd; |
| @@ -486,12 +488,13 @@ delete_read_fd (int fd) | |||
| 486 | void | 488 | void |
| 487 | add_write_fd (int fd, fd_callback func, void *data) | 489 | add_write_fd (int fd, fd_callback func, void *data) |
| 488 | { | 490 | { |
| 489 | if (fd > max_desc) | 491 | eassert (fd >= 0 && fd < FD_SETSIZE); |
| 490 | max_desc = fd; | ||
| 491 | 492 | ||
| 492 | fd_callback_info[fd].func = func; | 493 | fd_callback_info[fd].func = func; |
| 493 | fd_callback_info[fd].data = data; | 494 | fd_callback_info[fd].data = data; |
| 494 | fd_callback_info[fd].flags |= FOR_WRITE; | 495 | fd_callback_info[fd].flags |= FOR_WRITE; |
| 496 | if (fd > max_desc) | ||
| 497 | max_desc = fd; | ||
| 495 | } | 498 | } |
| 496 | 499 | ||
| 497 | static void | 500 | static void |
| @@ -915,7 +918,7 @@ update_processes_for_thread_death (Lisp_Object dying_thread) | |||
| 915 | { | 918 | { |
| 916 | struct Lisp_Process *proc = XPROCESS (process); | 919 | struct Lisp_Process *proc = XPROCESS (process); |
| 917 | 920 | ||
| 918 | proc->thread = Qnil; | 921 | pset_thread (proc, Qnil); |
| 919 | if (proc->infd >= 0) | 922 | if (proc->infd >= 0) |
| 920 | fd_callback_info[proc->infd].thread = NULL; | 923 | fd_callback_info[proc->infd].thread = NULL; |
| 921 | if (proc->outfd >= 0) | 924 | if (proc->outfd >= 0) |
| @@ -1230,7 +1233,7 @@ set_process_filter_masks (struct Lisp_Process *p) | |||
| 1230 | else if (EQ (p->filter, Qt) | 1233 | else if (EQ (p->filter, Qt) |
| 1231 | /* Network or serial process not stopped: */ | 1234 | /* Network or serial process not stopped: */ |
| 1232 | && !EQ (p->command, Qt)) | 1235 | && !EQ (p->command, Qt)) |
| 1233 | add_non_keyboard_read_fd (p->infd); | 1236 | add_process_read_fd (p->infd); |
| 1234 | } | 1237 | } |
| 1235 | 1238 | ||
| 1236 | DEFUN ("set-process-filter", Fset_process_filter, Sset_process_filter, | 1239 | DEFUN ("set-process-filter", Fset_process_filter, Sset_process_filter, |
| @@ -1336,7 +1339,7 @@ If THREAD is nil, the process is unlocked. */) | |||
| 1336 | } | 1339 | } |
| 1337 | 1340 | ||
| 1338 | proc = XPROCESS (process); | 1341 | proc = XPROCESS (process); |
| 1339 | proc->thread = thread; | 1342 | pset_thread (proc, thread); |
| 1340 | if (proc->infd >= 0) | 1343 | if (proc->infd >= 0) |
| 1341 | fd_callback_info[proc->infd].thread = tstate; | 1344 | fd_callback_info[proc->infd].thread = tstate; |
| 1342 | if (proc->outfd >= 0) | 1345 | if (proc->outfd >= 0) |
| @@ -2031,7 +2034,8 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir) | |||
| 2031 | p->pty_flag = pty_flag; | 2034 | p->pty_flag = pty_flag; |
| 2032 | pset_status (p, Qrun); | 2035 | pset_status (p, Qrun); |
| 2033 | 2036 | ||
| 2034 | add_process_read_fd (inchannel); | 2037 | if (!EQ (p->command, Qt)) |
| 2038 | add_process_read_fd (inchannel); | ||
| 2035 | 2039 | ||
| 2036 | /* This may signal an error. */ | 2040 | /* This may signal an error. */ |
| 2037 | setup_process_coding_systems (process); | 2041 | setup_process_coding_systems (process); |
| @@ -2265,7 +2269,7 @@ create_pty (Lisp_Object process) | |||
| 2265 | pset_status (p, Qrun); | 2269 | pset_status (p, Qrun); |
| 2266 | setup_process_coding_systems (process); | 2270 | setup_process_coding_systems (process); |
| 2267 | 2271 | ||
| 2268 | add_non_keyboard_read_fd (pty_fd); | 2272 | add_process_read_fd (pty_fd); |
| 2269 | 2273 | ||
| 2270 | pset_tty_name (p, build_string (pty_name)); | 2274 | pset_tty_name (p, build_string (pty_name)); |
| 2271 | } | 2275 | } |
| @@ -2371,7 +2375,7 @@ usage: (make-pipe-process &rest ARGS) */) | |||
| 2371 | eassert (! p->pty_flag); | 2375 | eassert (! p->pty_flag); |
| 2372 | 2376 | ||
| 2373 | if (!EQ (p->command, Qt)) | 2377 | if (!EQ (p->command, Qt)) |
| 2374 | add_non_keyboard_read_fd (inchannel); | 2378 | add_process_read_fd (inchannel); |
| 2375 | p->adaptive_read_buffering | 2379 | p->adaptive_read_buffering |
| 2376 | = (NILP (Vprocess_adaptive_read_buffering) ? 0 | 2380 | = (NILP (Vprocess_adaptive_read_buffering) ? 0 |
| 2377 | : EQ (Vprocess_adaptive_read_buffering, Qt) ? 1 : 2); | 2381 | : EQ (Vprocess_adaptive_read_buffering, Qt) ? 1 : 2); |
| @@ -3107,7 +3111,7 @@ usage: (make-serial-process &rest ARGS) */) | |||
| 3107 | eassert (! p->pty_flag); | 3111 | eassert (! p->pty_flag); |
| 3108 | 3112 | ||
| 3109 | if (!EQ (p->command, Qt)) | 3113 | if (!EQ (p->command, Qt)) |
| 3110 | add_non_keyboard_read_fd (fd); | 3114 | add_process_read_fd (fd); |
| 3111 | 3115 | ||
| 3112 | if (BUFFERP (buffer)) | 3116 | if (BUFFERP (buffer)) |
| 3113 | { | 3117 | { |
| @@ -3597,7 +3601,7 @@ connect_network_socket (Lisp_Object proc, Lisp_Object addrinfos, | |||
| 3597 | still listen for incoming connects unless it is stopped. */ | 3601 | still listen for incoming connects unless it is stopped. */ |
| 3598 | if ((!EQ (p->filter, Qt) && !EQ (p->command, Qt)) | 3602 | if ((!EQ (p->filter, Qt) && !EQ (p->command, Qt)) |
| 3599 | || (EQ (p->status, Qlisten) && NILP (p->command))) | 3603 | || (EQ (p->status, Qlisten) && NILP (p->command))) |
| 3600 | add_non_keyboard_read_fd (inch); | 3604 | add_process_read_fd (inch); |
| 3601 | 3605 | ||
| 3602 | if (inch > max_desc) | 3606 | if (inch > max_desc) |
| 3603 | max_desc = inch; | 3607 | max_desc = inch; |
| @@ -4793,7 +4797,9 @@ server_accept_connection (Lisp_Object server, int channel) | |||
| 4793 | 4797 | ||
| 4794 | /* Client processes for accepted connections are not stopped initially. */ | 4798 | /* Client processes for accepted connections are not stopped initially. */ |
| 4795 | if (!EQ (p->filter, Qt)) | 4799 | if (!EQ (p->filter, Qt)) |
| 4796 | add_non_keyboard_read_fd (s); | 4800 | add_process_read_fd (s); |
| 4801 | if (s > max_desc) | ||
| 4802 | max_desc = s; | ||
| 4797 | 4803 | ||
| 4798 | /* Setup coding system for new process based on server process. | 4804 | /* Setup coding system for new process based on server process. |
| 4799 | This seems to be the proper thing to do, as the coding system | 4805 | This seems to be the proper thing to do, as the coding system |
| @@ -5542,7 +5548,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd, | |||
| 5542 | if (d->func | 5548 | if (d->func |
| 5543 | && ((d->flags & FOR_READ | 5549 | && ((d->flags & FOR_READ |
| 5544 | && FD_ISSET (channel, &Available)) | 5550 | && FD_ISSET (channel, &Available)) |
| 5545 | || (d->flags & FOR_WRITE | 5551 | || ((d->flags & FOR_WRITE) |
| 5546 | && FD_ISSET (channel, &Writeok)))) | 5552 | && FD_ISSET (channel, &Writeok)))) |
| 5547 | d->func (channel, d->data); | 5553 | d->func (channel, d->data); |
| 5548 | } | 5554 | } |
| @@ -5728,7 +5734,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd, | |||
| 5728 | 5734 | ||
| 5729 | if (0 <= p->infd && !EQ (p->filter, Qt) | 5735 | if (0 <= p->infd && !EQ (p->filter, Qt) |
| 5730 | && !EQ (p->command, Qt)) | 5736 | && !EQ (p->command, Qt)) |
| 5731 | add_non_keyboard_read_fd (p->infd); | 5737 | add_process_read_fd (p->infd); |
| 5732 | } | 5738 | } |
| 5733 | } | 5739 | } |
| 5734 | } /* End for each file descriptor. */ | 5740 | } /* End for each file descriptor. */ |
| @@ -6728,7 +6734,7 @@ traffic. */) | |||
| 6728 | && p->infd >= 0 | 6734 | && p->infd >= 0 |
| 6729 | && (!EQ (p->filter, Qt) || EQ (p->status, Qlisten))) | 6735 | && (!EQ (p->filter, Qt) || EQ (p->status, Qlisten))) |
| 6730 | { | 6736 | { |
| 6731 | add_non_keyboard_read_fd (p->infd); | 6737 | add_process_read_fd (p->infd); |
| 6732 | #ifdef WINDOWSNT | 6738 | #ifdef WINDOWSNT |
| 6733 | if (fd_info[ p->infd ].flags & FILE_SERIAL) | 6739 | if (fd_info[ p->infd ].flags & FILE_SERIAL) |
| 6734 | PurgeComm (fd_info[ p->infd ].hnd, PURGE_RXABORT | PURGE_RXCLEAR); | 6740 | PurgeComm (fd_info[ p->infd ].hnd, PURGE_RXABORT | PURGE_RXCLEAR); |
| @@ -7397,7 +7403,8 @@ keyboard_bit_set (fd_set *mask) | |||
| 7397 | 7403 | ||
| 7398 | for (fd = 0; fd <= max_desc; fd++) | 7404 | for (fd = 0; fd <= max_desc; fd++) |
| 7399 | if (FD_ISSET (fd, mask) | 7405 | if (FD_ISSET (fd, mask) |
| 7400 | && ((fd_callback_info[fd].flags & KEYBOARD_FD) != 0)) | 7406 | && ((fd_callback_info[fd].flags & (FOR_READ | KEYBOARD_FD)) |
| 7407 | == (FOR_READ | KEYBOARD_FD))) | ||
| 7401 | return 1; | 7408 | return 1; |
| 7402 | 7409 | ||
| 7403 | return 0; | 7410 | return 0; |
| @@ -7635,8 +7642,7 @@ void | |||
| 7635 | add_timer_wait_descriptor (int fd) | 7642 | add_timer_wait_descriptor (int fd) |
| 7636 | { | 7643 | { |
| 7637 | add_read_fd (fd, timerfd_callback, NULL); | 7644 | add_read_fd (fd, timerfd_callback, NULL); |
| 7638 | if (fd > max_desc) | 7645 | fd_callback_info[fd].flags &= ~KEYBOARD_FD; |
| 7639 | max_desc = fd; | ||
| 7640 | } | 7646 | } |
| 7641 | 7647 | ||
| 7642 | #endif /* HAVE_TIMERFD */ | 7648 | #endif /* HAVE_TIMERFD */ |
| @@ -7661,6 +7667,7 @@ add_keyboard_wait_descriptor (int desc) | |||
| 7661 | { | 7667 | { |
| 7662 | #ifdef subprocesses /* Actually means "not MSDOS". */ | 7668 | #ifdef subprocesses /* Actually means "not MSDOS". */ |
| 7663 | eassert (desc >= 0 && desc < FD_SETSIZE); | 7669 | eassert (desc >= 0 && desc < FD_SETSIZE); |
| 7670 | fd_callback_info[desc].flags &= ~PROCESS_FD; | ||
| 7664 | fd_callback_info[desc].flags |= (FOR_READ | KEYBOARD_FD); | 7671 | fd_callback_info[desc].flags |= (FOR_READ | KEYBOARD_FD); |
| 7665 | if (desc > max_desc) | 7672 | if (desc > max_desc) |
| 7666 | max_desc = desc; | 7673 | max_desc = desc; |