You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: glide-core/src/socket_listener.rs
+26-28
Original file line number
Diff line number
Diff line change
@@ -11,7 +11,6 @@ use crate::errors::{error_message, error_type, RequestErrorType};
11
11
usecrate::response;
12
12
usecrate::response::Response;
13
13
use bytes::Bytes;
14
-
use directories::BaseDirs;
15
14
use logger_core::{log_debug, log_error, log_info, log_trace, log_warn};
16
15
use once_cell::sync::Lazy;
17
16
use protobuf::{Chars,Message};
@@ -24,8 +23,8 @@ use std::cell::Cell;
24
23
use std::collections::HashSet;
25
24
use std::ptr::from_mut;
26
25
use std::rc::Rc;
26
+
use std::str;
27
27
use std::sync::RwLock;
28
-
use std::{env, str};
29
28
use std::{io, thread};
30
29
use thiserror::Error;
31
30
use tokio::net::{UnixListener,UnixStream};
@@ -39,7 +38,8 @@ use ClosingReason::*;
39
38
usePipeListeningResult::*;
40
39
41
40
/// The socket file name
42
-
constSOCKET_FILE_NAME:&str = "glide-socket";
41
+
constSOCKET_FILE_NAME:&str = "glide-socket.sock";
42
+
constSOCKET_FOLDER:&str = "valkey-glide";
43
43
44
44
/// The maximum length of a request's arguments to be passed as a vector of
45
45
/// strings instead of a pointer
@@ -569,7 +569,13 @@ async fn handle_requests(
569
569
570
570
pubfnclose_socket(socket_path:&String){
571
571
log_info("close_socket",format!("closing socket at {socket_path}"));
572
-
let _ = std::fs::remove_file(socket_path);
572
+
// On Unix systems, the files are "unlinked" but not deleted until all references to the file are closed.
573
+
// Based on the officials docs of `rust std::fs::remove_file: https://doc.rust-lang.org/std/fs/fn.remove_file.html`,
574
+
// "Note that there is no guarantee that the file is immediately deleted (e.g., depending on platform, other open file descriptors may prevent immediate removal)."
575
+
// So, we rename the file to a new name and then remove it, to avoid any issues with the file being unlinked but not deleted, and the system is closed before the file is deleted.
576
+
// As we saw with dockers being closed on immediate shutdown of the program.
577
+
let _ = std::fs::rename(socket_path,format!("{socket_path}.closed"));
578
+
let _ = std::fs::remove_file(format!("{socket_path}.closed"));
0 commit comments