winpr-comm: fixed _purge(), eventfd_read() and eventfd_write() just return a error code, not a number of bytes read or written

This commit is contained in:
Emmanuel Ledoux 2014-05-28 19:10:01 +02:00 committed by Emmanuel Ledoux
parent 85343a435a
commit f26c7ee498
2 changed files with 4 additions and 20 deletions

View File

@ -259,10 +259,8 @@ BOOL CommReadFile(HANDLE hDevice, LPVOID lpBuffer, DWORD nNumberOfBytesToRead,
if (FD_ISSET(pComm->fd_read_event, &read_set))
{
eventfd_t event = 0;
int nbRead;
nbRead = eventfd_read(pComm->fd_read_event, &event);
if (nbRead < 0)
if (eventfd_read(pComm->fd_read_event, &event) < 0)
{
if (errno == EAGAIN)
{
@ -278,8 +276,6 @@ BOOL CommReadFile(HANDLE hDevice, LPVOID lpBuffer, DWORD nNumberOfBytesToRead,
assert(errno == EAGAIN);
}
assert(nbRead == sizeof(eventfd_t));
if (event == FREERDP_PURGE_RXABORT)
{
SetLastError(ERROR_CANCELLED);
@ -437,10 +433,8 @@ BOOL CommWriteFile(HANDLE hDevice, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite
if (FD_ISSET(pComm->fd_write_event, &event_set))
{
eventfd_t event = 0;
int nbRead;
nbRead = eventfd_read(pComm->fd_write_event, &event);
if (nbRead < 0)
if (eventfd_read(pComm->fd_write_event, &event) < 0)
{
if (errno == EAGAIN)
{
@ -456,8 +450,6 @@ BOOL CommWriteFile(HANDLE hDevice, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite
assert(errno == EAGAIN);
}
assert(nbRead == sizeof(eventfd_t));
if (event == FREERDP_PURGE_TXABORT)
{
SetLastError(ERROR_CANCELLED);

View File

@ -1123,9 +1123,7 @@ static BOOL _purge(WINPR_COMM *pComm, const ULONG *pPurgeMask)
{
/* Purges all write (IRP_MJ_WRITE) requests. */
int nbWritten;
if ((nbWritten = eventfd_write(pComm->fd_write_event, FREERDP_PURGE_TXABORT)) < 0)
if (eventfd_write(pComm->fd_write_event, FREERDP_PURGE_TXABORT) < 0)
{
if (errno != EAGAIN)
{
@ -1134,17 +1132,13 @@ static BOOL _purge(WINPR_COMM *pComm, const ULONG *pPurgeMask)
assert(errno == EAGAIN); /* no reader <=> no pending IRP_MJ_WRITE */
}
assert(nbWritten == sizeof(eventfd_t));
}
if (*pPurgeMask & SERIAL_PURGE_RXABORT)
{
/* Purges all read (IRP_MJ_READ) requests. */
int nbWritten;
if ((nbWritten = eventfd_write(pComm->fd_read_event, FREERDP_PURGE_RXABORT)) < 0)
if (eventfd_write(pComm->fd_read_event, FREERDP_PURGE_RXABORT) < 0)
{
if (errno != EAGAIN)
{
@ -1153,8 +1147,6 @@ static BOOL _purge(WINPR_COMM *pComm, const ULONG *pPurgeMask)
assert(errno == EAGAIN); /* no reader <=> no pending IRP_MJ_READ */
}
assert(nbWritten == sizeof(eventfd_t));
}
if (*pPurgeMask & SERIAL_PURGE_TXCLEAR)