Don't put socket endpoints in a directory

This would only leave an empty directory behind.
This commit is contained in:
Robbert van der Helm
2020-04-19 17:05:50 +02:00
parent ed3b319f4f
commit f29a859713
+8 -6
View File
@@ -543,13 +543,15 @@ fs::path generate_endpoint_name() {
alphanumeric_characters + strlen(alphanumeric_characters) - 1, alphanumeric_characters + strlen(alphanumeric_characters) - 1,
std::back_inserter(random_id), 8, rng); std::back_inserter(random_id), 8, rng);
candidate_endpoint = fs::temp_directory_path() / "yabridge" / // We'll get rid of the file descriptors immediately after accepting the
(plugin_name + "-" + random_id + ".sock"); // sockets, so putting them inside of a subdirectory would only leave
} while (fs::exists(candidate_endpoint)); // behind an empty directory
std::ostringstream socket_name;
socket_name << "yabridge-" << plugin_name << "-" << random_id
<< ".sock";
// Ensure that the parent directory exists so the socket endpoint can be candidate_endpoint = fs::temp_directory_path() / socket_name.str();
// created there } while (fs::exists(candidate_endpoint));
fs::create_directories(candidate_endpoint.parent_path());
// TODO: Should probably try creating the endpoint right here and catch any // TODO: Should probably try creating the endpoint right here and catch any
// exceptions since this could technically result in a race condition // exceptions since this could technically result in a race condition