Skip to content

Commit 21f4c9f

Browse files
committed
windows: move_handle_to_process(): Take ownership of handle
More explicitly reflect the fact that this function consumes/moves the original handle.
1 parent 6cd642e commit 21f4c9f

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/platform/windows/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ fn dup_handle_to_process(handle: &WinHandle, other_process: &WinHandle) -> Resul
258258
}
259259

260260
/// Duplicate a handle to the target process, closing the source handle.
261-
fn move_handle_to_process(handle: &mut WinHandle, other_process: &WinHandle) -> Result<WinHandle,WinError> {
261+
fn move_handle_to_process(mut handle: WinHandle, other_process: &WinHandle) -> Result<WinHandle,WinError> {
262262
unsafe {
263263
let h = try!(dup_handle_to_process_with_flags(
264264
handle.take(), **other_process,
@@ -1011,16 +1011,16 @@ impl OsIpcSender {
10111011

10121012
for port in ports {
10131013
match port {
1014-
OsIpcChannel::Sender(mut s) => {
1015-
let mut raw_remote_handle = try!(move_handle_to_process(&mut s.handle, &server_h));
1014+
OsIpcChannel::Sender(s) => {
1015+
let mut raw_remote_handle = try!(move_handle_to_process(s.handle, &server_h));
10161016
oob.channel_handles.push(raw_remote_handle.take() as intptr_t);
10171017
},
10181018
OsIpcChannel::Receiver(r) => {
10191019
if try!(r.prepare_for_transfer()) == false {
10201020
panic!("Sending receiver with outstanding partial read buffer, noooooo! What should even happen?");
10211021
}
10221022

1023-
let mut raw_remote_handle = try!(move_handle_to_process(&mut r.reader.borrow_mut().handle, &server_h));
1023+
let mut raw_remote_handle = try!(move_handle_to_process(r.reader.into_inner().handle, &server_h));
10241024
oob.channel_handles.push(raw_remote_handle.take() as intptr_t);
10251025
},
10261026
}
@@ -1039,7 +1039,7 @@ impl OsIpcSender {
10391039
};
10401040

10411041
// Put the receiver in the OOB data
1042-
let mut raw_receiver_handle = try!(move_handle_to_process(&mut receiver.reader.borrow_mut().handle, &server_h));
1042+
let mut raw_receiver_handle = try!(move_handle_to_process(receiver.reader.into_inner().handle, &server_h));
10431043
oob.big_data_receiver_handle = Some((raw_receiver_handle.take() as intptr_t, data.len() as u64));
10441044
oob.target_process_id = server_pid;
10451045

0 commit comments

Comments
 (0)