Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix lifespan of the temporary directory that holds cuFile configuration file #10403

Merged
Merged
Show file tree
Hide file tree
Changes from 4 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
7 changes: 6 additions & 1 deletion cpp/include/cudf_test/file_utilities.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, NVIDIA CORPORATION.
* Copyright (c) 2020-2022, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -47,6 +47,11 @@ class temp_directory {
return std::remove(pathname);
}

temp_directory& operator=(temp_directory const&) = delete;
temp_directory(temp_directory const&) = delete;
temp_directory& operator=(temp_directory&&) = default;
temp_directory(temp_directory&&) = default;

~temp_directory()
{
// TODO: should use std::filesystem instead, once C++17 support added
Expand Down
5 changes: 3 additions & 2 deletions cpp/src/io/utilities/file_io_utilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,14 @@ class cufile_shim {
void cufile_shim::modify_cufile_json() const
{
std::string const json_path_env_var = "CUFILE_ENV_PATH_JSON";
temp_directory tmp_config_dir{"cudf_cufile_config"};
static std::optional<temp_directory> tmp_config_dir;
if (not tmp_config_dir.has_value()) { tmp_config_dir = temp_directory{"cudf_cufile_config"}; }
vuule marked this conversation as resolved.
Show resolved Hide resolved

// Modify the config file based on the policy
auto const config_file_path = getenv_or<std::string>(json_path_env_var, "/etc/cufile.json");
std::ifstream user_config_file(config_file_path);
// Modified config file is stored in a temporary directory
auto const cudf_config_path = tmp_config_dir.path() + "/cufile.json";
auto const cudf_config_path = tmp_config_dir->path() + "cufile.json";
std::ofstream cudf_config_file(cudf_config_path);

std::string line;
Expand Down