mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-02-22 08:46:17 +08:00
* fhandler_serial.cc (fhandler_serial::tcflush): Simplify. Remove
read polling loop to avoid a hang with streaming devices.
This commit is contained in:
parent
992406a5ea
commit
97cb9b9de4
@ -1,3 +1,8 @@
|
|||||||
|
2003-12-11 Brian Ford <ford@vss.fsi.com>
|
||||||
|
|
||||||
|
* fhandler_serial.cc (fhandler_serial::tcflush): Simplify. Remove
|
||||||
|
read polling loop to avoid a hang with streaming devices.
|
||||||
|
|
||||||
2003-12-11 Christopher Faylor <cgf@redhat.com>
|
2003-12-11 Christopher Faylor <cgf@redhat.com>
|
||||||
|
|
||||||
* pinfo.cc (_pinfo::set_ctty): Correct stupid typo.
|
* pinfo.cc (_pinfo::set_ctty): Correct stupid typo.
|
||||||
|
@ -497,20 +497,29 @@ fhandler_serial::ioctl (unsigned int cmd, void *buffer)
|
|||||||
int
|
int
|
||||||
fhandler_serial::tcflush (int queue)
|
fhandler_serial::tcflush (int queue)
|
||||||
{
|
{
|
||||||
if (queue == TCOFLUSH || queue == TCIOFLUSH)
|
DWORD flags;
|
||||||
PurgeComm (get_handle (), PURGE_TXABORT | PURGE_TXCLEAR);
|
|
||||||
|
|
||||||
if (queue == TCIFLUSH || queue == TCIOFLUSH)
|
switch (queue)
|
||||||
/* Input flushing by polling until nothing turns up
|
|
||||||
(we stop after 1000 chars anyway) */
|
|
||||||
for (int max = 1000; max > 0; max--)
|
|
||||||
{
|
{
|
||||||
COMSTAT st;
|
case TCOFLUSH:
|
||||||
if (!PurgeComm (get_handle (), PURGE_RXABORT | PURGE_RXCLEAR))
|
flags = PURGE_TXABORT | PURGE_TXCLEAR;
|
||||||
break;
|
break;
|
||||||
low_priority_sleep (100);
|
case TCIFLUSH:
|
||||||
if (!ClearCommError (get_handle (), &ev, &st) || !st.cbInQue)
|
flags = PURGE_RXABORT | PURGE_RXCLEAR;
|
||||||
break;
|
break;
|
||||||
|
case TCIOFLUSH:
|
||||||
|
flags = PURGE_TXABORT | PURGE_TXCLEAR | PURGE_RXABORT | PURGE_RXCLEAR;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
termios_printf ("Invalid tcflush queue %d", queue);
|
||||||
|
set_errno (EINVAL);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!PurgeComm (get_handle (), flags))
|
||||||
|
{
|
||||||
|
__seterrno ();
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user