Skip to content

Commit

Permalink
Remove the depricated function std::tmpnam (facebookincubator#10733)
Browse files Browse the repository at this point in the history
Summary:
Fixes : facebookincubator#10715

Pull Request resolved: facebookincubator#10733

Reviewed By: tanjialiang

Differential Revision: D61212598

Pulled By: xiaoxmeng

fbshipit-source-id: 3d1e510deccef2f5b8ca80e6bdfb50358b80d64e
  • Loading branch information
Joe-Abraham authored and facebook-github-bot committed Aug 13, 2024
1 parent 99f990c commit ba1bb9e
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions velox/functions/remote/client/tests/RemoteFunctionTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include <folly/init/Init.h>
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include <cstdio>
#include <stdlib.h>

#include "velox/common/base/Exceptions.h"
#include "velox/common/base/tests/GTestUtils.h"
Expand Down Expand Up @@ -125,8 +125,18 @@ class RemoteFunctionTest

// Creates a random temporary file name to use to communicate as a unix domain
// socket.
folly::SocketAddress location_{
folly::SocketAddress::makeFromPath(std::tmpnam(nullptr))};
folly::SocketAddress location_ = []() {
char name[] = "/tmp/socketXXXXXX";
int fd = mkstemp(name);
if (fd < 0) {
throw std::runtime_error("Failed to create temporary file for socket");
}
close(fd);
std::string socketPath(name);
// Cleanup existing socket file if it exists.
unlink(socketPath.c_str());
return folly::SocketAddress::makeFromPath(socketPath);
}();

const std::string remotePrefix_{"remote"};
};
Expand Down

0 comments on commit ba1bb9e

Please sign in to comment.