VirtualBox

Changeset 38090 in vbox


Ignore:
Timestamp:
Jul 21, 2011 11:09:02 AM (14 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
73039
Message:

NAT: next attempt to handle FD_CONNECT right, under NAT_CONNETCTION_EXPERIMENT umbrella.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Network/slirp/slirp.c

    r38068 r38090  
    10441044}
    10451045
     1046
     1047static bool slirpConnectOrWrite(PNATState pData, struct socket *so, bool fConnectOnly)
     1048{
     1049    int ret;
     1050    LogFlowFunc(("ENTER: so:%R[natsock], fConnectOnly:%RTbool\n", so, fConnectOnly));
     1051    /*
     1052     * Check for non-blocking, still-connecting sockets
     1053     */
     1054    if (so->so_state & SS_ISFCONNECTING)
     1055    {
     1056        Log2(("connecting %R[natsock] catched\n", so));
     1057        /* Connected */
     1058        so->so_state &= ~SS_ISFCONNECTING;
     1059
     1060        /*
     1061         * This should be probably guarded by PROBE_CONN too. Anyway,
     1062         * we disable it on OS/2 because the below send call returns
     1063         * EFAULT which causes the opened TCP socket to close right
     1064         * after it has been opened and connected.
     1065         */
     1066#ifndef RT_OS_OS2
     1067    ret = send(so->s, (const char *)&ret, 0, 0);
     1068    if (ret < 0)
     1069    {
     1070        /* XXXXX Must fix, zero bytes is a NOP */
     1071        if (   errno == EAGAIN
     1072            || errno == EWOULDBLOCK
     1073            || errno == EINPROGRESS
     1074            || errno == ENOTCONN)
     1075        {
     1076            LogFlowFunc(("LEAVE: true"));
     1077            return false;
     1078        }
     1079
     1080        /* else failed */
     1081        so->so_state = SS_NOFDREF;
     1082    }
     1083    /* else so->so_state &= ~SS_ISFCONNECTING; */
     1084#endif
     1085
     1086        /*
     1087         * Continue tcp_input
     1088         */
     1089        TCP_INPUT(pData, (struct mbuf *)NULL, sizeof(struct ip), so);
     1090        /* continue; */
     1091    }
     1092    else if (!fConnectOnly)
     1093        SOWRITE(ret, pData, so);
     1094    /*
     1095     * XXX If we wrote something (a lot), there could be the need
     1096     * for a window update. In the worst case, the remote will send
     1097     * a window probe to get things going again.
     1098     */
     1099    LogFlowFunc(("LEAVE: true"));
     1100    return true;
     1101}
     1102
    10461103#if defined(RT_OS_WINDOWS)
    10471104void slirp_select_poll(PNATState pData, int fTimeout, int fIcmp)
     
    11951252            if (WIN_CHECK_FD_SET(so, NetworkEvents, connectfds))
    11961253            {
    1197                 TCP_ENGAGE_EVENT2(so, readfds, acceptds);
    1198                 goto dont_read_now;
     1254                /* Finish connection first */
     1255                /* should we ignore return value? */
     1256                bool fRet = slirpConnectOrWrite(pData, so, true);
     1257                LogFunc(("fRet:%RTbool\n", fRet));
    11991258            }
    12001259#endif
     
    12131272            if (RT_LIKELY(ret > 0))
    12141273                TCP_OUTPUT(pData, sototcpcb(so));
    1215 #ifdef NAT_CONNECT_EXPERIMENT
    1216 dont_read_now:;
    1217 #endif
    12181274        }
    12191275
     
    12591315            )
    12601316        {
    1261             /*
    1262              * Check for non-blocking, still-connecting sockets
    1263              */
    1264             if (so->so_state & SS_ISFCONNECTING)
    1265             {
    1266                 Log2(("connecting %R[natsock] catched\n", so));
    1267                 /* Connected */
    1268                 so->so_state &= ~SS_ISFCONNECTING;
    1269 
    1270                 /*
    1271                  * This should be probably guarded by PROBE_CONN too. Anyway,
    1272                  * we disable it on OS/2 because the below send call returns
    1273                  * EFAULT which causes the opened TCP socket to close right
    1274                  * after it has been opened and connected.
    1275                  */
    1276 #ifndef RT_OS_OS2
    1277                 ret = send(so->s, (const char *)&ret, 0, 0);
    1278                 if (ret < 0)
    1279                 {
    1280                     /* XXXXX Must fix, zero bytes is a NOP */
    1281                     if (   errno == EAGAIN
    1282                         || errno == EWOULDBLOCK
    1283                         || errno == EINPROGRESS
    1284                         || errno == ENOTCONN)
    1285                         CONTINUE(tcp);
    1286 
    1287                     /* else failed */
    1288                     so->so_state = SS_NOFDREF;
    1289                 }
    1290                 /* else so->so_state &= ~SS_ISFCONNECTING; */
    1291 #endif
    1292 
    1293                 /*
    1294                  * Continue tcp_input
    1295                  */
    1296                 TCP_INPUT(pData, (struct mbuf *)NULL, sizeof(struct ip), so);
    1297                 /* continue; */
    1298             }
    1299             else
    1300                 SOWRITE(ret, pData, so);
    1301             /*
    1302              * XXX If we wrote something (a lot), there could be the need
    1303              * for a window update. In the worst case, the remote will send
    1304              * a window probe to get things going again.
    1305              */
     1317            if(!slirpConnectOrWrite(pData, so, false))
     1318                CONTINUE(tcp);
    13061319        }
    13071320
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