Skip to content
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

fix race read while running proxy #2

Merged
merged 3 commits into from
Feb 15, 2021
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,15 @@ type chanWriter struct {
}

func (w *chanWriter) Write(data []byte) (int, error) {
w.out <- data

return len(data), nil
// look like the buffer being reused internally by the exec.Command
// so we can directly read the buffer in another goroutine while still being used in exec.Command goroutine

// copy to be written buffer and pass it into channel
bufferToWrite := append([]byte{}, data...)
w.out <- bufferToWrite

return len(bufferToWrite), nil
}

// Proxy runs inkspace instance in background and
Expand Down