Changeset 9da8740 in rtems
- Timestamp:
- 12/10/13 01:33:22 (10 years ago)
- Branches:
- 4.11, 5, master
- Children:
- 6122cb6a
- Parents:
- b51d8a4
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cpukit/libfs/src/pipe/fifo.c
rb51d8a4 r9da8740 391 391 return -EINTR; 392 392 393 while (read < count) { 394 while (PIPE_EMPTY(pipe)) { 395 /* Not an error */ 396 if (pipe->Writers == 0) 397 goto out_locked; 398 399 if (LIBIO_NODELAY(iop)) { 400 ret = -EAGAIN; 401 goto out_locked; 402 } 403 404 /* Wait until pipe is no more empty or no writer exists */ 405 pipe->waitingReaders ++; 406 PIPE_UNLOCK(pipe); 407 if (! PIPE_READWAIT(pipe)) 408 ret = -EINTR; 409 if (! PIPE_LOCK(pipe)) { 410 /* WARN waitingReaders not restored! */ 411 ret = -EINTR; 412 goto out_nolock; 413 } 414 pipe->waitingReaders --; 415 if (ret != 0) 416 goto out_locked; 393 while (PIPE_EMPTY(pipe)) { 394 /* Not an error */ 395 if (pipe->Writers == 0) 396 goto out_locked; 397 398 if (LIBIO_NODELAY(iop)) { 399 ret = -EAGAIN; 400 goto out_locked; 417 401 } 418 402 419 /* Read chunk bytes */ 420 chunk = MIN(count - read, pipe->Length); 421 chunk1 = pipe->Size - pipe->Start; 422 if (chunk > chunk1) { 423 memcpy(buffer + read, pipe->Buffer + pipe->Start, chunk1); 424 memcpy(buffer + read + chunk1, pipe->Buffer, chunk - chunk1); 403 /* Wait until pipe is no more empty or no writer exists */ 404 pipe->waitingReaders ++; 405 PIPE_UNLOCK(pipe); 406 if (! PIPE_READWAIT(pipe)) 407 ret = -EINTR; 408 if (! PIPE_LOCK(pipe)) { 409 /* WARN waitingReaders not restored! */ 410 ret = -EINTR; 411 goto out_nolock; 425 412 } 426 else 427 memcpy(buffer + read, pipe->Buffer + pipe->Start, chunk); 428 429 pipe->Start += chunk; 430 pipe->Start %= pipe->Size; 431 pipe->Length -= chunk; 432 /* For buffering optimization */ 433 if (PIPE_EMPTY(pipe)) 434 pipe->Start = 0; 435 436 if (pipe->waitingWriters > 0) 437 PIPE_WAKEUPWRITERS(pipe); 438 read += chunk; 439 } 413 pipe->waitingReaders --; 414 if (ret != 0) 415 goto out_locked; 416 } 417 418 /* Read chunk bytes */ 419 chunk = MIN(count - read, pipe->Length); 420 chunk1 = pipe->Size - pipe->Start; 421 if (chunk > chunk1) { 422 memcpy(buffer + read, pipe->Buffer + pipe->Start, chunk1); 423 memcpy(buffer + read + chunk1, pipe->Buffer, chunk - chunk1); 424 } 425 else 426 memcpy(buffer + read, pipe->Buffer + pipe->Start, chunk); 427 428 pipe->Start += chunk; 429 pipe->Start %= pipe->Size; 430 pipe->Length -= chunk; 431 /* For buffering optimization */ 432 if (PIPE_EMPTY(pipe)) 433 pipe->Start = 0; 434 435 if (pipe->waitingWriters > 0) 436 PIPE_WAKEUPWRITERS(pipe); 437 read += chunk; 440 438 441 439 out_locked:
Note: See TracChangeset
for help on using the changeset viewer.