in src/enclave_proc/socket.rs [112:149]
fn close_mut(&mut self) -> NitroCliResult<()> {
// Delete the socket from the disk. Also mark that this operation is intended, so that the
// socket file monitoring thread doesn't exit forcefully when notifying the deletion.
self.requested_remove.store(true, Ordering::SeqCst);
if self.socket_path.exists() {
std::fs::remove_file(&self.socket_path).map_err(|e| {
new_nitro_cli_failure!(
&format!(
"Failed to remove socket file {:?} from disk: {:?}",
self.socket_path, e
),
NitroCliErrorEnum::FileOperationFailure
)
.add_info(vec![
self.socket_path
.to_str()
.unwrap_or("Invalid unicode socket file name"),
"Remove",
])
})?;
}
// Since the socket file has been deleted, we also wait for the event listener thread to finish.
if self.remove_listener_thread.is_some() {
self.remove_listener_thread
.take()
.unwrap()
.join()
.map_err(|e| {
new_nitro_cli_failure!(
&format!("Failed to join socket notification thread: {:?}", e),
NitroCliErrorEnum::ThreadJoinFailure
)
})?;
}
Ok(())
}