r228601 - Update r228592 for when gethostname() returns an error
Ben Langmuir
blangmuir at apple.com
Mon Feb 9 12:13:11 PST 2015
Author: benlangmuir
Date: Mon Feb 9 14:13:11 2015
New Revision: 228601
URL: http://llvm.org/viewvc/llvm-project?rev=228601&view=rev
Log:
Update r228592 for when gethostname() returns an error
If gethostname() is not successful, just skip adding the hostname to the
module hash. And don't bother setting hostname[255] = 0, since if
gethostname() is successful, it will be null-terminated already (and if
it's not successful we don't read the string now.
Modified:
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=228601&r1=228600&r2=228601&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Mon Feb 9 14:13:11 2015
@@ -2028,10 +2028,10 @@ std::string CompilerInvocation::getModul
// The LockFileManager cannot tell when processes from another host are
// running, so mangle the hostname in to the module hash to separate them.
char hostname[256];
- hostname[255] = 0;
hostname[0] = 0;
- gethostname(hostname, 255);
- code = hash_combine(code, StringRef(hostname));
+ if (gethostname(hostname, 255) == 0)
+ code = hash_combine(code, StringRef(hostname));
+ // Ignore failures in gethostname() by not including the hostname in the hash.
#endif
return llvm::APInt(64, code).toString(36, /*Signed=*/false);
More information about the cfe-commits
mailing list