* fhandler_serial.cc (fhandler_serial::raw_read): Handle non-blocking

case more thoroughly.
This commit is contained in:
Corinna Vinschen 2011-07-13 18:59:41 +00:00
parent b4efd5410c
commit f55fc99c77
2 changed files with 26 additions and 1 deletions

View File

@ -1,3 +1,8 @@
2011-07-13 Corinna Vinschen <corinna@vinschen.de>
* fhandler_serial.cc (fhandler_serial::raw_read): Handle non-blocking
case more thoroughly.
2011-07-13 Christopher Faylor <me.cygwin2011@cgf.cx>
* setup_handler (setup_handler): Change break to goto out, missed in

View File

@ -81,7 +81,17 @@ fhandler_serial::raw_read (void *ptr, size_t& ulen)
}
else if (GetLastError () != ERROR_IO_PENDING)
goto err;
else if (!is_nonblocking ())
else if (is_nonblocking ())
{
PurgeComm (get_handle (), PURGE_RXABORT);
if (tot == 0)
{
tot = -1;
set_errno (EAGAIN);
}
goto out;
}
else
{
HANDLE w4[3] = { io_status.hEvent, signal_arrived,
pthread::get_cancel_event () };
@ -124,6 +134,16 @@ restart:
/* Got something */;
else if (GetLastError () != ERROR_IO_PENDING)
goto err;
else if (is_nonblocking ())
{
PurgeComm (get_handle (), PURGE_RXABORT);
if (tot == 0)
{
tot = -1;
set_errno (EAGAIN);
}
goto out;
}
else if (!GetOverlappedResult (get_handle (), &io_status, &n, TRUE))
goto err;