Skip to content

Commit

Permalink
[Runtime][Disco] Restore checks for hangup of disco pipe (#16997)
Browse files Browse the repository at this point in the history
This resolves a conflict between two recent changes.  In
#16989, reads of size zero are used
to identify hangups in `ProcessSession`.  In
#16992, reads of size zero are
treated as an error to avoid infinite loops while waiting for data to
be ready.

For a long-term resolution, the `dmlc::Stream` interface will need to
be updated, so that the `Write` method returns the number of bytes
written, just as the `Read` method currently does.  This will allow
the calling scope to verify the number of bytes received.
  • Loading branch information
Lunderberg authored May 15, 2024
1 parent b49468d commit f044eef
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/support/pipe.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,11 @@ class Pipe : public dmlc::Stream {
RetryCallOnEINTR([&]() { return read(handle_, ptr, size); }, GetLastErrorCode);
ICHECK_NE(nread_chunk, -1) << "Write Error: " << strerror(errno);

ICHECK_GT(nread_chunk, 0) << "Was unable to read any data from pipe";
if (nread_chunk == 0) {
break;
}

ICHECK_GE(nread_chunk, 0);
ICHECK_LE(nread_chunk, size) << "Read " << nread_chunk << " bytes, "
<< "but only expected to read " << size << " bytes";
size -= nread_chunk;
Expand Down

0 comments on commit f044eef

Please sign in to comment.