- Timestamp:
- Feb 25, 2010 11:56:52 AM (15 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/pipe.h
r26774 r26784 118 118 * @returns IPRT status code. 119 119 * @retval VERR_WRONG_ORDER if racing a call to RTPipeWriteBlocking. 120 * @retval VERR_BROKEN_PIPE if the remote party has disconnected. 120 * @retval VERR_BROKEN_PIPE if the remote party has disconnected. Does not 121 * trigger when @a cbToWrite is 0. 121 122 * @retval VINF_TRY_AGAIN if no data was written. @a *pcbWritten will be set 122 123 * to 0. … … 135 136 * @returns IPRT status code. 136 137 * @retval VERR_WRONG_ORDER if racing a call to RTPipeWrite. 137 * @retval VERR_BROKEN_PIPE if the remote party has disconnected. 138 * @retval VERR_BROKEN_PIPE if the remote party has disconnected. Does not 139 * trigger when @a cbToWrite is 0. 138 140 * @retval VERR_ACCESS_DENIED if it's a read pipe. 139 141 * -
trunk/src/VBox/Runtime/r3/posix/pipe-posix.cpp
r26774 r26784 378 378 if (RT_SUCCESS(rc)) 379 379 { 380 do380 while (cbToRead > 0) 381 381 { 382 382 ssize_t cbRead = read(pThis->fd, pvBuf, RT_MIN(cbToRead, SSIZE_MAX)); … … 395 395 pvBuf = (char *)pvBuf + cbRead; 396 396 cbToRead -= cbRead; 397 } while (cbToRead > 0);397 } 398 398 399 399 ASMAtomicDecU32(&pThis->u32State); … … 415 415 if (RT_SUCCESS(rc)) 416 416 { 417 ssize_t cbWritten = write(pThis->fd, pvBuf, RT_MIN(cbToWrite, SSIZE_MAX)); 418 if (cbWritten >= 0) 419 *pcbWritten = cbWritten; 420 else if (errno == EAGAIN) 421 { 422 *pcbWritten = 0;; 423 rc = VINF_TRY_AGAIN; 417 if (cbToWrite) 418 { 419 ssize_t cbWritten = write(pThis->fd, pvBuf, RT_MIN(cbToWrite, SSIZE_MAX)); 420 if (cbWritten >= 0) 421 *pcbWritten = cbWritten; 422 else if (errno == EAGAIN) 423 { 424 *pcbWritten = 0;; 425 rc = VINF_TRY_AGAIN; 426 } 427 else 428 rc = RTErrConvertFromErrno(errno); 424 429 } 425 430 else 426 rc = RTErrConvertFromErrno(errno);431 *pcbWritten = 0; 427 432 428 433 ASMAtomicDecU32(&pThis->u32State); … … 471 476 472 477 if (fsync(pThis->fd)) 478 { 479 if (errno == EINVAL || errno == ENOTSUP) 480 return VERR_NOT_SUPPORTED; 473 481 return RTErrConvertFromErrno(errno); 482 } 474 483 return VINF_SUCCESS; 475 484 } -
trunk/src/VBox/Runtime/testcase/tstRTPipe.cpp
r26775 r26784 140 140 RTTESTI_CHECK_RC_RETV(RTPipeCreate(&hPipeR, &hPipeW, RTPIPE_C_INHERIT_READ | RTPIPE_C_INHERIT_WRITE), VINF_SUCCESS); 141 141 int rc = RTPipeFlush(hPipeW); 142 RTTESTI_CHECK (rc == VERR_NOT_SUPPORTED || rc == VINF_SUCCESS);142 RTTESTI_CHECK_MSG(rc == VERR_NOT_SUPPORTED || rc == VINF_SUCCESS, ("%Rrc\n", rc)); 143 143 RTTESTI_CHECK_RC_RETV(RTPipeClose(hPipeR), VINF_SUCCESS); 144 144 RTTESTI_CHECK_RC_RETV(RTPipeClose(hPipeW), VINF_SUCCESS); … … 223 223 RTTESTI_CHECK_RC_RETV(RTPipeClose(hPipeR), VINF_SUCCESS); 224 224 cbWritten = ~(size_t)2; 225 RTTESTI_CHECK_RC(RTPipeWrite(hPipeW, "", 0, &cbWritten), V ERR_BROKEN_PIPE);226 RTTESTI_CHECK(cbWritten == ~(size_t)2);225 RTTESTI_CHECK_RC(RTPipeWrite(hPipeW, "", 0, &cbWritten), VINF_SUCCESS); 226 RTTESTI_CHECK(cbWritten == 0); 227 227 cbWritten = ~(size_t)2; 228 228 RTTESTI_CHECK_RC(RTPipeWrite(hPipeW, "4", 1, &cbWritten), VERR_BROKEN_PIPE); … … 233 233 RTTESTI_CHECK_RC_RETV(RTPipeClose(hPipeW), VINF_SUCCESS); 234 234 cbRead = ~(size_t)0; 235 RTTESTI_CHECK_RC(RTPipeRead(hPipeR, abBuf, 0, &cbRead), VINF_SUCCESS); // !?235 RTTESTI_CHECK_RC(RTPipeRead(hPipeR, abBuf, 0, &cbRead), VINF_SUCCESS); 236 236 RTTESTI_CHECK(cbRead == 0); 237 237 cbRead = ~(size_t)3; … … 284 284 RTTESTI_CHECK(!memcmp(abBuf, "42!", 3)); 285 285 RTTESTI_CHECK_RC(RTPipeClose(hPipeR), VINF_SUCCESS); 286 RTTESTI_CHECK_RC_RETV(RTPipeWriteBlocking(hPipeW, "", 0), V ERR_BROKEN_PIPE);286 RTTESTI_CHECK_RC_RETV(RTPipeWriteBlocking(hPipeW, "", 0), VINF_SUCCESS); 287 287 RTTESTI_CHECK_RC_RETV(RTPipeWriteBlocking(hPipeW, "42", 2), VERR_BROKEN_PIPE); 288 288 RTTESTI_CHECK_RC(RTPipeClose(hPipeW), VINF_SUCCESS);
Note:
See TracChangeset
for help on using the changeset viewer.