| OLD | NEW |
| (Empty) |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "ui/ozone/platform/drm/gpu/gpu_lock.h" | |
| 6 | |
| 7 #include <sys/file.h> | |
| 8 #include <unistd.h> | |
| 9 | |
| 10 #include "base/logging.h" | |
| 11 #include "base/posix/eintr_wrapper.h" | |
| 12 | |
| 13 namespace ui { | |
| 14 | |
| 15 namespace { | |
| 16 const char kGpuLockFile[] = "/run/frecon"; | |
| 17 } | |
| 18 | |
| 19 GpuLock::GpuLock() { | |
| 20 fd_ = open(kGpuLockFile, O_RDWR); | |
| 21 if (fd_ < 0) { | |
| 22 PLOG(ERROR) << "Failed to open lock file '" << kGpuLockFile << "'"; | |
| 23 return; | |
| 24 } | |
| 25 | |
| 26 VLOG(1) << "Taking write lock on '" << kGpuLockFile << "'"; | |
| 27 if (HANDLE_EINTR(flock(fd_, LOCK_EX))) | |
| 28 PLOG(ERROR) << "Error while trying to get lock on '" << kGpuLockFile << "'"; | |
| 29 | |
| 30 VLOG(1) << "Done trying to take write lock on '" << kGpuLockFile << "'"; | |
| 31 } | |
| 32 | |
| 33 GpuLock::~GpuLock() { | |
| 34 // Failed to open the lock file, so nothing to do here. | |
| 35 if (fd_ < 0) | |
| 36 return; | |
| 37 | |
| 38 VLOG(1) << "Releasing write lock on '" << kGpuLockFile << "'"; | |
| 39 close(fd_); | |
| 40 } | |
| 41 | |
| 42 } // namespace ui | |
| OLD | NEW |