Changeset 31450 in vbox for trunk/src/VBox/Runtime/r3/socket.cpp
- Timestamp:
- Aug 8, 2010 12:51:20 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r3/socket.cpp
r31212 r31450 873 873 return rc; 874 874 875 /* 876 * Construct message descriptor (translate pSgBuf) and send it. 877 */ 875 unsigned cSegsToSend = 0; 878 876 rc = VERR_NO_TMP_MEMORY; 879 877 #ifdef RT_OS_WINDOWS 880 AssertCompileSize(WSABUF, sizeof(RTSGSEG)); 881 AssertCompileMemberSize(WSABUF, buf, RT_SIZEOFMEMB(RTSGSEG, pvSeg)); 882 883 LPWSABUF paMsg = (LPWSABUF)RTMemTmpAllocZ(pSgBuf->cSegs * sizeof(WSABUF)); 878 LPWSABUF paMsg = NULL; 879 880 RTSgBufMapToNative(paMsg, pSgBuf, WSABUF, buf, char *, len, u_long, cSegsToSend); 884 881 if (paMsg) 885 882 { 886 for (unsigned i = 0; i < pSgBuf->cSegs; i++)887 {888 paMsg[i].buf = (char *)pSgBuf->paSegs[i].pvSeg;889 paMsg[i].len = (u_long)pSgBuf->paSegs[i].cbSeg;890 }891 892 883 DWORD dwSent = 0; 893 int hrc = WSASend(pThis->hNative, paMsg, pSgBuf->cSegs, &dwSent,884 int hrc = WSASend(pThis->hNative, paMsg, cSegsToSend, &dwSent, 894 885 MSG_NOSIGNAL, NULL, NULL); 895 886 if (!hrc) 896 887 rc = VINF_SUCCESS; 897 /** @todo check for incomplete writes */898 888 else 899 889 rc = rtSocketError(); … … 905 895 906 896 #else /* !RT_OS_WINDOWS */ 907 AssertCompileSize(struct iovec, sizeof(RTSGSEG)); 908 AssertCompileMemberSize(struct iovec, iov_base, RT_SIZEOFMEMB(RTSGSEG, pvSeg)); 909 AssertCompileMemberSize(struct iovec, iov_len, RT_SIZEOFMEMB(RTSGSEG, cbSeg)); 910 911 struct iovec *paMsg = (struct iovec *)RTMemTmpAllocZ(pSgBuf->cSegs * sizeof(struct iovec)); 897 struct iovec *paMsg = NULL; 898 899 RTSgBufMapToNative(paMsg, pSgBuf, struct iovec, iov_base, void *, iov_len, size_t, cSegsToSend); 912 900 if (paMsg) 913 901 { 914 for (unsigned i = 0; i < pSgBuf->cSegs; i++)915 {916 paMsg[i].iov_base = pSgBuf->paSegs[i].pvSeg;917 paMsg[i].iov_len = pSgBuf->paSegs[i].cbSeg;918 }919 920 902 struct msghdr msgHdr; 921 903 RT_ZERO(msgHdr); 922 904 msgHdr.msg_iov = paMsg; 923 msgHdr.msg_iovlen = pSgBuf->cSegs;905 msgHdr.msg_iovlen = cSegsToSend; 924 906 ssize_t cbWritten = sendmsg(pThis->hNative, &msgHdr, MSG_NOSIGNAL); 925 907 if (RT_LIKELY(cbWritten >= 0)) 908 { 926 909 rc = VINF_SUCCESS; 927 /** @todo check for incomplete writes */ 910 *pcbWritten = cbWritten; 911 } 928 912 else 929 913 rc = rtSocketError(); 930 931 *pcbWritten = cbWritten;932 914 933 915 RTMemTmpFree(paMsg);
Note:
See TracChangeset
for help on using the changeset viewer.