From 60d38daf0a62b3de0f9b80f87b844fe67e69a424 Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Fri, 16 Aug 2013 12:40:06 +0200 Subject: [PATCH] Reset file descriptor set only, if necessary now. --- channels/serial/client/serial_main.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/channels/serial/client/serial_main.c b/channels/serial/client/serial_main.c index 80a5435bf..d34dd7a0a 100644 --- a/channels/serial/client/serial_main.c +++ b/channels/serial/client/serial_main.c @@ -340,21 +340,22 @@ static void* serial_thread_func(void* arg) if (WAIT_OBJECT_0 == status) break; - FD_ZERO(&serial->read_fds); - FD_ZERO(&serial->write_fds); - - serial->tv.tv_sec = 0; - serial->tv.tv_usec = 0; - serial->select_timeout = 0; - if (status == WAIT_OBJECT_0 + 1) { + FD_ZERO(&serial->read_fds); + FD_ZERO(&serial->write_fds); + + serial->tv.tv_sec = 0; + serial->tv.tv_usec = 0; + serial->select_timeout = 0; + if ((irp = (IRP*) Queue_Dequeue(serial->queue))) serial_process_irp(serial, irp); continue; } - serial_check_fds(serial); + if(serial->tty) + serial_check_fds(serial); } return NULL; @@ -680,6 +681,13 @@ static BOOL serial_check_fds(SERIAL_DEVICE* serial) if (list_size(serial->pending_irps) == 0) return 1; + FD_ZERO(&serial->read_fds); + FD_ZERO(&serial->write_fds); + + serial->tv.tv_sec = 0; + serial->tv.tv_usec = 0; + serial->select_timeout = 0; + serial_set_fds(serial); DEBUG_SVC("waiting %lu %lu", serial->tv.tv_sec, serial->tv.tv_usec);