bug-commoncpp
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Patch: Add POLLNVAL to error values Serial::isPending tests


From: Conrad T. Pino
Subject: Patch: Add POLLNVAL to error values Serial::isPending tests
Date: Sun, 11 Sep 2005 03:23:15 -0700

This patch depends upon patches committed on "dev-bcb6-arm" branch
between revision tags "dev-bcb6-arm-0052" and "dev-bcb6-arm-0056".

This patch modifies the following files:

        ChangeLog
        src/serial.cpp

This patch is committed on "dev-bcb6-arm" branch between revision
tags "dev-bcb6-arm-0056" and "dev-bcb6-arm-0057".

Index: ChangeLog
===================================================================
RCS file: /cvsroot/gnutelephony/testing/commoncpp2/ChangeLog,v
retrieving revision 1.18.2.6
retrieving revision 1.18.2.7
diff -u -p -r1.18.2.6 -r1.18.2.7
--- ChangeLog   11 Sep 2005 07:04:20 -0000      1.18.2.6
+++ ChangeLog   11 Sep 2005 10:19:21 -0000      1.18.2.7
@@ -1,4 +1,5 @@
 From Common C++ 1.3.18 to 1.3.19
+- add POLLNVAL to error values Serial::isPending tests
 - add Serial::AnyPending enumeration and Serial::anyPending method
 - fix Win32 CreateEvent returns NULL on failure, not INVALID_HANDLE_VALUE
 - fix indentation error in WIN32 aRead method
Index: src/serial.cpp
===================================================================
RCS file: /cvsroot/gnutelephony/testing/commoncpp2/src/serial.cpp,v
retrieving revision 1.1.1.1.2.6
retrieving revision 1.1.1.1.2.7
diff -u -p -r1.1.1.1.2.6 -r1.1.1.1.2.7
--- src/serial.cpp      11 Sep 2005 07:04:20 -0000      1.1.1.1.2.6
+++ src/serial.cpp      11 Sep 2005 10:19:21 -0000      1.1.1.1.2.7
@@ -936,7 +936,13 @@ size_t Serial::getBufferSize(void)
        return maxsize;
 }
 
-#if !defined(WIN32) && !defined(HAVE_POLL)
+#ifndef        WIN32
+#ifdef HAVE_POLL
+static const unsigned int
+       pollMaskError = POLLERR | POLLHUP | POLLNVAL,
+       pollMaskInput = POLLIN | POLLPRI,
+       pollMaskOutput = POLLOUT;
+#else  //      ! HAVE_POLL
 static fd_set *fd_set_init(    fd_set *pfd_set, const HANDLE dev,
                                                        const 
Serial::AnyPending pendingMask,
                                                        const 
Serial::AnyPending pendingSelect
@@ -950,7 +956,8 @@ static fd_set *fd_set_init( fd_set *pfd_
 
        return NULL;
 }
-#endif // !defined(WIN32) && !defined(HAVE_POLL)
+#endif //      ! HAVE_POLL
+#endif //      ! WIN32
 
 Serial::AnyPending Serial::anyPending(const AnyPending pendingMask, const 
timeout_t timeout)
 {
@@ -1094,11 +1101,11 @@ Serial::AnyPending Serial::anyPending(co
                pfd.revents = 0;
                pfd.events = 0;
                if(pendingMask & anyPendingError)
-                       pfd.events |= POLLERR | POLLHUP;
+                       pfd.events |= pollMaskError;
                if(pendingMask & anyPendingInput)
-                       pfd.events |= POLLIN | POLLPRI;
+                       pfd.events |= pollMaskInput;
                if(pendingMask & anyPendingOutput)
-                       pfd.events |= POLLOUT;
+                       pfd.events |= pollMaskOutput;
 
                status = poll(&pfd, 1, polltimeout);
        } while(status == -1 && errno == EINTR);
@@ -1108,13 +1115,13 @@ Serial::AnyPending Serial::anyPending(co
        else
        if(status > 0)
        {
-               if(pfd.revents & (POLLERR | POLLHUP))
+               if(pfd.revents & pollMaskError)
                        isPending |= anyPendingError;
 
-               if(pfd.revents & (POLLIN | POLLPRI))
+               if(pfd.revents & pollMaskInput)
                        isPending |= anyPendingInput;
 
-               if(pfd.revents & POLLOUT)
+               if(pfd.revents & pollMaskOutput)
                        isPending |= anyPendingOutput;
        }
 #else  //      HAVE_POLL
@@ -1226,13 +1233,13 @@ bool Serial::isPending(Pending pending, 
        switch(pending)
        {
        case pendingInput:
-               pfd.events = POLLIN | POLLPRI;
+               pfd.events = pollMaskInput;
                break;
        case pendingOutput:
-               pfd.events = POLLOUT;
+               pfd.events = pollMaskOutput;
                break;
        case pendingError:
-               pfd.events = POLLERR | POLLHUP;
+               pfd.events = pollMaskError;
                break;
        }
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]