mirror of
https://github.com/NVIDIA/cuda-samples.git
synced 2025-08-23 23:40:31 +08:00
Merge branch 'shawnz_bug_fix' into 'master'
Bug 5339530: Bug 4854664: Set socket creating folder to /tmp for QNX See merge request cuda-samples/cuda-samples!118
This commit is contained in:
commit
a9a4db666f
@ -185,25 +185,30 @@ int ipcCreateSocket(ipcHandle *&handle, const char *name,
|
||||
return -1;
|
||||
}
|
||||
|
||||
unlink(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());
|
||||
|
||||
unlink(path_name);
|
||||
memset(&servaddr, 0, sizeof(servaddr));
|
||||
servaddr.sun_family = AF_UNIX;
|
||||
|
||||
size_t len = strlen(name);
|
||||
size_t len = strlen(path_name);
|
||||
if (len > (sizeof(servaddr.sun_path) - 1)) {
|
||||
perror("IPC failure: Cannot bind provided name to socket. Name too large");
|
||||
return -1;
|
||||
}
|
||||
|
||||
strncpy(servaddr.sun_path, name, len);
|
||||
strncpy(servaddr.sun_path, path_name, len);
|
||||
|
||||
if (bind(server_fd, (struct sockaddr *)&servaddr, SUN_LEN(&servaddr)) < 0) {
|
||||
perror("IPC failure: Binding socket failed");
|
||||
return -1;
|
||||
}
|
||||
|
||||
handle->socketName = new char[strlen(name) + 1];
|
||||
strcpy(handle->socketName, name);
|
||||
handle->socketName = new char[strlen(path_name) + 1];
|
||||
strcpy(handle->socketName, path_name);
|
||||
handle->socket = server_fd;
|
||||
return 0;
|
||||
}
|
||||
@ -222,9 +227,9 @@ int ipcOpenSocket(ipcHandle *&handle) {
|
||||
|
||||
memset(&cliaddr, 0, sizeof(cliaddr));
|
||||
cliaddr.sun_family = AF_UNIX;
|
||||
char temp[20];
|
||||
char temp[50];
|
||||
|
||||
// Create unique name for the socket.
|
||||
// Create unique name for the socket with path if SOCK_FOLDER is set.
|
||||
sprintf(temp, "%s%u", SOCK_FOLDER, getpid());
|
||||
|
||||
strcpy(cliaddr.sun_path, temp);
|
||||
|
Loading…
x
Reference in New Issue
Block a user