VirtualBox

Changeset 30272 in vbox for trunk/src


Ignore:
Timestamp:
Jun 17, 2010 7:54:20 AM (15 years ago)
Author:
vboxsync
Message:

Runtime/socket: there is no sendmsg equivalent on all Windows versions, must cop
y to single buffer

File:
1 edited

Legend:

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

    r30270 r30272  
    596596    {
    597597#ifdef RT_OS_WINDOWS
     598# if 0 /* WSASendMsg is Vista+, so not an option */
    598599        AssertCompileSize(WSABUF, sizeof(RTSGSEG));
    599600        AssertCompileMemberSize(WSABUF, buf, RT_SIZEOFMEMB(RTSGSEG, pvSeg));
     
    623624        else
    624625            cbWritten = -1;
     626        RTMemTmpFree(paMsg);
     627# else /* 1 */
     628        /* Portable but inefficient: copy everything to a single buffer and
     629         * use send(). Annoying that WSASendMsg() is so "new". */
     630        int cbBuf = 0;
     631        for (unsigned i = 0; i < pSgBuf->cSeg; i++)
     632        {
     633            cbBuf += pSgBuf->pcaSeg[i].cbSeg
     634            AssertBreakStmt(cbBuf, rc = VERR_BUFFER_OVERFLOW);
     635        }
     636
     637        void *pBuf = RTMemTmpAlloc(cbBuf);
     638        AssertPtrBreakStmt(pBuf, rc = VERR_NO_MEMORY);
     639        char *p = (char *)pBuf;
     640        for (unsigned i = 0; i < pSgBuf->cSeg; i++)
     641        {
     642            memcpy(p, pSgBuf->pcaSeg[i].pvSeg, pSgBuf->pcaSeg[i].cbSeg);
     643            p += pSgBuf->pcaSeg[i].cbSeg;
     644        }
     645
     646        ssize_t cbWritten = send(pThis->hNative, (const char *)pBuf, cbBuf, MSG_NOSIGNAL);
     647        RTMemTmpFree(pBuf);
     648# endif /* 1 */
    625649#else
    626650        AssertCompileSize(struct iovec, sizeof(RTSGSEG));
     
    641665        msgHdr.msg_iovlen = pSgBuf->cSeg;
    642666        ssize_t cbWritten = sendmsg(pThis->hNative, &msgHdr, MSG_NOSIGNAL);
    643 #endif
    644 
    645667        RTMemTmpFree(paMsg);
     668#endif
     669
    646670        if (RT_LIKELY(cbWritten >= 0))
    647671            rc = VINF_SUCCESS;
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