VirtualBox

Ignore:
Timestamp:
Jun 10, 2014 1:33:55 AM (11 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
94289
Message:

NAT/Net: Hide checking for transient errors (EWOULDBLOCK &co) in an
inline function to prevent #ifdef sprawl.

Location:
trunk/src/VBox/NetworkServices/NAT
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/NetworkServices/NAT/pxtcp.c

    r51581 r51584  
    14851485             * them out here.
    14861486             */
    1487             if (sockerr == EWOULDBLOCK
    1488                 || sockerr == EAGAIN
    1489                 || sockerr == ENOBUFS
    1490                 || sockerr == ENOMEM
    1491                 || sockerr == EINTR)
    1492             {
     1487            if (proxy_error_is_transient(sockerr)) {
    14931488                sockerr = 0;
    14941489            }
     
    17751770 *
    17761771 * Returns zero if nothing was read, either because buffer is full, or
    1777  * if no data is available (EAGAIN, EINTR &c).
     1772 * if no data is available (EWOULDBLOCK, EINTR &c).
    17781773 *
    17791774 * Returns -errno on real socket errors.
     
    18561851        int sockerr = SOCKERRNO();
    18571852
    1858         if (sockerr == EWOULDBLOCK || sockerr == EAGAIN || sockerr == EINTR) {
     1853        if (proxy_error_is_transient(sockerr)) {
    18591854            /* haven't read anything, just return */
    18601855            DPRINTF2(("pxtcp %p: sock %d read cancelled\n",
  • trunk/src/VBox/NetworkServices/NAT/winutils.h

    r51583 r51584  
    165165#  define IOVEC_SET_LEN(iov, l) ((iov).iov_len = (l))
    166166# endif
     167
     168DECLINLINE(int)
     169proxy_error_is_transient(int error)
     170{
     171# if !defined(RT_OS_WINDOWS)
     172    return error == EWOULDBLOCK
     173#  if EAGAIN != EWOULDBLOCK
     174        || error == EAGAIN
     175#  endif
     176        || error == EINTR
     177        || error == ENOBUFS
     178        || error == ENOMEM;
     179# else
     180    return error == WSAEWOULDBLOCK
     181        || error == WSAEINTR    /* NB: we don't redefine EINTR above */
     182        || error == WSAENOBUFS;
     183# endif
     184}
     185
    167186#endif
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette