netatalk
4.4.0
Free and Open Source Apple Filing Protocol (AFP) Server
Loading...
Searching...
No Matches
ad_lock.h
Go to the documentation of this file.
1
#ifndef LIBATALK_ADOUBLE_AD_PRIVATE_H
2
#define LIBATALK_ADOUBLE_AD_PRIVATE_H 1
3
4
#include <
atalk/adouble.h
>
5
6
/* this is so that we can keep lists of fds referencing the same file
7
* around. that way, we can honor locks created by the same process
8
* with the same file. */
9
10
#define adf_lock_init(a) do { \
11
(a)->adf_lockmax = 0; \
12
(a)->adf_lockcount = 0; \
13
(a)->adf_lock = NULL; \
14
} while (0)
15
16
#define adf_lock_free(a) do { \
17
int i; \
18
if (!(a)->adf_lock) \
19
break; \
20
for (i = 0; i < (a)->adf_lockcount; i++) { \
21
adf_lock_t *lock = (a)->adf_lock + i; \
22
/* Always release fcntl lock when freeing array */
\
23
if ((a)->adf_fd >= 0) { \
24
lock->lock.l_type = F_UNLCK; \
25
if (fcntl((a)->adf_fd, F_SETLK, &lock->lock) == -1) { \
26
LOG(log_warning, logtype_default, \
27
"adf_lock_free: fcntl unlock failed on fd %d: %s", \
28
(a)->adf_fd, strerror(errno)); \
29
} \
30
} \
31
/* Only free refcount memory when last reference */
\
32
if (--(*lock->refcount) < 1) { \
33
free(lock->refcount); \
34
} \
35
} \
36
free((a)->adf_lock); \
37
adf_lock_init(a); \
38
} while (0)
39
40
#endif
/* libatalk/adouble/ad_private.h */
adouble.h
Part of Netatalk's AppleDouble implementatation.
libatalk
adouble
ad_lock.h
Generated by
1.15.0