Changeset 15509 in vbox
- Timestamp:
- Dec 15, 2008 3:10:55 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r3/tcp.cpp
r13837 r15509 146 146 * @returns iprt status code. 147 147 */ 148 DECLINLINE(int) rtTcpError( void)148 DECLINLINE(int) rtTcpError(bool fHErrNo) 149 149 { 150 150 #ifdef RT_OS_WINDOWS 151 151 return RTErrConvertFromWin32(WSAGetLastError()); 152 152 #else 153 return RTErrConvertFromErrno(errno); 153 if (fHErrNo) 154 { 155 switch (h_errno) 156 { 157 case HOST_NOT_FOUND: 158 return VERR_NET_HOST_NOT_FOUND; 159 break; 160 case NO_DATA: 161 return VERR_NET_ADDRESS_NOT_AVAILABLE; 162 break; 163 case NO_RECOVERY: 164 return VERR_IO_GEN_FAILURE; 165 break; 166 case TRY_AGAIN: 167 return VERR_TRY_AGAIN; 168 break; 169 default: 170 return VERR_UNRESOLVED_ERROR; 171 } 172 } 173 else 174 return RTErrConvertFromErrno(errno); 154 175 #endif 155 176 } … … 317 338 if (!pHostEnt) 318 339 { 319 rc = rtTcpError( );340 rc = rtTcpError(true); 320 341 AssertMsgFailed(("Could not get host address rc=%Rrc\n", rc)); 321 342 return rc; … … 376 397 else 377 398 { 378 rc = rtTcpError( );399 rc = rtTcpError(false); 379 400 AssertMsgFailed(("listen() %Rrc\n", rc)); 380 401 } … … 382 403 else 383 404 { 384 rc = rtTcpError( );405 rc = rtTcpError(false); 385 406 } 386 407 } 387 408 else 388 409 { 389 rc = rtTcpError( );410 rc = rtTcpError(false); 390 411 AssertMsgFailed(("setsockopt() %Rrc\n", rc)); 391 412 } … … 394 415 else 395 416 { 396 rc = rtTcpError( );417 rc = rtTcpError(false); 397 418 AssertMsgFailed(("socket() %Rrc\n", rc)); 398 419 } … … 722 743 ssize_t cbBytesRead = recv(Sock, (char *)pvBuffer + cbRead, cbToRead, MSG_NOSIGNAL); 723 744 if (cbBytesRead < 0) 724 return rtTcpError( );725 if (cbBytesRead == 0 && rtTcpError( ))726 return rtTcpError( );745 return rtTcpError(false); 746 if (cbBytesRead == 0 && rtTcpError(false)) 747 return rtTcpError(false); 727 748 if (pcbRead) 728 749 { … … 751 772 ssize_t cbWritten = send(Sock, (const char *)pvBuffer, cbBuffer, MSG_NOSIGNAL); 752 773 if (cbWritten < 0) 753 return rtTcpError( );774 return rtTcpError(false); 754 775 AssertMsg(cbBuffer >= (size_t)cbWritten, ("Wrote more than we requested!!! cbWritten=%d cbBuffer=%d rtTcpError()=%d\n", 755 cbWritten, cbBuffer, rtTcpError( )));776 cbWritten, cbBuffer, rtTcpError(false))); 756 777 cbBuffer -= cbWritten; 757 778 pvBuffer = (char *)pvBuffer + cbWritten; … … 795 816 if (rc == 0) 796 817 return VERR_TIMEOUT; 797 return rtTcpError( );818 return rtTcpError(false); 798 819 } 799 820 … … 835 856 if (!pHostEnt) 836 857 { 837 rc = rtTcpError( );858 rc = rtTcpError(false); 838 859 AssertMsgFailed(("Could not resolve '%s', rc=%Rrc\n", pszAddress, rc)); 839 860 return rc; … … 856 877 return VINF_SUCCESS; 857 878 } 858 rc = rtTcpError( );879 rc = rtTcpError(false); 859 880 rtTcpClose(Sock, "RTTcpClientConnect"); 860 881 } 861 882 else 862 rc = rtTcpError( );883 rc = rtTcpError(false); 863 884 return rc; 864 885 } … … 890 911 if (!rc) 891 912 return VINF_SUCCESS; 892 rc = rtTcpError( );913 rc = rtTcpError(false); 893 914 AssertMsgFailed(("\"%s\": close(%d) -> %Rrc\n", pszMsg, Sock, rc)); 894 915 return rc;
Note:
See TracChangeset
for help on using the changeset viewer.