mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-03-06 05:52:32 -08:00
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.
This commit is contained in:
parent
7b9a5c2a45
commit
40a03df453
3 changed files with 14 additions and 18 deletions
|
|
@ -971,6 +971,9 @@ main (int argc, char **argv)
|
|||
w32_daemon_event = NULL;
|
||||
#endif
|
||||
|
||||
|
||||
int sockfd = -1;
|
||||
|
||||
if (argmatch (argv, argc, "-daemon", "--daemon", 5, NULL, &skip_args)
|
||||
|| argmatch (argv, argc, "-daemon", "--daemon", 5, &dname_arg, &skip_args))
|
||||
{
|
||||
|
|
@ -1016,7 +1019,7 @@ main (int argc, char **argv)
|
|||
else if (systemd_socket == 1
|
||||
&& (0 < sd_is_socket (SD_LISTEN_FDS_START,
|
||||
AF_UNSPEC, SOCK_STREAM, 1)))
|
||||
set_external_socket_descriptor (SD_LISTEN_FDS_START);
|
||||
sockfd = SD_LISTEN_FDS_START;
|
||||
#endif /* HAVE_LIBSYSTEMD */
|
||||
|
||||
#ifndef DAEMON_MUST_EXEC
|
||||
|
|
@ -1575,7 +1578,7 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
|
|||
/* This can create a thread that may call getenv, so it must follow
|
||||
all calls to putenv and setenv. Also, this sets up
|
||||
add_keyboard_wait_descriptor, which init_display uses. */
|
||||
init_process_emacs ();
|
||||
init_process_emacs (sockfd);
|
||||
|
||||
init_keyboard (); /* This too must precede init_sys_modes. */
|
||||
if (!noninteractive)
|
||||
|
|
|
|||
|
|
@ -4181,10 +4181,9 @@ extern void delete_keyboard_wait_descriptor (int);
|
|||
extern void add_gpm_wait_descriptor (int);
|
||||
extern void delete_gpm_wait_descriptor (int);
|
||||
#endif
|
||||
extern void init_process_emacs (void);
|
||||
extern void init_process_emacs (int);
|
||||
extern void syms_of_process (void);
|
||||
extern void setup_process_coding_systems (Lisp_Object);
|
||||
extern void set_external_socket_descriptor (int);
|
||||
|
||||
/* Defined in callproc.c. */
|
||||
#ifndef DOS_NT
|
||||
|
|
|
|||
|
|
@ -267,7 +267,10 @@ static int max_process_desc;
|
|||
/* The largest descriptor currently in use for input; -1 if none. */
|
||||
static int max_input_desc;
|
||||
|
||||
/* The descriptor of any socket passed to Emacs; -1 if none. */
|
||||
/* Set the external socket descriptor for Emacs to use when
|
||||
`make-network-process' is called with a non-nil
|
||||
`:use-external-socket' option. The value should be either -1, or
|
||||
the file descriptor of a socket that is already bound. */
|
||||
static int external_sock_fd;
|
||||
|
||||
/* Indexed by descriptor, gives the process (if any) for that descriptor. */
|
||||
|
|
@ -7733,24 +7736,14 @@ catch_child_signal (void)
|
|||
}
|
||||
#endif /* subprocesses */
|
||||
|
||||
/* Set the external socket descriptor for Emacs to use when
|
||||
`make-network-process' is called with a non-nil
|
||||
`:use-external-socket' option. The fd should have been checked to
|
||||
ensure it is a valid socket and is already bound. */
|
||||
void
|
||||
set_external_socket_descriptor (int fd)
|
||||
{
|
||||
external_sock_fd = fd;
|
||||
}
|
||||
|
||||
|
||||
/* This is not called "init_process" because that is the name of a
|
||||
Mach system call, so it would cause problems on Darwin systems. */
|
||||
void
|
||||
init_process_emacs (void)
|
||||
init_process_emacs (int sockfd)
|
||||
{
|
||||
#ifdef subprocesses
|
||||
register int i;
|
||||
int i;
|
||||
|
||||
inhibit_sentinels = 0;
|
||||
|
||||
|
|
@ -7772,7 +7765,8 @@ init_process_emacs (void)
|
|||
FD_ZERO (&non_keyboard_wait_mask);
|
||||
FD_ZERO (&non_process_wait_mask);
|
||||
FD_ZERO (&write_mask);
|
||||
max_process_desc = max_input_desc = external_sock_fd = -1;
|
||||
max_process_desc = max_input_desc = -1;
|
||||
external_sock_fd = sockfd;
|
||||
memset (fd_callback_info, 0, sizeof (fd_callback_info));
|
||||
|
||||
FD_ZERO (&connect_wait_mask);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue