Closed Luv-Ray closed 6 months ago
Thanks for the PR! That was quick. :)
define struct FileDescription(Rc<RefCell
>)
This sounds the wrong way around. Many file descriptors map to fewer file descriptions, not the other way around.
Sorry for the bad naming. It has been rectified.
Awesome, I think we're done. :)
Please squash the commits together.
Thanks a lot!
@bors r+
:pushpin: Commit 41b5a1b4e8294fc620bb3f4450aa01859325add0 has been approved by RalfJung
It is now in the queue for this repository.
:hourglass: Testing commit 41b5a1b4e8294fc620bb3f4450aa01859325add0 with merge be0e91ebec475b6c7bf94a81b41db29ceb99c16a...
@Luv-Ray a possible next step, if you want, would be to give the read
and write
methods of FileDescriptor
access to ecx: &mut InterpCx<'mir, 'tcx, MiriMachine<'mir, 'tcx>>
. This will be needed in the future to support blocking on these operations.
To make that work out in terms of borrowing, I think what we will have to do is clone the Rc
in the read
/write
functions in unix/fd.rs
, so that we have a fully owned FileDescriptor
next to a uniquely borrowed InterpCx
.
:sunny: Test successful - checks-actions Approved by: RalfJung Pushing be0e91ebec475b6c7bf94a81b41db29ceb99c16a to master...
Thanks for review! I think I can give it a try on the next step.
fixes #3525
Remove
fn dup
intrait FileDescription
, definestruct FileDescriptor(Rc<RefCell<dyn FileDescription>>)
, and useBTreeMap<i32, FileDescriptor>
inFdTable
.There are some refactors similar to the following form:
The origin form can't compile because as using
RefCell
to get interior mutability,fn get_mut
returnOption<std::cell::RefMut<'_, dyn FileDescription>>
instead ofOption<&mut dyn FileDescription>
now, and thederef_mut
onfile_descriptor: RefMut
will cause borrowthis
as mutable more than once at a time. So this form of refactors and manual drops are are implemented to avoid borrowingthis
at the same time.