1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-02 01:01:48 +02:00

openLockFile: Return an AutoCloseFD

This commit is contained in:
Eelco Dolstra 2017-01-25 12:51:35 +01:00
parent c0f2f4eeef
commit a55f589720
No known key found for this signature in database
GPG key ID: 8170B4726D7198DE
3 changed files with 7 additions and 7 deletions

View file

@ -1,6 +1,6 @@
#pragma once
#include "types.hh"
#include "util.hh"
namespace nix {
@ -9,7 +9,7 @@ namespace nix {
/* Open (possibly create) a lock file and return the file descriptor.
-1 is returned if create is false and the lock could not be opened
because it doesn't exist. Any other error throws an exception. */
int openLockFile(const Path & path, bool create);
AutoCloseFD openLockFile(const Path & path, bool create);
/* Delete an open lock file. */
void deleteLockFile(const Path & path, int fd);
@ -19,7 +19,7 @@ enum LockType { ltRead, ltWrite, ltNone };
bool lockFile(int fd, LockType lockType, bool wait);
class PathLocks
class PathLocks
{
private:
typedef std::pair<int, Path> FDPair;