chore: modify broker related code#2992
Conversation
77a1e4d to
bdf9e41
Compare
bdf9e41 to
f7ef250
Compare
adamsitnik
left a comment
There was a problem hiding this comment.
And modify OnProcessExited callback to dispose DisposeLocalCopyOfClientHandle.
It's required when child process is spawned and exits quickly withoutBeforeAnythingElsesignal.
Without this code,reader.ReadLine();infinitely waiting, because anonymous pipe is not closed.
If the process exits, the ReadLine should return null as the underlying pipe got closed (when the process exited).
If it's not the case, I can see two other potential issues:
- the parent process has not closed it's copy of the pipe handle (write end in this case)
- the parent process has started another process, that derived the pipe handle and keeps it open until it exits
@filzrev big thanks for taking care of this edge case bug!
|
I've removed redundant It’s remained to preserve the original code behavior. (Run ProcessDataBlocking on worker thread)
Original code contains OnProcessExited callback already and disposing client handles inside OnProcessExited . So expected edge case is following
|
timcassell
left a comment
There was a problem hiding this comment.
LGTM but I'll let @adamsitnik make the final call.
|
It seems PR #2958 including So it's not needed if #2958 is expected to be merged in the near future.
|
|
It's fine to merge this first. I still have some work to do in that PR, and I can fix the merge conflicts with this. |
|
The change to named pipe in #2958 is showing freezes on Windows CI just like the issue this is trying to fix. I don't think it's a cause, but it does make it more repro-able. I'm going to go ahead and merge this then update that branch with these changes and see if it helps. |
This PR intended to fix part of issue of #2824
What's changed in this PR
1. Add IDisposable interface
and remove OnProcessExited event handlerTo ensure dispose operation is called synchronously.
Add IDisposable interface.
And modify OnProcessExited callback to dispose DisposeLocalCopyOfClientHandle.
It's required when child process is spawned and exits quickly without
BeforeAnythingElsesignal.Without this code,
reader.ReadLine();infinitely waiting, because anonymous pipe is not closed.2. Add Result enum
Add
Resultenum to returnProcessDataBlockingresult for error logging.3. Modify Task.Run` code
On current implementation.
Exception that thrown inside ProcessDataBlocking is silently ignored.
Because task is not awaited and
TaskScheduler.UnobservedTaskExceptionis not registerd.So when exception thrown, it cause benchmark freeze at
finished.WaitOneline.This PR move
finished.Setcode to try-finally block.To ensure
finished.WaitOneis signaled on unexpected exception thrown.And add
GetAwaiter().GetResult()code to wait task completion to throw exception.4. ProcessDataBlocking code changes
Resultenum.else ifblocks to if-continue to improve code readability.(As far as I've confirmed on original issue's logs. It seems there is cases that incomplete log line is returned from ReadLine())