-
Notifications
You must be signed in to change notification settings - Fork 6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[core] Fix std::flush with istream::readsome
#50248
Conversation
d637a3a
to
bc19684
Compare
Signed-off-by: dentiny <[email protected]>
bc19684
to
0953813
Compare
681e78f
to
059d963
Compare
Signed-off-by: dentiny <[email protected]>
059d963
to
f25d458
Compare
Signed-off-by: dentiny <[email protected]>
@jjyao I updated the implementation and integrate with the newliner sink, no known stuck issue at the moment. |
Signed-off-by: dentiny <[email protected]>
Signed-off-by: dentiny <[email protected]>
4b96c9b
to
9d2ebc3
Compare
Signed-off-by: dentiny <[email protected]>
Signed-off-by: dentiny <[email protected]>
Signed-off-by: dentiny <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LG
std::this_thread::sleep_for(std::chrono::seconds(2)); | ||
FlushOnRedirectedStderr(); | ||
|
||
// Make sure flush hook works fine and process terminates with no problem. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we are not checking anything here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See documentation above.
// This test case only checks whether stream redirection process could exit normally.
StreamRedirectionOption opts; | ||
opts.file_path = test_file_path; | ||
opts.tee_to_stderr = true; | ||
RedirectStderr(opts); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we decouple RedirectStream
with atexit()
so that we can test better and don't need to create a file for each test.
Ideally we can manually call SyncOnStreamRedirection
to close the redirection.
RedirectStderr();
// test
SyncOnStreamRedirection(); // restore to the old state
// some checks
RedirectStderr();
// another test
SyncOnStreamRedirection();
// some checks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That way you need to return redirection handler to the caller? Or return the exit terminator.
Signed-off-by: dentiny <[email protected]>
Signed-off-by: dentiny <[email protected]>
87dee19
to
babd0bb
Compare
Current implementation doesn't handle
std::flush
, which requires to dump content into sinks right away.This PR reads content from pipe in two ways:
istream::readsome
to apply non-blocking read, to read all content right away;istream::read
to block read, so we don't waste CPU cycle on busy polling when no content in pipe.