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: Data race in CopyPassThru #66

Conversation

mafredri
Copy link
Contributor

The fix in #38 was incomplete as it only moved StdoutPipe outside the
goroutine, this commit also moves StdinPipe outside the goroutine so
there is no race when doing Run on the session.

Fixes #39
Related to #38

The fix in bramvdbogaerde#38 was incomplete as it only moved StdoutPipe outside the
goroutine, this commit also moves StdinPipe outside the goroutine so
there is no race when doing Run on the session.

Fixes bramvdbogaerde#39
Related to bramvdbogaerde#38
@@ -157,12 +162,6 @@ func (a *Client) CopyPassThru(ctx context.Context, r io.Reader, remotePath strin

go func() {
defer wg.Done()
w, err := a.Session.StdinPipe()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This issue is easy to reproduce by adding a time.Sleep(time.Second) above.

mafredri added a commit to coder/coder that referenced this pull request Dec 19, 2022
@deansheather
Copy link

@bramvdbogaerde

@bramvdbogaerde bramvdbogaerde merged commit 35e970e into bramvdbogaerde:master Dec 19, 2022
@bramvdbogaerde
Copy link
Owner

Merged! Thank you for your contribution.

@mafredri mafredri deleted the mafredri/fix-copypassthru-data-race branch December 20, 2022 09:23
mudler referenced this pull request in kairos-io/provider-kairos Feb 7, 2023
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
|
[github.com/bramvdbogaerde/go-scp](https://togithub.com/bramvdbogaerde/go-scp)
| require | patch | `v1.2.0` -> `v1.2.1` |

---

### Release Notes

<details>
<summary>bramvdbogaerde/go-scp</summary>

###
[`v1.2.1`](https://togithub.com/bramvdbogaerde/go-scp/releases/tag/v1.2.1):
Version 1.2.1

[Compare
Source](https://togithub.com/bramvdbogaerde/go-scp/compare/v1.2.0...v1.2.1)

#### What's Changed

- Some code style fixes by
[@&#8203;dshemin](https://togithub.com/dshemin) in
[https://github.com/bramvdbogaerde/go-scp/pull/53](https://togithub.com/bramvdbogaerde/go-scp/pull/53)
- fix: CopyRemotePassThru blocked on writing to error channel by
[@&#8203;262nos](https://togithub.com/262nos) in
[https://github.com/bramvdbogaerde/go-scp/pull/56](https://togithub.com/bramvdbogaerde/go-scp/pull/56)
- fix: Data race in CopyPassThru by
[@&#8203;mafredri](https://togithub.com/mafredri) in
[https://github.com/bramvdbogaerde/go-scp/pull/66](https://togithub.com/bramvdbogaerde/go-scp/pull/66)

#### New Contributors

- [@&#8203;262nos](https://togithub.com/262nos) made their first
contribution in
[https://github.com/bramvdbogaerde/go-scp/pull/56](https://togithub.com/bramvdbogaerde/go-scp/pull/56)
- [@&#8203;mafredri](https://togithub.com/mafredri) made their first
contribution in
[https://github.com/bramvdbogaerde/go-scp/pull/66](https://togithub.com/bramvdbogaerde/go-scp/pull/66)

**Full Changelog**:
bramvdbogaerde/go-scp@v1.2.0...v1.2.1

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://app.renovatebot.com/dashboard#github/kairos-io/provider-kairos).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNC44MS4wIiwidXBkYXRlZEluVmVyIjoiMzQuMTA4LjEifQ==-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Check the CopyPassThru code for race conditions
3 participants