public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
* [newlib-cygwin] Cygwin: serial: select: fix WaitCommEvent request
@ 2020-03-26 11:26 Corinna Vinschen
0 siblings, 0 replies; only message in thread
From: Corinna Vinschen @ 2020-03-26 11:26 UTC (permalink / raw)
To: cygwin-cvs
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=3a74630f7542c12f58f1a23d696b6b5f647b70d4
commit 3a74630f7542c12f58f1a23d696b6b5f647b70d4
Author: Corinna Vinschen <corinna@vinschen.de>
Date: Mon Mar 23 13:08:32 2020 +0100
Cygwin: serial: select: fix WaitCommEvent request
- make sure event object is reset
- set read_ready to true if WaitCommEvent returns success
- improve debugging
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Diff:
---
winsup/cygwin/select.cc | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/winsup/cygwin/select.cc b/winsup/cygwin/select.cc
index e11f5850a..07e0d82fb 100644
--- a/winsup/cygwin/select.cc
+++ b/winsup/cygwin/select.cc
@@ -1457,7 +1457,7 @@ peek_serial (select_record *s, bool)
if (!ClearCommError (h, &io_err, &st))
{
- debug_printf ("ClearCommError %E");
+ select_printf ("ClearCommError %E");
goto err;
}
if (st.cbInQue)
@@ -1493,6 +1493,7 @@ serial_read_cleanup (select_record *s, select_stuff *stuff)
}
}
+static int
verify_serial (select_record *me, fd_set *rfds, fd_set *wfds, fd_set *efds)
{
return peek_serial (me, true);
@@ -1513,9 +1514,16 @@ fhandler_serial::select_read (select_stuff *ss)
See: http://cygwin.com/ml/cygwin/2009-01/msg00667.html */
SetCommMask (get_handle_cyg (), 0);
SetCommMask (get_handle_cyg (), EV_RXCHAR);
- if (!WaitCommEvent (get_handle_cyg (), &event, &io_status)
- && GetLastError () == ERROR_IO_PENDING)
- s->h = io_status.hEvent;
+ ResetEvent (io_status.hEvent);
+ if (!WaitCommEvent (get_handle_cyg (), &event, &io_status))
+ {
+ if (GetLastError () == ERROR_IO_PENDING)
+ s->h = io_status.hEvent;
+ else
+ select_printf ("WaitCommEvent %E");
+ }
+ else
+ s->read_ready = true;
return s;
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-03-26 11:26 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-26 11:26 [newlib-cygwin] Cygwin: serial: select: fix WaitCommEvent request Corinna Vinschen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).