VirtualBox

Changeset 54895 in vbox


Ignore:
Timestamp:
Mar 21, 2015 9:39:24 PM (10 years ago)
Author:
vboxsync
Message:

NAT/Network: group windows and unix code to make socket non-blocking
into one #if/#elif.

File:
1 edited

Legend:

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

    r54124 r54895  
    318318    }
    319319
    320 #if !defined(SOCK_NONBLOCK) && !defined(RT_OS_WINDOWS)
    321     {
    322         int sflags;
    323 
    324         sflags = fcntl(s, F_GETFL, 0);
    325         if (sflags < 0) {
    326             DPRINTF(("F_GETFL: %R[sockerr]\n", SOCKERRNO()));
    327             closesocket(s);
    328             return INVALID_SOCKET;
    329         }
    330 
    331         status = fcntl(s, F_SETFL, sflags | O_NONBLOCK);
    332         if (status < 0) {
    333             DPRINTF(("O_NONBLOCK: %R[sockerr]\n", SOCKERRNO()));
    334             closesocket(s);
    335             return INVALID_SOCKET;
    336         }
    337     }
    338 #endif
    339 
    340 #if !defined(SOCK_NOSIGPIPE) && defined(SO_NOSIGPIPE)
    341     if (stype == SOCK_STREAM) {
    342         int on = 1;
    343         const socklen_t onlen = sizeof(on);
    344 
    345         status = setsockopt(s, SOL_SOCKET, SO_NOSIGPIPE, &on, onlen);
    346         if (status < 0) {
    347             DPRINTF(("SO_NOSIGPIPE: %R[sockerr]\n", SOCKERRNO()));
    348             closesocket(s);
    349             return INVALID_SOCKET;
    350         }
    351     }
    352 #endif
    353 
    354320#if defined(RT_OS_WINDOWS)
    355321    {
     
    358324        if (status == SOCKET_ERROR) {
    359325            DPRINTF(("FIONBIO: %R[sockerr]\n", SOCKERRNO()));
     326            closesocket(s);
     327            return INVALID_SOCKET;
     328        }
     329    }
     330#elif !defined(SOCK_NONBLOCK)
     331    {
     332        int sflags;
     333
     334        sflags = fcntl(s, F_GETFL, 0);
     335        if (sflags < 0) {
     336            DPRINTF(("F_GETFL: %R[sockerr]\n", SOCKERRNO()));
     337            closesocket(s);
     338            return INVALID_SOCKET;
     339        }
     340
     341        status = fcntl(s, F_SETFL, sflags | O_NONBLOCK);
     342        if (status < 0) {
     343            DPRINTF(("O_NONBLOCK: %R[sockerr]\n", SOCKERRNO()));
     344            closesocket(s);
     345            return INVALID_SOCKET;
     346        }
     347    }
     348#endif
     349
     350#if !defined(SOCK_NOSIGPIPE) && defined(SO_NOSIGPIPE)
     351    if (stype == SOCK_STREAM) {
     352        int on = 1;
     353        const socklen_t onlen = sizeof(on);
     354
     355        status = setsockopt(s, SOL_SOCKET, SO_NOSIGPIPE, &on, onlen);
     356        if (status < 0) {
     357            DPRINTF(("SO_NOSIGPIPE: %R[sockerr]\n", SOCKERRNO()));
    360358            closesocket(s);
    361359            return INVALID_SOCKET;
Note: See TracChangeset for help on using the changeset viewer.

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