|
Lines 60-66
static FILE *fopen_lock(const char *name, const char *type, FILE **l_file) {
Link Here
|
| 60 |
snprintf(buf, sizeof(buf), "%s.lock", name); |
60 |
snprintf(buf, sizeof(buf), "%s.lock", name); |
| 61 |
|
61 |
|
| 62 |
if ((*l_file = fopen(buf, "a")) == NULL) { |
62 |
if ((*l_file = fopen(buf, "a")) == NULL) { |
| 63 |
univention_debug(UV_DEBUG_LDAP, UV_DEBUG_WARN, "Could not open lock file [%s]", buf); |
63 |
univention_debug(UV_DEBUG_LISTENER, UV_DEBUG_WARN, "Could not open lock file [%s]", buf); |
| 64 |
return NULL; |
64 |
return NULL; |
| 65 |
} |
65 |
} |
| 66 |
|
66 |
|
|
Lines 69-75
static FILE *fopen_lock(const char *name, const char *type, FILE **l_file) {
Link Here
|
| 69 |
int rc = lockf(l_fd, F_TLOCK, 0); |
69 |
int rc = lockf(l_fd, F_TLOCK, 0); |
| 70 |
if (!rc) |
70 |
if (!rc) |
| 71 |
break; |
71 |
break; |
| 72 |
univention_debug(UV_DEBUG_LDAP, UV_DEBUG_INFO, "Could not get lock for file [%s]; count=%d", buf, count); |
72 |
univention_debug(UV_DEBUG_LISTENER, UV_DEBUG_INFO, "Could not get lock for file [%s]; count=%d", buf, count); |
| 73 |
count++; |
73 |
count++; |
| 74 |
if (count > listener_lock_count) { |
74 |
if (count > listener_lock_count) { |
| 75 |
univention_debug(UV_DEBUG_TRANSFILE, UV_DEBUG_ERROR, "Could not get lock for file [%s]; exit", buf); |
75 |
univention_debug(UV_DEBUG_TRANSFILE, UV_DEBUG_ERROR, "Could not get lock for file [%s]; exit", buf); |
|
Lines 79-89
static FILE *fopen_lock(const char *name, const char *type, FILE **l_file) {
Link Here
|
| 79 |
} |
79 |
} |
| 80 |
|
80 |
|
| 81 |
if ((file = fopen(name, type)) == NULL) { |
81 |
if ((file = fopen(name, type)) == NULL) { |
| 82 |
univention_debug(UV_DEBUG_LDAP, UV_DEBUG_WARN, "Could not open file [%s]", name); |
82 |
univention_debug(UV_DEBUG_LISTENER, UV_DEBUG_WARN, "Could not open file [%s]", name); |
| 83 |
|
83 |
|
| 84 |
int rc = lockf(l_fd, F_ULOCK, 0); |
84 |
int rc = lockf(l_fd, F_ULOCK, 0); |
| 85 |
if (rc) |
85 |
if (rc) |
| 86 |
univention_debug(UV_DEBUG_LDAP, UV_DEBUG_WARN, "Failed to unlock %s: %s", buf, strerror(errno)); |
86 |
univention_debug(UV_DEBUG_LISTENER, UV_DEBUG_WARN, "Failed to unlock %s: %s", buf, strerror(errno)); |
| 87 |
fclose(*l_file); |
87 |
fclose(*l_file); |
| 88 |
*l_file = NULL; |
88 |
*l_file = NULL; |
| 89 |
} |
89 |
} |
|
Lines 105-111
static int fclose_lock(FILE **file, FILE **l_file) {
Link Here
|
| 105 |
int l_fd = fileno(*l_file); |
105 |
int l_fd = fileno(*l_file); |
| 106 |
int rc = lockf(l_fd, F_ULOCK, 0); |
106 |
int rc = lockf(l_fd, F_ULOCK, 0); |
| 107 |
if (rc) |
107 |
if (rc) |
| 108 |
univention_debug(UV_DEBUG_LDAP, UV_DEBUG_ALL, "unlockf(): %d", rc); |
108 |
univention_debug(UV_DEBUG_LISTENER, UV_DEBUG_ALL, "unlockf(): %d", rc); |
| 109 |
rv |= fclose(*l_file); |
109 |
rv |= fclose(*l_file); |
| 110 |
*l_file = NULL; |
110 |
*l_file = NULL; |
| 111 |
} |
111 |
} |
| 112 |
- |
|
|