From df7734b220de9c61575677adbc1f431ef6703d84 Mon Sep 17 00:00:00 2001 From: Dan Nicolaescu Date: Mon, 22 Mar 2010 12:51:59 -0700 Subject: Remove dead code dealing with POSIX_SIGNALS. * atimer.c (set_alarm): Remove dead code, all USG systems define POSIX_SIGNALS. * data.c (arith_error): Likewise. * keyboard.c (input_available_signal, handle_user_signal) (interrupt_signal): Likewise. * process.c (sigchld_handler): Likewise. (create_process): Remove if 0 code. Remove HPUX conditional when !defined (POSIX_SIGNALS), it cannot be true. * syssignal.h: Remove USG5_4 and USG conditionals when !POSIX_SIGNALS, they cannot be true. --- src/process.c | 45 +++++++-------------------------------------- 1 file changed, 7 insertions(+), 38 deletions(-) (limited to 'src/process.c') diff --git a/src/process.c b/src/process.c index 53cc42f223e..5d2d64e3ddc 100644 --- a/src/process.c +++ b/src/process.c @@ -1878,13 +1878,7 @@ create_process (process, new_argv, current_dir) #ifdef AIX struct sigaction sighup_action; #endif -#else /* !POSIX_SIGNALS */ -#if 0 -#ifdef SIGCHLD - SIGTYPE (*sigchld)(); -#endif -#endif /* 0 */ -#endif /* !POSIX_SIGNALS */ +#endif /* POSIX_SIGNALS */ /* Use volatile to protect variables from being clobbered by longjmp. */ volatile int forkin, forkout; volatile int pty_flag = 0; @@ -2008,14 +2002,9 @@ create_process (process, new_argv, current_dir) sigprocmask (SIG_BLOCK, &blocked, &procmask); #else /* !POSIX_SIGNALS */ #ifdef SIGCHLD -#if defined (BSD_SYSTEM) || defined (HPUX) +#if defined (BSD_SYSTEM) sigsetmask (sigmask (SIGCHLD)); -#else /* ordinary USG */ -#if 0 - sigchld_deferred = 0; - sigchld = signal (SIGCHLD, create_process_sigchld); -#endif -#endif /* ordinary USG */ +#endif /* BSD_SYSTEM */ #endif /* SIGCHLD */ #endif /* !POSIX_SIGNALS */ @@ -2172,13 +2161,9 @@ create_process (process, new_argv, current_dir) sigprocmask (SIG_SETMASK, &procmask, 0); #else /* !POSIX_SIGNALS */ #ifdef SIGCHLD -#if defined (BSD_SYSTEM) || defined (HPUX) +#if defined (BSD_SYSTEM) sigsetmask (SIGEMPTYMASK); -#else /* ordinary USG */ -#if 0 - signal (SIGCHLD, sigchld); -#endif -#endif /* ordinary USG */ +#endif /* BSD_SYSTEM */ #endif /* SIGCHLD */ #endif /* !POSIX_SIGNALS */ @@ -2275,17 +2260,9 @@ create_process (process, new_argv, current_dir) sigprocmask (SIG_SETMASK, &procmask, 0); #else /* !POSIX_SIGNALS */ #ifdef SIGCHLD -#if defined (BSD_SYSTEM) || defined (HPUX) +#if defined (BSD_SYSTEM) sigsetmask (SIGEMPTYMASK); -#else /* ordinary USG */ -#if 0 - signal (SIGCHLD, sigchld); - /* Now really handle any of these signals - that came in during this function. */ - if (sigchld_deferred) - kill (getpid (), SIGCHLD); -#endif -#endif /* ordinary USG */ +#endif /* BSD_SYSTEM */ #endif /* SIGCHLD */ #endif /* !POSIX_SIGNALS */ @@ -6704,11 +6681,6 @@ sigchld_handler (signo) /* PID == 0 means no processes found, PID == -1 means a real failure. We have done all our job, so return. */ - /* USG systems forget handlers when they are used; - must reestablish each time */ -#if defined (USG) && !defined (POSIX_SIGNALS) - signal (signo, sigchld_handler); /* WARNING - must come after wait3() */ -#endif errno = old_errno; return; } @@ -6809,9 +6781,6 @@ sigchld_handler (signo) #if (defined WINDOWSNT \ || (defined USG && !defined GNU_LINUX \ && !(defined HPUX && defined WNOHANG))) -#if defined (USG) && ! defined (POSIX_SIGNALS) - signal (signo, sigchld_handler); -#endif errno = old_errno; return; #endif /* USG, but not HPUX with WNOHANG */ -- cgit v1.2.1 From cd591dbccd185c8c271f5ee5e01bf7325e370582 Mon Sep 17 00:00:00 2001 From: Helmut Eller Date: Thu, 25 Mar 2010 17:48:52 +0900 Subject: Call `select' for interrupted `connect' rather than creating new socket (Bug#5173). --- src/process.c | 37 ++++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) (limited to 'src/process.c') diff --git a/src/process.c b/src/process.c index 5d2d64e3ddc..789befc2a6b 100644 --- a/src/process.c +++ b/src/process.c @@ -3534,8 +3534,6 @@ usage: (make-network-process &rest ARGS) */) { int optn, optbits; - retry_connect: - s = socket (lres->ai_family, lres->ai_socktype, lres->ai_protocol); if (s < 0) { @@ -3652,6 +3650,38 @@ usage: (make-network-process &rest ARGS) */) #endif #endif #endif + if (xerrno == EINTR) + { + /* Unlike most other syscalls connect() cannot be called + again. (That would return EALREADY.) The proper way to + wait for completion is select(). */ + int sc; + SELECT_TYPE fdset; + retry_select: + FD_ZERO (&fdset); + FD_SET (s, &fdset); + QUIT; + sc = select (s + 1, (SELECT_TYPE *)0, &fdset, (SELECT_TYPE *)0, + (EMACS_TIME *)0); + if (sc == -1) + { + if (errno == EINTR) + goto retry_select; + else + report_file_error ("select failed", Qnil); + } + eassert (sc > 0); + { + int len = sizeof xerrno; + eassert (FD_ISSET (s, &fdset)); + if (getsockopt (s, SOL_SOCKET, SO_ERROR, &xerrno, &len) == -1) + report_file_error ("getsockopt failed", Qnil); + if (xerrno != 0) + errno = xerrno, report_file_error ("error during connect", Qnil); + else + break; + } + } immediate_quit = 0; @@ -3659,9 +3689,6 @@ usage: (make-network-process &rest ARGS) */) specpdl_ptr = specpdl + count1; emacs_close (s); s = -1; - - if (xerrno == EINTR) - goto retry_connect; } if (s >= 0) -- cgit v1.2.1 From cad4261fd31b3dec552ffc4dfd66c0b2a19169ce Mon Sep 17 00:00:00 2001 From: YAMAMOTO Mitsuharu Date: Thu, 25 Mar 2010 17:56:15 +0900 Subject: Don't call turn_on_atimers around `connect' (Bug#5723). --- src/process.c | 14 -------------- 1 file changed, 14 deletions(-) (limited to 'src/process.c') diff --git a/src/process.c b/src/process.c index 789befc2a6b..268a3ad7bab 100644 --- a/src/process.c +++ b/src/process.c @@ -3615,23 +3615,9 @@ usage: (make-network-process &rest ARGS) */) immediate_quit = 1; QUIT; - /* This turns off all alarm-based interrupts; the - bind_polling_period call above doesn't always turn all the - short-interval ones off, especially if interrupt_input is - set. - - It'd be nice to be able to control the connect timeout - though. Would non-blocking connect calls be portable? - - This used to be conditioned by HAVE_GETADDRINFO. Why? */ - - turn_on_atimers (0); - ret = connect (s, lres->ai_addr, lres->ai_addrlen); xerrno = errno; - turn_on_atimers (1); - if (ret == 0 || xerrno == EISCONN) { /* The unwind-protect will be discarded afterwards. -- cgit v1.2.1 From 649dbf36cdf3ce38a3fc0d08a814d299e9f72d8c Mon Sep 17 00:00:00 2001 From: Chong Yidong Date: Fri, 26 Mar 2010 20:45:32 -0400 Subject: * process.c (Fmake_network_process): Don't apply Bug#5173 fix for Windows. --- src/process.c | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) (limited to 'src/process.c') diff --git a/src/process.c b/src/process.c index 268a3ad7bab..4f103752296 100644 --- a/src/process.c +++ b/src/process.c @@ -3534,6 +3534,8 @@ usage: (make-network-process &rest ARGS) */) { int optn, optbits; + retry_connect: + s = socket (lres->ai_family, lres->ai_socktype, lres->ai_protocol); if (s < 0) { @@ -3636,12 +3638,14 @@ usage: (make-network-process &rest ARGS) */) #endif #endif #endif + +#ifndef WINDOWSNT if (xerrno == EINTR) { /* Unlike most other syscalls connect() cannot be called again. (That would return EALREADY.) The proper way to wait for completion is select(). */ - int sc; + int sc, len; SELECT_TYPE fdset; retry_select: FD_ZERO (&fdset); @@ -3651,23 +3655,23 @@ usage: (make-network-process &rest ARGS) */) (EMACS_TIME *)0); if (sc == -1) { - if (errno == EINTR) + if (errno == EINTR) goto retry_select; - else + else report_file_error ("select failed", Qnil); } eassert (sc > 0); - { - int len = sizeof xerrno; - eassert (FD_ISSET (s, &fdset)); - if (getsockopt (s, SOL_SOCKET, SO_ERROR, &xerrno, &len) == -1) - report_file_error ("getsockopt failed", Qnil); - if (xerrno != 0) - errno = xerrno, report_file_error ("error during connect", Qnil); - else - break; - } + + len = sizeof xerrno; + eassert (FD_ISSET (s, &fdset)); + if (getsockopt (s, SOL_SOCKET, SO_ERROR, &xerrno, &len) == -1) + report_file_error ("getsockopt failed", Qnil); + if (xerrno) + errno = xerrno, report_file_error ("error during connect", Qnil); + else + break; } +#endif /* !WINDOWSNT */ immediate_quit = 0; @@ -3675,6 +3679,11 @@ usage: (make-network-process &rest ARGS) */) specpdl_ptr = specpdl + count1; emacs_close (s); s = -1; + +#ifdef WINDOWSNT + if (xerrno == EINTR) + goto retry_connect; +#endif } if (s >= 0) -- cgit v1.2.1