Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(137)

Side by Side Diff: lib/Support/LockFileManager.cpp

Issue 939073008: Rebased PNaCl localmods in LLVM to 223109 (Closed)
Patch Set: undo localmod Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « lib/Support/CrashRecoveryContext.cpp ('k') | lib/Support/MemoryBuffer.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //===--- LockFileManager.cpp - File-level Locking Utility------------------===// 1 //===--- LockFileManager.cpp - File-level Locking Utility------------------===//
2 // 2 //
3 // The LLVM Compiler Infrastructure 3 // The LLVM Compiler Infrastructure
4 // 4 //
5 // This file is distributed under the University of Illinois Open Source 5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details. 6 // License. See LICENSE.TXT for details.
7 // 7 //
8 //===----------------------------------------------------------------------===// 8 //===----------------------------------------------------------------------===//
9 #include "llvm/Support/LockFileManager.h" 9 #include "llvm/Support/LockFileManager.h"
10 #include "llvm/ADT/STLExtras.h" 10 #include "llvm/ADT/STLExtras.h"
11 #include "llvm/ADT/StringExtras.h" 11 #include "llvm/ADT/StringExtras.h"
12 #include "llvm/Support/Errc.h" 12 #include "llvm/Support/Errc.h"
13 #include "llvm/Support/FileSystem.h" 13 #include "llvm/Support/FileSystem.h"
14 #include "llvm/Support/MemoryBuffer.h" 14 #include "llvm/Support/MemoryBuffer.h"
15 #include "llvm/Support/Path.h" 15 #include "llvm/Support/Path.h"
16 #include "llvm/Support/raw_ostream.h" 16 #include "llvm/Support/raw_ostream.h"
17 #include <sys/stat.h> 17 #include <sys/stat.h>
18 #include <sys/types.h> 18 #include <sys/types.h>
19 #if LLVM_ON_WIN32 19 #if LLVM_ON_WIN32
20 #include <windows.h> 20 #include <windows.h>
21 #endif 21 #endif
22 #if LLVM_ON_UNIX 22 #if LLVM_ON_UNIX
23 #include <unistd.h> 23 #include <unistd.h>
24 #endif 24 #endif
25 using namespace llvm; 25 using namespace llvm;
26 26
27 // @LOCALMOD-BEGIN
28 #if !defined(PNACL_BROWSER_TRANSLATOR)
29 // @LOCALMOD-END
30
27 /// \brief Attempt to read the lock file with the given name, if it exists. 31 /// \brief Attempt to read the lock file with the given name, if it exists.
28 /// 32 ///
29 /// \param LockFileName The name of the lock file to read. 33 /// \param LockFileName The name of the lock file to read.
30 /// 34 ///
31 /// \returns The process ID of the process that owns this lock file 35 /// \returns The process ID of the process that owns this lock file
32 Optional<std::pair<std::string, int> > 36 Optional<std::pair<std::string, int> >
33 LockFileManager::readLockFile(StringRef LockFileName) { 37 LockFileManager::readLockFile(StringRef LockFileName) {
34 // Read the owning host and PID out of the lock file. If it appears that the 38 // Read the owning host and PID out of the lock file. If it appears that the
35 // owning process is dead, the lock file is invalid. 39 // owning process is dead, the lock file is invalid.
36 ErrorOr<std::unique_ptr<MemoryBuffer>> MBOrErr = 40 ErrorOr<std::unique_ptr<MemoryBuffer>> MBOrErr =
(...skipping 14 matching lines...) Expand all
51 if (processStillExecuting(Owner.first, Owner.second)) 55 if (processStillExecuting(Owner.first, Owner.second))
52 return Owner; 56 return Owner;
53 } 57 }
54 58
55 // Delete the lock file. It's invalid anyway. 59 // Delete the lock file. It's invalid anyway.
56 sys::fs::remove(LockFileName); 60 sys::fs::remove(LockFileName);
57 return None; 61 return None;
58 } 62 }
59 63
60 bool LockFileManager::processStillExecuting(StringRef Hostname, int PID) { 64 bool LockFileManager::processStillExecuting(StringRef Hostname, int PID) {
61 #if LLVM_ON_UNIX && !defined(__ANDROID__) 65 // @LOCALMOD-BEGIN
66 #if LLVM_ON_UNIX && !defined(__ANDROID__) && !defined(__native_client__)
67 // @LOCALMOD-END
62 char MyHostname[256]; 68 char MyHostname[256];
63 MyHostname[255] = 0; 69 MyHostname[255] = 0;
64 MyHostname[0] = 0; 70 MyHostname[0] = 0;
65 gethostname(MyHostname, 255); 71 gethostname(MyHostname, 255);
66 // Check whether the process is dead. If so, we're done. 72 // Check whether the process is dead. If so, we're done.
67 if (MyHostname == Hostname && getsid(PID) == -1 && errno == ESRCH) 73 if (MyHostname == Hostname && getsid(PID) == -1 && errno == ESRCH)
68 return false; 74 return false;
69 #endif 75 #endif
70 76
71 return true; 77 return true;
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 #if LLVM_ON_WIN32 262 #if LLVM_ON_WIN32
257 Interval < MaxSeconds * 1000 263 Interval < MaxSeconds * 1000
258 #else 264 #else
259 Interval.tv_sec < (time_t)MaxSeconds 265 Interval.tv_sec < (time_t)MaxSeconds
260 #endif 266 #endif
261 ); 267 );
262 268
263 // Give up. 269 // Give up.
264 return Res_Timeout; 270 return Res_Timeout;
265 } 271 }
272
273 #endif // __native_client__ @LOCALMOD
OLDNEW
« no previous file with comments | « lib/Support/CrashRecoveryContext.cpp ('k') | lib/Support/MemoryBuffer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698