Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/marian-nmt/nccl.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Sergeev <alexander.sergeev@live.com>2018-11-20 04:39:44 +0300
committerSylvain Jeaugey <sjeaugey@nvidia.com>2018-11-20 04:39:44 +0300
commitd7a58cfa5865c4f627a128c3238cc72502649881 (patch)
tree5300167228ca7b7048938f837d65ed01d6b78cd2
parent3c6e25210bb1b544748937e5db74db0b9679b95e (diff)
Generate host-hash for P2P and SHM based on $(readlink /proc/self/ns/uts) + $(readlink /proc/self/ns/mnt) (#156)
-rw-r--r--src/misc/utils.cu17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/misc/utils.cu b/src/misc/utils.cu
index 986bd61..d517267 100644
--- a/src/misc/utils.cu
+++ b/src/misc/utils.cu
@@ -33,17 +33,24 @@ uint64_t getHash(const char* string) {
* that will be unique for both bare-metal and container instances
* Equivalent of a hash of;
*
- * $(hostname) $(readlink /proc/self/ns/uts)
+ * $(hostname) $(readlink /proc/self/ns/uts) $(readlink /proc/self/ns/mnt)
*/
uint64_t getHostHash(void) {
char uname[1024];
// Start off with the hostname
(void) getHostName(uname, sizeof(uname));
- int hlen = strlen(uname);
- int len = readlink("/proc/self/ns/uts", uname+hlen, sizeof(uname)-1-hlen);
+ int offset = strlen(uname);
+ int len;
+ // $(readlink /proc/self/ns/uts)
+ len = readlink("/proc/self/ns/uts", uname+offset, sizeof(uname)-1-offset);
if (len < 0) len = 0;
-
- uname[hlen+len]='\0';
+ offset += len;
+ // $(readlink /proc/self/ns/mnt)
+ len = readlink("/proc/self/ns/mnt", uname+offset, sizeof(uname)-1-offset);
+ if (len < 0) len = 0;
+ offset += len;
+ // Trailing '\0'
+ uname[offset]='\0';
TRACE(INIT,"unique hostname '%s'", uname);
return getHash(uname);