Skip to content

Commit

Permalink
Merge branch 'uniqueness-check-before-logrotate' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
dlon committed Feb 22, 2024
2 parents e7eacb9 + f60a9c9 commit a08f3a5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Line wrap the file at 100 chars. Th
### Fixed
- Continual excessive attempts to update the API IP were made after testing access methods.
- Fix pointless API access method rotations for concurrent requests.
- Fix daemon rotating logs on startup even if another daemon is already running.

### Security
#### Android
Expand Down
20 changes: 11 additions & 9 deletions mullvad-daemon/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,24 @@ const EARLY_BOOT_LOG_FILENAME: &str = "early-boot-fw.log";

fn main() {
let config = cli::get_config();

let runtime = new_runtime_builder().build().unwrap_or_else(|error| {
eprintln!("{}", error.display_chain());
std::process::exit(1);
});

if runtime.block_on(rpc_uniqueness_check::is_another_instance_running()) {
eprintln!("Another instance of the daemon is already running");
std::process::exit(1)
}

let log_dir = init_daemon_logging(config).unwrap_or_else(|error| {
eprintln!("{error}");
std::process::exit(1)
});

log::trace!("Using configuration: {:?}", config);

let runtime = new_runtime_builder().build().unwrap_or_else(|error| {
eprintln!("{}", error.display_chain());
std::process::exit(1);
});

let exit_code = match runtime.block_on(run_platform(config, log_dir)) {
Ok(_) => 0,
Err(error) => {
Expand Down Expand Up @@ -144,10 +150,6 @@ async fn run_platform(_config: &cli::Config, log_dir: Option<PathBuf>) -> Result
}

async fn run_standalone(log_dir: Option<PathBuf>) -> Result<(), String> {
if rpc_uniqueness_check::is_another_instance_running().await {
return Err("Another instance of the daemon is already running".to_owned());
}

#[cfg(any(target_os = "macos", target_os = "linux"))]
if let Err(err) = tokio::fs::remove_file(mullvad_paths::get_rpc_socket_path()).await {
if err.kind() != std::io::ErrorKind::NotFound {
Expand Down

0 comments on commit a08f3a5

Please sign in to comment.