Commit 3fad2ad2 authored by Jan D's avatar Jan D
Browse files

Add fd handling with callbacks to select, dbus needs it for async operation.

* src/dbusbind.c: Include process.h.
(dbus_fd_cb, xd_find_watch_fd, xd_toggle_watch)
(xd_read_message_1): New functions.
(xd_add_watch, xd_remove_watch): Call xd_find_watch_fd.  Handle
watch for both read and write.
(Fdbus_init_bus): Also register xd_toggle_watch.
(Fdbus_call_method_asynchronously, Fdbus_method_return_internal)
(Fdbus_method_error_internal, Fdbus_send_signal): Remove call
to dbus_connection_flush.
(xd_read_message):  Move most of the code to xd_read_message_1.
Call xd_read_message_1 until status is COMPLETE.

* src/keyboard.c (readable_events, gobble_input): Remove DBUS code.

* src/process.c (gpm_wait_mask, max_gpm_desc): Remove.
(write_mask): New variable.
(max_input_desc): Renamed from max_keyboard_desc.
(fd_callback_info): New variable.
(add_read_fd, delete_read_fd, add_write_fd, delete_write_fd): New
functions.
(Fmake_network_process): FD_SET write_mask.
(deactivate_process): FD_CLR write_mask.
(wait_reading_process_output): Connecting renamed to Writeok.
check_connect removed.  check_write is new.  Remove references to
gpm.  Use Writeok/check_write unconditionally (i.e. no #ifdef
NON_BLOCKING_CONNECT) instead of Connecting.
Loop over file descriptors and call callbacks in fd_callback_info
if file descriptor is ready for I/O.
(add_gpm_wait_descriptor): Just call add_keyboard_wait_descriptor.
(delete_gpm_wait_descriptor): Just call delete_keyboard_wait_descriptor.
(keyboard_bit_set): Use max_input_desc.
(add_keyboard_wait_descriptor, delete_keyboard_wait_descriptor): Remove
#ifdef subprocesses. Use max_input_desc.
(init_process): Initialize write_mask and fd_callback_info.

* src/process.h (add_read_fd, delete_read_fd, add_write_fd)
(delete_write_fd): Declare.
parent 6303aba1
2010-09-26 Jan Djärv <jan.h.d@swipnet.se>
* process.h (add_read_fd, delete_read_fd, add_write_fd)
(delete_write_fd): Declare.
* process.c (gpm_wait_mask, max_gpm_desc): Remove.
(write_mask): New variable.
(max_input_desc): Renamed from max_keyboard_desc.
(fd_callback_info): New variable.
(add_read_fd, delete_read_fd, add_write_fd, delete_write_fd): New
functions.
(Fmake_network_process): FD_SET write_mask.
(deactivate_process): FD_CLR write_mask.
(wait_reading_process_output): Connecting renamed to Writeok.
check_connect removed. check_write is new. Remove references to
gpm. Use Writeok/check_write unconditionally (i.e. no #ifdef
NON_BLOCKING_CONNECT) instead of Connecting.
Loop over file descriptors and call callbacks in fd_callback_info
if file descriptor is ready for I/O.
(add_gpm_wait_descriptor): Just call add_keyboard_wait_descriptor.
(delete_gpm_wait_descriptor): Just call delete_keyboard_wait_descriptor.
(keyboard_bit_set): Use max_input_desc.
(add_keyboard_wait_descriptor, delete_keyboard_wait_descriptor): Remove
#ifdef subprocesses. Use max_input_desc.
(init_process): Initialize write_mask and fd_callback_info.
* keyboard.c (readable_events, gobble_input): Remove DBUS code.
* dbusbind.c: Include process.h.
(dbus_fd_cb, xd_find_watch_fd, xd_toggle_watch)
(xd_read_message_1): New functions.
(xd_add_watch, xd_remove_watch): Call xd_find_watch_fd. Handle
watch for both read and write.
(Fdbus_init_bus): Also register xd_toggle_watch.
(Fdbus_call_method_asynchronously, Fdbus_method_return_internal)
(Fdbus_method_error_internal, Fdbus_send_signal): Remove call
to dbus_connection_flush.
(xd_read_message): Move most of the code to xd_read_message_1.
Call xd_read_message_1 until status is COMPLETE.
2010-09-26 Dan Nicolaescu <dann@ics.uci.edu> 2010-09-26 Dan Nicolaescu <dann@ics.uci.edu>
   
* term.c: Do not include sys/ioctl.h, not needed. * term.c: Do not include sys/ioctl.h, not needed.
......
...@@ -27,6 +27,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ ...@@ -27,6 +27,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include "frame.h" #include "frame.h"
#include "termhooks.h" #include "termhooks.h"
#include "keyboard.h" #include "keyboard.h"
#include "process.h"
/* Subroutines. */ /* Subroutines. */
...@@ -799,71 +800,93 @@ xd_initialize (Lisp_Object bus, int raise_error) ...@@ -799,71 +800,93 @@ xd_initialize (Lisp_Object bus, int raise_error)
return connection; return connection;
} }
/* Callback called when something is read to read ow write. */
/* Add connection file descriptor to input_wait_mask, in order to static void
let select() detect, whether a new message has been arrived. */ dbus_fd_cb (int fd, void *data, int for_read)
dbus_bool_t {
xd_add_watch (DBusWatch *watch, void *data) xd_read_queued_messages ();
}
/* Return the file descriptor for WATCH, -1 if not found. */
static int
xd_find_watch_fd (DBusWatch *watch)
{ {
/* We check only for incoming data. */
if (dbus_watch_get_flags (watch) & DBUS_WATCH_READABLE)
{
#if HAVE_DBUS_WATCH_GET_UNIX_FD #if HAVE_DBUS_WATCH_GET_UNIX_FD
/* TODO: Reverse these on Win32, which prefers the opposite. */ /* TODO: Reverse these on Win32, which prefers the opposite. */
int fd = dbus_watch_get_unix_fd(watch); int fd = dbus_watch_get_unix_fd (watch);
if (fd == -1) if (fd == -1)
fd = dbus_watch_get_socket(watch); fd = dbus_watch_get_socket (watch);
#else #else
int fd = dbus_watch_get_fd(watch); int fd = dbus_watch_get_fd (watch);
#endif #endif
XD_DEBUG_MESSAGE ("fd %d", fd); return fd;
}
if (fd == -1)
return FALSE;
/* Add the file descriptor to input_wait_mask. */ /* Start monitoring WATCH for possible I/O. */
add_keyboard_wait_descriptor (fd);
}
/* Return. */ static dbus_bool_t
xd_add_watch (DBusWatch *watch, void *data)
{
unsigned int flags = dbus_watch_get_flags (watch);
int fd = xd_find_watch_fd (watch);
XD_DEBUG_MESSAGE ("fd %d, write %d, enabled %d",
fd, flags & DBUS_WATCH_WRITABLE,
dbus_watch_get_enabled (watch));
if (fd == -1)
return FALSE;
if (dbus_watch_get_enabled (watch))
{
if (flags & DBUS_WATCH_WRITABLE)
add_write_fd (fd, dbus_fd_cb, NULL);
if (flags & DBUS_WATCH_READABLE)
add_read_fd (fd, dbus_fd_cb, NULL);
}
return TRUE; return TRUE;
} }
/* Remove connection file descriptor from input_wait_mask. DATA is /* Stop monitoring WATCH for possible I/O.
the used bus, either a string or QCdbus_system_bus or DATA is the used bus, either a string or QCdbus_system_bus or
QCdbus_session_bus. */ QCdbus_session_bus. */
void
static void
xd_remove_watch (DBusWatch *watch, void *data) xd_remove_watch (DBusWatch *watch, void *data)
{ {
/* We check only for incoming data. */ unsigned int flags = dbus_watch_get_flags (watch);
if (dbus_watch_get_flags (watch) & DBUS_WATCH_READABLE) int fd = xd_find_watch_fd (watch);
{
#if HAVE_DBUS_WATCH_GET_UNIX_FD
/* TODO: Reverse these on Win32, which prefers the opposite. */
int fd = dbus_watch_get_unix_fd(watch);
if (fd == -1)
fd = dbus_watch_get_socket(watch);
#else
int fd = dbus_watch_get_fd(watch);
#endif
XD_DEBUG_MESSAGE ("fd %d", fd);
if (fd == -1) XD_DEBUG_MESSAGE ("fd %d", fd);
return;
if (fd == -1) return;
/* Unset session environment. */
if ((data != NULL) && (data == (void*) XHASH (QCdbus_session_bus)))
{
XD_DEBUG_MESSAGE ("unsetenv DBUS_SESSION_BUS_ADDRESS");
unsetenv ("DBUS_SESSION_BUS_ADDRESS");
}
/* Remove the file descriptor from input_wait_mask. */ /* Unset session environment. */
delete_keyboard_wait_descriptor (fd); if (data != NULL && data == (void*) XHASH (QCdbus_session_bus))
{
XD_DEBUG_MESSAGE ("unsetenv DBUS_SESSION_BUS_ADDRESS");
unsetenv ("DBUS_SESSION_BUS_ADDRESS");
} }
/* Return. */ if (flags & DBUS_WATCH_WRITABLE)
return; delete_write_fd (fd);
if (flags & DBUS_WATCH_READABLE)
delete_read_fd (fd);
}
/* Toggle monitoring WATCH for possible I/O. */
static void
xd_toggle_watch (DBusWatch *watch, void *data)
{
if (dbus_watch_get_enabled (watch))
xd_add_watch (watch, data);
else
xd_remove_watch (watch, data);
} }
DEFUN ("dbus-init-bus", Fdbus_init_bus, Sdbus_init_bus, 1, 1, 0, DEFUN ("dbus-init-bus", Fdbus_init_bus, Sdbus_init_bus, 1, 1, 0,
...@@ -880,7 +903,8 @@ DEFUN ("dbus-init-bus", Fdbus_init_bus, Sdbus_init_bus, 1, 1, 0, ...@@ -880,7 +903,8 @@ DEFUN ("dbus-init-bus", Fdbus_init_bus, Sdbus_init_bus, 1, 1, 0,
if (!dbus_connection_set_watch_functions (connection, if (!dbus_connection_set_watch_functions (connection,
xd_add_watch, xd_add_watch,
xd_remove_watch, xd_remove_watch,
NULL, (void*) XHASH (bus), NULL)) xd_toggle_watch,
(void*) XHASH (bus), NULL))
XD_SIGNAL1 (build_string ("Cannot add watch functions")); XD_SIGNAL1 (build_string ("Cannot add watch functions"));
/* Add bus to list of registered buses. */ /* Add bus to list of registered buses. */
...@@ -1288,9 +1312,6 @@ usage: (dbus-call-method-asynchronously BUS SERVICE PATH INTERFACE METHOD HANDLE ...@@ -1288,9 +1312,6 @@ usage: (dbus-call-method-asynchronously BUS SERVICE PATH INTERFACE METHOD HANDLE
result = Qnil; result = Qnil;
} }
/* Flush connection to ensure the message is handled. */
dbus_connection_flush (connection);
XD_DEBUG_MESSAGE ("Message sent"); XD_DEBUG_MESSAGE ("Message sent");
/* Cleanup. */ /* Cleanup. */
...@@ -1379,9 +1400,6 @@ usage: (dbus-method-return-internal BUS SERIAL SERVICE &rest ARGS) */) ...@@ -1379,9 +1400,6 @@ usage: (dbus-method-return-internal BUS SERIAL SERVICE &rest ARGS) */)
if (!dbus_connection_send (connection, dmessage, NULL)) if (!dbus_connection_send (connection, dmessage, NULL))
XD_SIGNAL1 (build_string ("Cannot send message")); XD_SIGNAL1 (build_string ("Cannot send message"));
/* Flush connection to ensure the message is handled. */
dbus_connection_flush (connection);
XD_DEBUG_MESSAGE ("Message sent"); XD_DEBUG_MESSAGE ("Message sent");
/* Cleanup. */ /* Cleanup. */
...@@ -1471,9 +1489,6 @@ usage: (dbus-method-error-internal BUS SERIAL SERVICE &rest ARGS) */) ...@@ -1471,9 +1489,6 @@ usage: (dbus-method-error-internal BUS SERIAL SERVICE &rest ARGS) */)
if (!dbus_connection_send (connection, dmessage, NULL)) if (!dbus_connection_send (connection, dmessage, NULL))
XD_SIGNAL1 (build_string ("Cannot send message")); XD_SIGNAL1 (build_string ("Cannot send message"));
/* Flush connection to ensure the message is handled. */
dbus_connection_flush (connection);
XD_DEBUG_MESSAGE ("Message sent"); XD_DEBUG_MESSAGE ("Message sent");
/* Cleanup. */ /* Cleanup. */
...@@ -1589,9 +1604,6 @@ usage: (dbus-send-signal BUS SERVICE PATH INTERFACE SIGNAL &rest ARGS) */) ...@@ -1589,9 +1604,6 @@ usage: (dbus-send-signal BUS SERVICE PATH INTERFACE SIGNAL &rest ARGS) */)
if (!dbus_connection_send (connection, dmessage, NULL)) if (!dbus_connection_send (connection, dmessage, NULL))
XD_SIGNAL1 (build_string ("Cannot send message")); XD_SIGNAL1 (build_string ("Cannot send message"));
/* Flush connection to ensure the message is handled. */
dbus_connection_flush (connection);
XD_DEBUG_MESSAGE ("Signal sent"); XD_DEBUG_MESSAGE ("Signal sent");
/* Cleanup. */ /* Cleanup. */
...@@ -1645,32 +1657,27 @@ xd_pending_messages (void) ...@@ -1645,32 +1657,27 @@ xd_pending_messages (void)
return FALSE; return FALSE;
} }
/* Read queued incoming message of the D-Bus BUS. BUS is either a /* Read one queued incoming message of the D-Bus BUS.
Lisp symbol, :system or :session, or a string denoting the bus BUS is either a Lisp symbol, :system or :session, or a string denoting
address. */ the bus address. */
static Lisp_Object
xd_read_message (Lisp_Object bus) static void
xd_read_message_1 (DBusConnection *connection, Lisp_Object bus)
{ {
Lisp_Object args, key, value; Lisp_Object args, key, value;
struct gcpro gcpro1; struct gcpro gcpro1;
struct input_event event; struct input_event event;
DBusConnection *connection;
DBusMessage *dmessage; DBusMessage *dmessage;
DBusMessageIter iter; DBusMessageIter iter;
unsigned int dtype; unsigned int dtype;
int mtype, serial; int mtype, serial;
const char *uname, *path, *interface, *member; const char *uname, *path, *interface, *member;
/* Open a connection to the bus. */
connection = xd_initialize (bus, TRUE);
/* Non blocking read of the next available message. */
dbus_connection_read_write (connection, 0);
dmessage = dbus_connection_pop_message (connection); dmessage = dbus_connection_pop_message (connection);
/* Return if there is no queued message. */ /* Return if there is no queued message. */
if (dmessage == NULL) if (dmessage == NULL)
return Qnil; return;
/* Collect the parameters. */ /* Collect the parameters. */
args = Qnil; args = Qnil;
...@@ -1801,7 +1808,26 @@ xd_read_message (Lisp_Object bus) ...@@ -1801,7 +1808,26 @@ xd_read_message (Lisp_Object bus)
cleanup: cleanup:
dbus_message_unref (dmessage); dbus_message_unref (dmessage);
RETURN_UNGCPRO (Qnil); UNGCPRO;
}
/* Read queued incoming messages of the D-Bus BUS.
BUS is either a Lisp symbol, :system or :session, or a string denoting
the bus address. */
static Lisp_Object
xd_read_message (Lisp_Object bus)
{
/* Open a connection to the bus. */
DBusConnection *connection = xd_initialize (bus, TRUE);
/* Non blocking read of the next available message. */
dbus_connection_read_write (connection, 0);
while (dbus_connection_get_dispatch_status (connection)
!= DBUS_DISPATCH_COMPLETE)
xd_read_message_1 (connection, bus);
return Qnil;
} }
/* Read queued incoming messages from all buses. */ /* Read queued incoming messages from all buses. */
......
...@@ -3522,12 +3522,6 @@ restore_getcjmp (jmp_buf temp) ...@@ -3522,12 +3522,6 @@ restore_getcjmp (jmp_buf temp)
static int static int
readable_events (int flags) readable_events (int flags)
{ {
#ifdef HAVE_DBUS
/* Check whether a D-Bus message has arrived. */
if (xd_pending_messages () > 0)
return 1;
#endif /* HAVE_DBUS */
if (flags & READABLE_EVENTS_DO_TIMERS_NOW) if (flags & READABLE_EVENTS_DO_TIMERS_NOW)
timer_check (1); timer_check (1);
...@@ -6877,11 +6871,6 @@ get_input_pending (int *addr, int flags) ...@@ -6877,11 +6871,6 @@ get_input_pending (int *addr, int flags)
void void
gobble_input (int expected) gobble_input (int expected)
{ {
#ifdef HAVE_DBUS
/* Read D-Bus messages. */
xd_read_queued_messages ();
#endif /* HAVE_DBUS */
#ifdef SIGIO #ifdef SIGIO
if (interrupt_input) if (interrupt_input)
{ {
......
...@@ -294,9 +294,9 @@ static SELECT_TYPE non_keyboard_wait_mask; ...@@ -294,9 +294,9 @@ static SELECT_TYPE non_keyboard_wait_mask;
static SELECT_TYPE non_process_wait_mask; static SELECT_TYPE non_process_wait_mask;
/* Mask for the gpm mouse input descriptor. */ /* Mask for selecting for write. */
static SELECT_TYPE gpm_wait_mask; static SELECT_TYPE write_mask;
#ifdef NON_BLOCKING_CONNECT #ifdef NON_BLOCKING_CONNECT
/* Mask of bits indicating the descriptors that we wait for connect to /* Mask of bits indicating the descriptors that we wait for connect to
...@@ -316,11 +316,8 @@ static int num_pending_connects; ...@@ -316,11 +316,8 @@ static int num_pending_connects;
/* The largest descriptor currently in use for a process object. */ /* The largest descriptor currently in use for a process object. */
static int max_process_desc; static int max_process_desc;
/* The largest descriptor currently in use for keyboard input. */ /* The largest descriptor currently in use for input. */
static int max_keyboard_desc; static int max_input_desc;
/* The largest descriptor currently in use for gpm mouse input. */
static int max_gpm_desc;
/* Indexed by descriptor, gives the process (if any) for that descriptor */ /* Indexed by descriptor, gives the process (if any) for that descriptor */
Lisp_Object chan_process[MAXDESC]; Lisp_Object chan_process[MAXDESC];
...@@ -365,6 +362,90 @@ static int pty_max_bytes; ...@@ -365,6 +362,90 @@ static int pty_max_bytes;
static char pty_name[24]; static char pty_name[24];
#endif #endif
struct fd_callback_data
{
fd_callback func;
void *data;
#define FOR_READ 1
#define FOR_WRITE 2
int condition; /* mask of the defines above. */
} fd_callback_info[MAXDESC];
/* Add a file descriptor FD to be monitored for when read is possible.
When read is possible, call FUNC with argument DATA. */
void
add_read_fd (int fd, fd_callback func, void *data)
{
xassert (fd < MAXDESC);
add_keyboard_wait_descriptor (fd);
fd_callback_info[fd].func = func;
fd_callback_info[fd].data = data;
fd_callback_info[fd].condition |= FOR_READ;
}
/* Stop monitoring file descriptor FD for when read is possible. */
void
delete_read_fd (int fd)
{
xassert (fd < MAXDESC);
delete_keyboard_wait_descriptor (fd);
fd_callback_info[fd].condition &= ~FOR_READ;
if (fd_callback_info[fd].condition == 0)
{
fd_callback_info[fd].func = 0;
fd_callback_info[fd].data = 0;
}
}
/* Add a file descriptor FD to be monitored for when write is possible.
When write is possible, call FUNC with argument DATA. */
void
add_write_fd (int fd, fd_callback func, void *data)
{
xassert (fd < MAXDESC);
FD_SET (fd, &write_mask);
if (fd > max_input_desc)
max_input_desc = fd;
fd_callback_info[fd].func = func;
fd_callback_info[fd].data = data;
fd_callback_info[fd].condition |= FOR_WRITE;
}
/* Stop monitoring file descriptor FD for when write is possible. */
void
delete_write_fd (int fd)
{
int lim = max_input_desc;
xassert (fd < MAXDESC);
FD_CLR (fd, &write_mask);
fd_callback_info[fd].condition &= ~FOR_WRITE;
if (fd_callback_info[fd].condition == 0)
{
fd_callback_info[fd].func = 0;
fd_callback_info[fd].data = 0;
if (fd == max_input_desc)
for (fd = lim; fd >= 0; fd--)
if (FD_ISSET (fd, &input_wait_mask) || FD_ISSET (fd, &write_mask))
{
max_input_desc = fd;
break;
}
}
}
/* Compute the Lisp form of the process status, p->status, from /* Compute the Lisp form of the process status, p->status, from
the numeric status that was returned by `wait'. */ the numeric status that was returned by `wait'. */
...@@ -3620,6 +3701,7 @@ usage: (make-network-process &rest ARGS) */) ...@@ -3620,6 +3701,7 @@ usage: (make-network-process &rest ARGS) */)
if (!FD_ISSET (inch, &connect_wait_mask)) if (!FD_ISSET (inch, &connect_wait_mask))
{ {
FD_SET (inch, &connect_wait_mask); FD_SET (inch, &connect_wait_mask);
FD_SET (inch, &write_mask);
num_pending_connects++; num_pending_connects++;
} }
} }
...@@ -4023,6 +4105,7 @@ deactivate_process (Lisp_Object proc) ...@@ -4023,6 +4105,7 @@ deactivate_process (Lisp_Object proc)
if (FD_ISSET (inchannel, &connect_wait_mask)) if (FD_ISSET (inchannel, &connect_wait_mask))
{ {
FD_CLR (inchannel, &connect_wait_mask); FD_CLR (inchannel, &connect_wait_mask);
FD_CLR (inchannel, &write_mask);
if (--num_pending_connects < 0) if (--num_pending_connects < 0)
abort (); abort ();
} }
...@@ -4401,10 +4484,8 @@ wait_reading_process_output (int time_limit, int microsecs, int read_kbd, ...@@ -4401,10 +4484,8 @@ wait_reading_process_output (int time_limit, int microsecs, int read_kbd,
{ {
register int channel, nfds; register int channel, nfds;
SELECT_TYPE Available; SELECT_TYPE Available;
#ifdef NON_BLOCKING_CONNECT SELECT_TYPE Writeok;
SELECT_TYPE Connecting; int check_write;
int check_connect;
#endif
int check_delay, no_avail; int check_delay, no_avail;
int xerrno; int xerrno;
Lisp_Object proc; Lisp_Object proc;
...@@ -4414,9 +4495,7 @@ wait_reading_process_output (int time_limit, int microsecs, int read_kbd, ...@@ -4414,9 +4495,7 @@ wait_reading_process_output (int time_limit, int microsecs, int read_kbd,
int count = SPECPDL_INDEX (); int count = SPECPDL_INDEX ();
FD_ZERO (&Available); FD_ZERO (&Available);
#ifdef NON_BLOCKING_CONNECT FD_ZERO (&Writeok);
FD_ZERO (&Connecting);
#endif
if (time_limit == 0 && microsecs == 0 && wait_proc && !NILP (Vinhibit_quit) if (time_limit == 0 && microsecs == 0 && wait_proc && !NILP (Vinhibit_quit)
&& !(CONSP (wait_proc->status) && EQ (XCAR (wait_proc->status), Qexit))) && !(CONSP (wait_proc->status) && EQ (XCAR (wait_proc->status), Qexit)))
...@@ -4552,19 +4631,16 @@ wait_reading_process_output (int time_limit, int microsecs, int read_kbd, ...@@ -4552,19 +4631,16 @@ wait_reading_process_output (int time_limit, int microsecs, int read_kbd,
if (update_tick != process_tick) if (update_tick != process_tick)
{ {
SELECT_TYPE Atemp; SELECT_TYPE Atemp;
#ifdef NON_BLOCKING_CONNECT
SELECT_TYPE Ctemp; SELECT_TYPE Ctemp;
#endif
if (kbd_on_hold_p ()) if (kbd_on_hold_p ())
FD_ZERO (&Atemp); FD_ZERO (&Atemp);
else else
Atemp = input_wait_mask; Atemp = input_wait_mask;
IF_NON_BLOCKING_CONNECT (Ctemp = connect_wait_mask); Ctemp = write_mask;
EMACS_SET_SECS_USECS (timeout, 0, 0); EMACS_SET_SECS_USECS (timeout, 0, 0);
if ((select (max (max (max_process_desc, max_keyboard_desc), if ((select (max (max_process_desc, max_input_desc) + 1,
max_gpm_desc) + 1,
&Atemp, &Atemp,
#ifdef NON_BLOCKING_CONNECT #ifdef NON_BLOCKING_CONNECT
(num_pending_connects > 0 ? &Ctemp : (SELECT_TYPE *)0), (num_pending_connects > 0 ? &Ctemp : (SELECT_TYPE *)0),
...@@ -4635,13 +4711,13 @@ wait_reading_process_output (int time_limit, int microsecs, int read_kbd, ...@@ -4635,13 +4711,13 @@ wait_reading_process_output (int time_limit, int microsecs, int read_kbd,
break; break;
FD_SET (wait_proc->infd, &Available); FD_SET (wait_proc->infd, &Available);
check_delay = 0; check_delay = 0;
IF_NON_BLOCKING_CONNECT (check_connect = 0); check_write = 0;
} }
else if (!NILP (wait_for_cell)) else if (!NILP (wait_for_cell))
{ {
Available = non_process_wait_mask; Available = non_process_wait_mask;
check_delay = 0; check_delay = 0;
IF_NON_BLOCKING_CONNECT (check_connect = 0); check_write = 0;
} }
else else
{ {
...@@ -4649,7 +4725,8 @@ wait_reading_process_output (int time_limit, int microsecs, int read_kbd, ...@@ -4649,7 +4725,8 @@ wait_reading_process_output (int time_limit, int microsecs, int read_kbd,
Available = non_keyboard_wait_mask; Available = non_keyboard_wait_mask;
else else
Available = input_wait_mask; Available = input_wait_mask;
IF_NON_BLOCKING_CONNECT (check_connect = (num_pending_connects > 0));