Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
14 changes: 7 additions & 7 deletions src/ipc/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ impl ServerHolder {
new_mitm_server_fn: self.new_mitm_server_fn,
handle_type: WaitHandleType::Session,
mitm_forward_info: mitm_fwd_info,
is_mitm_service: forward_handle != 0,
is_mitm_service: forward_handle != svc::INVALID_HANDLE,
service_name: sm::ServiceName::empty(),
domain_table: self.domain_table.clone(),
})
Expand Down Expand Up @@ -519,20 +519,20 @@ impl ServerHolder {
"MitM server objects should always own their handles."
);
sm.atmosphere_uninstall_mitm(self.service_name)?;
}
else {
} else {
sm.unregister_service(self.service_name)?;
}
}

if self.is_mitm_service {
sf::Session::from(self.mitm_forward_info).close();
}

sm.detach_client(sf::ProcessId::new())?;
}
}

// Forward info may be valid despite having an empty service name (like a cloned session)
if self.is_mitm_service {
sf::Session::from(self.mitm_forward_info).close();
}

// Don't close our session like a normal one (like the forward session below) as we allocated the object IDs ourselves, the only thing we do have to close is the handle
if self.info.owns_handle {
svc::close_handle(self.info.handle)?;
Expand Down
20 changes: 10 additions & 10 deletions src/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,23 +292,23 @@ impl Builder {
f: F,
) -> crate::result::Result<JoinHandle<T, WAIT_ON_DROP>>
where
F: FnOnce() -> T,
F: FnOnce() -> T + 'static,
F: Send,
T: Send,
T: Send + 'static,
{
Ok(JoinHandle(unsafe { self.spawn_unchecked_(f, None) }?))
}

#[allow(unsafe_op_in_unsafe_fn)]
unsafe fn spawn_unchecked_<'scope, F, T>(
unsafe fn spawn_unchecked_<F, T>(
self,
f: F,
scope_data: Option<Arc<scoped::ScopeData>>,
) -> crate::result::Result<JoinInner<'scope, T>>
) -> crate::result::Result<JoinInner<'static, T>>
where
F: FnOnce() -> T,
F: FnOnce() -> T + 'static,
F: Send,
T: Send,
T: Send + 'static,
{
let Builder {
name,
Expand All @@ -327,7 +327,7 @@ impl Builder {
let my_thread = Thread::new_inner(name);
let _their_thread = my_thread.clone();

let my_packet: Arc<Packet<'scope, T>> = Arc::new(Packet {
let my_packet: Arc<Packet<'static, T>> = Arc::new(Packet {
scope: scope_data,
result: UnsafeCell::new(None),
_marker: PhantomData,
Expand Down Expand Up @@ -370,7 +370,7 @@ impl Builder {
// will call `decrement_num_running_threads` and therefore signal that this thread is
// done.
drop(their_packet);
// Here, the lifetime `'scope` can end. `main` keeps running for a bit
// Here, the lifetime `'static` can end. `main` keeps running for a bit
// after that before returning itself.
};

Expand Down Expand Up @@ -803,9 +803,9 @@ impl<T> Drop for Packet<'_, T> {
// Book-keeping so the scope knows when it's done.
if let Some(scope) = &self.scope {
// Now that there will be no more user code running on this thread
// that can use 'scope, mark the thread as 'finished'.
// that can use 'static, mark the thread as 'finished'.
// It's important we only do this after the `result` has been dropped,
// since dropping it might still use things it borrowed from 'scope.
// since dropping it might still use things it borrowed from 'static.
scope.decrement_num_running_threads(unhandled_panic);
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/thread/scoped.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@ impl<'scope> Scope<'scope, '_> {
/// [`join`]: ScopedJoinHandle::join
pub fn spawn<F, T>(&'scope self, f: F) -> ScopedJoinHandle<'scope, T>
where
F: FnOnce() -> T + Send + 'scope,
T: Send + 'scope,
F: FnOnce() -> T + Send + 'scope + 'static,
T: Send + 'scope + 'static,
{
Builder::new()
.spawn_scoped(self, f)
Expand Down Expand Up @@ -251,8 +251,8 @@ impl Builder {
f: F,
) -> crate::result::Result<ScopedJoinHandle<'scope, T>>
where
F: FnOnce() -> T + Send + 'scope,
T: Send + 'scope,
F: FnOnce() -> T + Send + 'scope + 'static,
T: Send + 'scope + 'static,
{
Ok(ScopedJoinHandle(unsafe {
self.spawn_unchecked_(f, Some(scope.data.clone()))
Expand Down