aboutsummaryrefslogtreecommitdiffstats
path: root/src/process.c
diff options
context:
space:
mode:
authorPaul Eggert2016-04-26 09:12:14 -0700
committerPaul Eggert2016-04-26 09:13:07 -0700
commit40a03df45353692f73364e488c962f1a7cf2e8bc (patch)
tree73db77552ab96859e688c8898b9b770b99635fc5 /src/process.c
parent7b9a5c2a451781f674f0a7ebd71f1061a174f627 (diff)
downloademacs-40a03df45353692f73364e488c962f1a7cf2e8bc.tar.gz
emacs-40a03df45353692f73364e488c962f1a7cf2e8bc.zip
Fix socketd fd startup bug that I introduced
Problem reported by Matthew Leach in: http://lists.gnu.org/archive/html/emacs-devel/2016-04/msg00778.html * src/emacs.c (main): Indicate more clearly the coupling between the --daemon option and init_process_emacs. * src/lisp.h: Adjust to API changes. * src/process.c (set_external_socket_descriptor): Remove, replacing by ... (init_process_emacs): ... passing the socket FD here instead. All uses changed.
Diffstat (limited to 'src/process.c')
-rw-r--r--src/process.c22
1 files changed, 8 insertions, 14 deletions
diff --git a/src/process.c b/src/process.c
index a222a5b8e26..0dfe1622971 100644
--- a/src/process.c
+++ b/src/process.c
@@ -267,7 +267,10 @@ static int max_process_desc;
267/* The largest descriptor currently in use for input; -1 if none. */ 267/* The largest descriptor currently in use for input; -1 if none. */
268static int max_input_desc; 268static int max_input_desc;
269 269
270/* The descriptor of any socket passed to Emacs; -1 if none. */ 270/* Set the external socket descriptor for Emacs to use when
271 `make-network-process' is called with a non-nil
272 `:use-external-socket' option. The value should be either -1, or
273 the file descriptor of a socket that is already bound. */
271static int external_sock_fd; 274static int external_sock_fd;
272 275
273/* Indexed by descriptor, gives the process (if any) for that descriptor. */ 276/* Indexed by descriptor, gives the process (if any) for that descriptor. */
@@ -7733,24 +7736,14 @@ catch_child_signal (void)
7733} 7736}
7734#endif /* subprocesses */ 7737#endif /* subprocesses */
7735 7738
7736/* Set the external socket descriptor for Emacs to use when
7737 `make-network-process' is called with a non-nil
7738 `:use-external-socket' option. The fd should have been checked to
7739 ensure it is a valid socket and is already bound. */
7740void
7741set_external_socket_descriptor (int fd)
7742{
7743 external_sock_fd = fd;
7744}
7745
7746 7739
7747/* This is not called "init_process" because that is the name of a 7740/* This is not called "init_process" because that is the name of a
7748 Mach system call, so it would cause problems on Darwin systems. */ 7741 Mach system call, so it would cause problems on Darwin systems. */
7749void 7742void
7750init_process_emacs (void) 7743init_process_emacs (int sockfd)
7751{ 7744{
7752#ifdef subprocesses 7745#ifdef subprocesses
7753 register int i; 7746 int i;
7754 7747
7755 inhibit_sentinels = 0; 7748 inhibit_sentinels = 0;
7756 7749
@@ -7772,7 +7765,8 @@ init_process_emacs (void)
7772 FD_ZERO (&non_keyboard_wait_mask); 7765 FD_ZERO (&non_keyboard_wait_mask);
7773 FD_ZERO (&non_process_wait_mask); 7766 FD_ZERO (&non_process_wait_mask);
7774 FD_ZERO (&write_mask); 7767 FD_ZERO (&write_mask);
7775 max_process_desc = max_input_desc = external_sock_fd = -1; 7768 max_process_desc = max_input_desc = -1;
7769 external_sock_fd = sockfd;
7776 memset (fd_callback_info, 0, sizeof (fd_callback_info)); 7770 memset (fd_callback_info, 0, sizeof (fd_callback_info));
7777 7771
7778 FD_ZERO (&connect_wait_mask); 7772 FD_ZERO (&connect_wait_mask);