VirtualBox

Changeset 44429 in vbox


Ignore:
Timestamp:
Jan 28, 2013 3:16:34 PM (12 years ago)
Author:
vboxsync
Message:

IPRT/r3/socket.cpp: OS/2 has trouble sending buffers larger than 64KB, so join the windows code in limiting and split reads/writes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r3/socket.cpp

    r43363 r44429  
    111111/** How many pending connection. */
    112112#define RTTCP_SERVER_BACKLOG    10
     113
     114/* Limit read and write sizes on Windows and OS/2. */
     115#ifdef RT_OS_WINDOWS
     116# define RTSOCKET_MAX_WRITE     (INT_MAX / 2)
     117# define RTSOCKET_MAX_READ      (INT_MAX / 2)
     118#elif defined(RT_OS_OS2)
     119# define RTSOCKET_MAX_WRITE     0x10000
     120# define RTSOCKET_MAX_READ      0x10000
     121#endif
    113122
    114123
     
    855864    {
    856865        rtSocketErrorReset();
    857 #ifdef RT_OS_WINDOWS
    858         int    cbNow = cbToRead >= INT_MAX/2 ? INT_MAX/2 : (int)cbToRead;
     866#ifdef RTSOCKET_MAX_READ
     867        int    cbNow = cbToRead >= RTSOCKET_MAX_READ ? RTSOCKET_MAX_READ : (int)cbToRead;
    859868#else
    860869        size_t cbNow = cbToRead;
     
    922931    rtSocketErrorReset();
    923932    RTSOCKADDRUNION u;
    924 #ifdef RT_OS_WINDOWS
    925     int       cbNow  = cbToRead >= INT_MAX/2 ? INT_MAX/2 : (int)cbToRead;
     933#ifdef RTSOCKET_MAX_READ
     934    int       cbNow  = cbToRead >= RTSOCKET_MAX_READ ? RTSOCKET_MAX_READ : (int)cbToRead;
    926935    int       cbAddr = sizeof(u);
    927936#else
     
    969978     * Try write all at once.
    970979     */
    971 #ifdef RT_OS_WINDOWS
    972     int     cbNow     = cbBuffer >= INT_MAX / 2 ? INT_MAX / 2 : (int)cbBuffer;
     980#ifdef RTSOCKET_MAX_WRITE
     981    int     cbNow     = cbBuffer >= RTSOCKET_MAX_WRITE ? RTSOCKET_MAX_WRITE : (int)cbBuffer;
    973982#else
    974983    size_t  cbNow     = cbBuffer >= SSIZE_MAX   ? SSIZE_MAX   :      cbBuffer;
     
    9961005
    9971006            /* send */
    998 #ifdef RT_OS_WINDOWS
    999             cbNow = cbBuffer >= INT_MAX / 2 ? INT_MAX / 2 : (int)cbBuffer;
     1007#ifdef RTSOCKET_MAX_WRITE
     1008            cbNow = cbBuffer >= RTSOCKET_MAX_WRITE ? RTSOCKET_MAX_WRITE : (int)cbBuffer;
    10001009#else
    10011010            cbNow = cbBuffer >= SSIZE_MAX   ? SSIZE_MAX   :      cbBuffer;
     
    10581067     */
    10591068#ifdef RT_OS_WINDOWS
    1060     int     cbNow     = cbBuffer >= INT_MAX / 2 ? INT_MAX / 2 : (int)cbBuffer;
     1069    int     cbNow     = cbBuffer >= RTSOCKET_MAX_WRITE ? RTSOCKET_MAX_WRITE : (int)cbBuffer;
    10611070#else
    10621071    size_t  cbNow     = cbBuffer >= SSIZE_MAX   ? SSIZE_MAX   :      cbBuffer;
     
    12031212
    12041213    rtSocketErrorReset();
    1205 #ifdef RT_OS_WINDOWS
    1206     int cbNow = cbBuffer >= INT_MAX/2 ? INT_MAX/2 : (int)cbBuffer;
    1207 
     1214#ifdef RTSOCKET_MAX_READ
     1215    int    cbNow = cbBuffer >= RTSOCKET_MAX_WRITE ? RTSOCKET_MAX_WRITE : (int)cbBuffer;
     1216#else
     1217    size_t cbNow = cbBuffer;
     1218#endif
     1219
     1220#ifdef RT_OS_WINDOWS
    12081221    int cbRead = recv(pThis->hNative, (char *)pvBuffer, cbNow, MSG_NOSIGNAL);
    12091222    if (cbRead >= 0)
     
    12181231        rc = VINF_TRY_AGAIN;
    12191232#else
    1220     ssize_t cbRead = recv(pThis->hNative, pvBuffer, cbBuffer, MSG_NOSIGNAL);
     1233    ssize_t cbRead = recv(pThis->hNative, pvBuffer, cbNow, MSG_NOSIGNAL);
    12211234    if (cbRead >= 0)
    12221235        *pcbRead = cbRead;
     
    12511264
    12521265    rtSocketErrorReset();
    1253 #ifdef RT_OS_WINDOWS
    1254     int cbNow = RT_MIN((int)cbBuffer, INT_MAX/2);
    1255 
     1266#ifdef RTSOCKET_MAX_WRITE
     1267    int    cbNow = cbBuffer >= RTSOCKET_MAX_WRITE ? RTSOCKET_MAX_WRITE : (int)cbBuffer;
     1268#else
     1269    size_t cbNow = cbBuffer;
     1270#endif
     1271
     1272#ifdef RT_OS_WINDOWS
    12561273    int cbWritten = send(pThis->hNative, (const char *)pvBuffer, cbNow, MSG_NOSIGNAL);
    1257 
    12581274    if (cbWritten >= 0)
    12591275    {
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