Skip to content

Commit 6182e18

Browse files
committed
rust-version = "1.80.0"
1 parent cbcf39a commit 6182e18

File tree

3 files changed

+8
-11
lines changed

3 files changed

+8
-11
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ members = [
3131
repository = "https://github.com/rustcoreutils/posixutils-rs"
3232
license = "MIT"
3333
edition = "2021"
34-
rust-version = "1.77.0"
34+
rust-version = "1.80.0"
3535

3636
[workspace.dependencies]
3737
clap = { version = "4", default-features = false, features = ["std", "derive", "help", "usage", "error-context", "cargo"] }

clippy.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
msrv = "1.77.0"
1+
msrv = "1.80.0"

users/talk.rs

+6-9
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ use std::{
3131
},
3232
os::fd::AsRawFd,
3333
process, ptr,
34-
sync::{Arc, Mutex, OnceLock},
34+
sync::{Arc, LazyLock, Mutex},
3535
thread,
3636
time::{Duration, Instant},
3737
};
@@ -53,12 +53,9 @@ pub struct State {
5353
pub talkd_addr: SocketAddr,
5454
}
5555

56-
fn get_delete_invitations() -> &'static Arc<Mutex<Option<State>>> {
57-
/// A static variable to hold the state of delete invitations on SIGINT signal.
58-
static DELETE_INVITATIONS: OnceLock<Arc<Mutex<Option<State>>>> = OnceLock::new();
59-
60-
DELETE_INVITATIONS.get_or_init(|| Arc::new(Mutex::new(None)))
61-
}
56+
/// A static variable to hold the state of delete invitations on SIGINT signal.
57+
static DELETE_INVITATIONS: LazyLock<Arc<Mutex<Option<State>>>> =
58+
LazyLock::new(|| Arc::new(Mutex::new(None)));
6259

6360
/// The size of the buffer for control message fields like l_name, r_name, and r_tty in CtlMsg.
6461
const BUFFER_SIZE: usize = 12;
@@ -962,7 +959,7 @@ fn handle_new_invitation(
962959

963960
let clone_socket = Arc::clone(&socket);
964961

965-
*get_delete_invitations().lock().unwrap() = Some(State {
962+
*DELETE_INVITATIONS.lock().unwrap() = Some(State {
966963
msg_bytes1,
967964
msg_bytes2,
968965
socket: clone_socket,
@@ -1630,7 +1627,7 @@ pub fn handle_signals(signal_code: libc::c_int) {
16301627
eprintln!("Connection closed, exiting...");
16311628

16321629
// Lock the DELETE_INVITATIONS mutex and check for an existing invitation
1633-
if let Some(state) = get_delete_invitations().lock().unwrap().as_ref() {
1630+
if let Some(state) = DELETE_INVITATIONS.lock().unwrap().as_ref() {
16341631
// Handle the deletion of invitations
16351632
handle_delete_invitations(&state.socket, &state.msg_bytes1, &state.talkd_addr);
16361633
handle_delete_invitations(&state.socket, &state.msg_bytes2, &state.talkd_addr);

0 commit comments

Comments
 (0)