Skip to content

wasi-common virtfs pipe: convert to be Send and Sync; fix Clone#1961

Merged
pchickey merged 2 commits intomainfrom
pch/sync_wasi_pipe
Jul 2, 2020
Merged

wasi-common virtfs pipe: convert to be Send and Sync; fix Clone#1961
pchickey merged 2 commits intomainfrom
pch/sync_wasi_pipe

Conversation

@pchickey
Copy link
Contributor

@pchickey pchickey commented Jul 1, 2020

Follow up to #1949

When we went to integrate this code, we discovered that we needed these virtual pipes to be Send and Sync. So, I have switched the internal types from Cell/RefCell/Rc to Arc/RwLock.

The RwLock.{read, write} results are always unwrap()ed because this code does not expose any way for a panic to occur while a lock is held.

We also identified that the Handle::try_clone method was incorrect, and did a manual impl of Clone with the correct semantics.

@pchickey pchickey requested a review from acfoltzer July 1, 2020 22:48
Copy link
Contributor

@acfoltzer acfoltzer left a comment

Choose a reason for hiding this comment

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

Thank you! Sorry for the oversight here. I mainly was testing with the lucet-wasi test suite, which does not do any thread migration.

@github-actions github-actions bot added the wasi Issues pertaining to WASI label Jul 1, 2020
@github-actions
Copy link

github-actions bot commented Jul 1, 2020

Subscribe to Label Action

cc @kubkon

Details This issue or pull request has been labeled: "wasi"

Thus the following users have been cc'd because of the following labels:

  • kubkon: wasi

To subscribe or unsubscribe from this label, edit the .github/subscribe-to-label.json configuration file.

Learn more.

* The underlying `R`/`W` doesnt need to be Clone, since we just need to
  clone the Arc it sits behind.
* The rights actually shouldn't be behind an Arc - those get mutated
  separately in each clone.
@pchickey pchickey changed the title wasi-common virtfs pipe: convert to be Send and Sync wasi-common virtfs pipe: convert to be Send and Sync; fix Clone Jul 2, 2020
Copy link
Contributor

@acfoltzer acfoltzer left a comment

Choose a reason for hiding this comment

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

Great catch on the Clone behavior as well. I didn't realize the constraint would end up on the type parameter.

@pchickey pchickey merged commit 301277e into main Jul 2, 2020
@pchickey pchickey deleted the pch/sync_wasi_pipe branch July 2, 2020 05:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

wasi Issues pertaining to WASI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants