Changeset 31582 in vbox for trunk/src/VBox/Runtime
- Timestamp:
- Aug 11, 2010 9:33:47 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r3/socket.cpp
r31450 r31582 758 758 return rc; 759 759 760 /* 761 * Read loop. 762 */ 763 size_t cbRead = 0; 764 size_t cbToRead = cbBuffer; 765 for (;;) 766 { 767 rtSocketErrorReset(); 768 #ifdef RT_OS_WINDOWS 769 int cbNow = cbToRead >= INT_MAX/2 ? INT_MAX/2 : (int)cbToRead; 770 #else 771 size_t cbNow = cbToRead; 772 #endif 773 ssize_t cbBytesRead = recv(pThis->hNative, (char *)pvBuffer + cbRead, cbNow, MSG_NOSIGNAL); 774 if (cbBytesRead <= 0) 775 { 776 rc = rtSocketError(); 777 Assert(RT_FAILURE_NP(rc) || cbBytesRead == 0); 778 if (RT_SUCCESS_NP(rc)) 779 { 780 *pcbRead = 0; 781 rc = VINF_SUCCESS; 782 } 783 else 784 *pcbRead = cbRead; 785 break; 786 } 787 788 /* read more? */ 789 cbRead += cbBytesRead; 790 if (cbRead == cbBuffer) 791 { 792 *pcbRead = cbRead; 793 break; 794 } 795 796 /* next */ 797 cbToRead = cbBuffer - cbRead; 798 } 760 rtSocketErrorReset(); 761 #ifdef RT_OS_WINDOWS 762 int cbNow = cbBuffer >= INT_MAX/2 ? INT_MAX/2 : (int)cbBuffer; 763 #else 764 size_t cbNow = cbBuffer; 765 #endif 766 ssize_t cbRead = recv(pThis->hNative, pvBuffer, cbNow, MSG_NOSIGNAL); 767 if (cbRead >= 0) 768 *pcbRead = cbRead; 769 else if (errno == EAGAIN) 770 { 771 *pcbRead = 0; 772 rc = VINF_TRY_AGAIN; 773 } 774 else 775 rc = RTErrConvertFromErrno(errno); 799 776 800 777 rtSocketUnlock(pThis); … … 818 795 return rc; 819 796 820 /* 821 * Write loop. 822 */ 823 size_t cbWrite = 0; 824 size_t cbToWrite = cbBuffer; 825 for (;;) 826 { 827 rtSocketErrorReset(); 828 #ifdef RT_OS_WINDOWS 829 int cbNow = RT_MIN((int)cbToWrite, INT_MAX/2); 830 #else 831 size_t cbNow = cbToWrite; 832 #endif 833 ssize_t cbBytesWritten = send(pThis->hNative, (char *)pvBuffer + cbWrite, cbNow, MSG_NOSIGNAL); 834 if (cbBytesWritten < 0) 835 { 836 rc = rtSocketError(); 837 *pcbWritten = cbWrite; 838 break; 839 } 840 841 /* write more? */ 842 cbWrite += cbBytesWritten; 843 if (cbWrite == cbBuffer) 844 { 845 *pcbWritten = cbWrite; 846 break; 847 } 848 849 /* next */ 850 cbToWrite = cbBuffer - cbWrite; 851 } 797 rtSocketErrorReset(); 798 #ifdef RT_OS_WINDOWS 799 int cbNow = RT_MIN((int)cbBuffer, INT_MAX/2); 800 #else 801 size_t cbNow = cbBuffer; 802 #endif 803 ssize_t cbWritten = send(pThis->hNative, pvBuffer, cbNow, MSG_NOSIGNAL); 804 if (cbWritten >= 0) 805 *pcbWritten = cbWritten; 806 else if (errno == EAGAIN) 807 { 808 *pcbWritten = 0; 809 rc = VINF_TRY_AGAIN; 810 } 811 else 812 rc = RTErrConvertFromErrno(errno); 852 813 853 814 rtSocketUnlock(pThis);
Note:
See TracChangeset
for help on using the changeset viewer.