* fhandler_serial.cc (raw_read): Evaluate minchars taking the
vmin_ > ulen case into account. Simplify evaluating the bytes to read. Don't use bytes in Queue value from ClearCommError call in case vtime_ is > 0. Reformat GetOverlappedResult call. Simplify call to ReadFile.
This commit is contained in:
parent
0d8de89c9b
commit
30691bd756
|
@ -1,3 +1,10 @@
|
||||||
|
2006-08-17 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
|
* fhandler_serial.cc (raw_read): Evaluate minchars taking the
|
||||||
|
vmin_ > ulen case into account. Simplify evaluating the bytes to read.
|
||||||
|
Don't use bytes in Queue value from ClearCommError call in case vtime_
|
||||||
|
is > 0. Reformat GetOverlappedResult call. Simplify call to ReadFile.
|
||||||
|
|
||||||
2006-08-14 Corinna Vinschen <corinna@vinschen.de>
|
2006-08-14 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
* security.cc (subauth): Initialize user_token to NULL. Add comment.
|
* security.cc (subauth): Initialize user_token to NULL. Add comment.
|
||||||
|
|
|
@ -44,7 +44,7 @@ fhandler_serial::raw_read (void *ptr, size_t& ulen)
|
||||||
int tot;
|
int tot;
|
||||||
DWORD n;
|
DWORD n;
|
||||||
HANDLE w4[2];
|
HANDLE w4[2];
|
||||||
size_t minchars = vmin_ ?: ulen;
|
size_t minchars = vmin_ ? min (vmin_, ulen) : ulen;
|
||||||
|
|
||||||
w4[0] = io_status.hEvent;
|
w4[0] = io_status.hEvent;
|
||||||
w4[1] = signal_arrived;
|
w4[1] = signal_arrived;
|
||||||
|
@ -60,25 +60,18 @@ fhandler_serial::raw_read (void *ptr, size_t& ulen)
|
||||||
for (n = 0, tot = 0; ulen; ulen -= n, ptr = (char *) ptr + n)
|
for (n = 0, tot = 0; ulen; ulen -= n, ptr = (char *) ptr + n)
|
||||||
{
|
{
|
||||||
COMSTAT st;
|
COMSTAT st;
|
||||||
DWORD inq = 1;
|
DWORD inq = vmin_ ? minchars : vtime_ ? ulen : 1;
|
||||||
|
|
||||||
n = 0;
|
n = 0;
|
||||||
|
|
||||||
if (!vtime_ && !vmin_)
|
if (vtime_) // non-interruptible -- have to use kernel timeouts
|
||||||
inq = ulen;
|
|
||||||
else if (vtime_)
|
|
||||||
{
|
|
||||||
inq = ulen; // non-interruptible -- have to use kernel timeouts
|
|
||||||
// also note that this is not strictly correct.
|
|
||||||
// if vmin > ulen then things won't work right.
|
|
||||||
overlapped_armed = -1;
|
overlapped_armed = -1;
|
||||||
}
|
|
||||||
|
|
||||||
if (!ClearCommError (get_handle (), &ev, &st))
|
if (!ClearCommError (get_handle (), &ev, &st))
|
||||||
goto err;
|
goto err;
|
||||||
else if (ev)
|
else if (ev)
|
||||||
termios_printf ("error detected %x", ev);
|
termios_printf ("error detected %x", ev);
|
||||||
else if (st.cbInQue)
|
else if (st.cbInQue && !vtime_)
|
||||||
inq = st.cbInQue;
|
inq = st.cbInQue;
|
||||||
else if (!overlapped_armed)
|
else if (!overlapped_armed)
|
||||||
{
|
{
|
||||||
|
@ -98,7 +91,8 @@ fhandler_serial::raw_read (void *ptr, size_t& ulen)
|
||||||
switch (WaitForMultipleObjects (2, w4, FALSE, INFINITE))
|
switch (WaitForMultipleObjects (2, w4, FALSE, INFINITE))
|
||||||
{
|
{
|
||||||
case WAIT_OBJECT_0:
|
case WAIT_OBJECT_0:
|
||||||
if (!GetOverlappedResult (get_handle (), &io_status, &n, FALSE))
|
if (!GetOverlappedResult (get_handle (), &io_status, &n,
|
||||||
|
FALSE))
|
||||||
goto err;
|
goto err;
|
||||||
debug_printf ("n %d, ev %x", n, ev);
|
debug_printf ("n %d, ev %x", n, ev);
|
||||||
break;
|
break;
|
||||||
|
@ -119,7 +113,7 @@ fhandler_serial::raw_read (void *ptr, size_t& ulen)
|
||||||
if (inq > ulen)
|
if (inq > ulen)
|
||||||
inq = ulen;
|
inq = ulen;
|
||||||
debug_printf ("inq %d", inq);
|
debug_printf ("inq %d", inq);
|
||||||
if (ReadFile (get_handle (), ptr, min (inq, ulen), &n, &io_status))
|
if (ReadFile (get_handle (), ptr, inq, &n, &io_status))
|
||||||
/* Got something */;
|
/* Got something */;
|
||||||
else if (GetLastError () != ERROR_IO_PENDING)
|
else if (GetLastError () != ERROR_IO_PENDING)
|
||||||
goto err;
|
goto err;
|
||||||
|
|
Loading…
Reference in New Issue