mirror of
https://github.com/NVIDIA/cuda-samples.git
synced 2026-01-08 10:27:49 +08:00
Bug 5502937: Set TEMPDIR as socket create dir to avoid socket create permission isue on systems like WSL
This commit is contained in:
parent
3e6d1858af
commit
b0a2f2049f
@ -188,7 +188,7 @@ int ipcCreateSocket(ipcHandle *&handle, const char *name,
|
||||
char path_name[50];
|
||||
|
||||
// Create unique name for the socket with path if SOCK_FOLDER is set.
|
||||
sprintf(path_name, "%s%u", SOCK_FOLDER, getpid());
|
||||
sprintf(path_name, "%s/%u", getSocketFolder().c_str(), getpid());
|
||||
|
||||
unlink(path_name);
|
||||
memset(&servaddr, 0, sizeof(servaddr));
|
||||
@ -230,7 +230,7 @@ int ipcOpenSocket(ipcHandle *&handle) {
|
||||
char temp[50];
|
||||
|
||||
// Create unique name for the socket with path if SOCK_FOLDER is set.
|
||||
sprintf(temp, "%s%u", SOCK_FOLDER, getpid());
|
||||
sprintf(temp, "%s/%u", getSocketFolder().c_str(), getpid());
|
||||
|
||||
strcpy(cliaddr.sun_path, temp);
|
||||
if (bind(sock, (struct sockaddr *)&cliaddr, sizeof(cliaddr)) < 0) {
|
||||
@ -367,7 +367,7 @@ int ipcSendShareableHandle(ipcHandle *handle,
|
||||
memset(&cliaddr, 0, sizeof(cliaddr));
|
||||
cliaddr.sun_family = AF_UNIX;
|
||||
char temp[20];
|
||||
sprintf(temp, "%s%u", SOCK_FOLDER, process);
|
||||
sprintf(temp, "%s/%u", getSocketFolder().c_str(), process);
|
||||
strcpy(cliaddr.sun_path, temp);
|
||||
len = sizeof(cliaddr);
|
||||
|
||||
|
||||
@ -52,14 +52,12 @@
|
||||
#include <memory.h>
|
||||
#include <sys/un.h>
|
||||
#endif
|
||||
#include <filesystem>
|
||||
#include <vector>
|
||||
|
||||
// Define "/tmp" as socket creating folder for QNX
|
||||
#if defined(__QNX__)
|
||||
#define SOCK_FOLDER "/tmp/"
|
||||
#else
|
||||
#define SOCK_FOLDER ""
|
||||
#endif
|
||||
inline std::string getSocketFolder() {
|
||||
return std::filesystem::temp_directory_path().string();
|
||||
}
|
||||
|
||||
typedef struct sharedMemoryInfo_st {
|
||||
void *addr;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user