Repository navigation
Conversation
…ilure soap.Client.Upload wraps the request body in a progress.reader and defers pr.Done(err), which closes the progress channel. If the server replies before it has read the whole body (for example vCenter returning 503 mid-VMDK upload), http.Client.Do returns and Done closes the channel. net/http's writer goroutine may still be reading the body at that point. It calls reader.Read, which sends a report on the closed channel and panics with send on closed channel. Fix: In vim25/progress/reader.go: - Add a sync.Mutex and a done flag to reader. Read and Done hold the lock around the channel send and close. - After Done, Read still returns data and errors from the underlying reader, but sends no more progress reports. - Done is idempotent, so a second call can't double-close the channel. - pos is now guarded by the same mutex. This also removes a data race between Read (transport goroutine) and Done (caller goroutine). - The underlying Read runs outside the lock, so a slow source never blocks Done. Signed-off-by: Prajwal Bhagat <prajwal.bhagat@broadcom.com> Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
soap.Client.Upload wraps the request body in a progress.reader and defers pr.Done(err), which closes the progress channel. If the server replies before it has read the whole body (for example vCenter returning 503 mid-VMDK upload), http.Client.Do returns and Done closes the channel. net/http's writer goroutine may still be reading the body at that point. It calls reader.Read, which sends a report on the closed channel and panics with send on closed channel.
Fix:
In vim25/progress/reader.go:
Closes: #3831
How Has This Been Tested?
TestReaderReadAfterDone,TestReaderConcurrentReadDone,TestReaderReadErrorandTestUploadEarlyErrorResponseto cover different scenarios.go test -race -count=5 ./vim25/progress ./vim25/soapandgo test -race ./vim25/... ./object ./nfcto run these tests.