MCPcopy Create free account
hub / github.com/git/git / flock_acquire

Function flock_acquire

reftable/system.c:61–85  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

59}
60
61int flock_acquire(struct reftable_flock *l, const char *target_path,
62 long timeout_ms)
63{
64 struct lock_file *lockfile;
65 int err;
66
67 lockfile = reftable_malloc(sizeof(*lockfile));
68 if (!lockfile)
69 return REFTABLE_OUT_OF_MEMORY_ERROR;
70
71 err = hold_lock_file_for_update_timeout(lockfile, target_path, LOCK_NO_DEREF,
72 timeout_ms);
73 if (err < 0) {
74 reftable_free(lockfile);
75 if (errno == EEXIST)
76 return REFTABLE_LOCK_ERROR;
77 return REFTABLE_IO_ERROR;
78 }
79
80 l->fd = get_lock_file_fd(lockfile);
81 l->path = get_lock_file_path(lockfile);
82 l->priv = lockfile;
83
84 return 0;
85}
86
87int flock_close(struct reftable_flock *l)
88{

Callers 2

stack_compact_rangeFunction · 0.85

Calls 5

reftable_mallocFunction · 0.85
reftable_freeFunction · 0.85
get_lock_file_fdFunction · 0.85
get_lock_file_pathFunction · 0.85

Tested by

no test coverage detected