1 # HG changeset patch |
1 # HG changeset patch |
2 # Parent d242bf664878ef31577058ed193d7c04eb27f6d0 |
2 # Parent 64ab3b6277037986519edb924069a75ba339de2a |
3 |
3 |
4 diff -r d242bf664878 OS/Makefile-Linux |
4 diff -r 64ab3b627703 src/transports/appendfile.c |
5 --- a/OS/Makefile-Linux Thu Feb 24 20:12:03 2011 +0100 |
5 --- a/src/transports/appendfile.c Thu Feb 24 20:29:56 2011 +0100 |
6 +++ b/OS/Makefile-Linux Thu Feb 24 20:29:13 2011 +0100 |
6 +++ b/src/transports/appendfile.c Thu Feb 24 22:29:28 2011 +0100 |
7 @@ -16,7 +16,7 @@ |
|
8 DBMLIB = -ldb |
|
9 USE_DB = yes |
|
10 |
|
11 -LIBS = -lnsl -lcrypt -lm |
|
12 +LIBS = -lnsl -lcrypt -lm -lrt |
|
13 LIBRESOLV = -lresolv |
|
14 |
|
15 X11=/usr/X11R6 |
|
16 diff -r d242bf664878 src/transports/appendfile.c |
|
17 --- a/src/transports/appendfile.c Thu Feb 24 20:12:03 2011 +0100 |
|
18 +++ b/src/transports/appendfile.c Thu Feb 24 20:29:13 2011 +0100 |
|
19 @@ -13,6 +13,7 @@ |
7 @@ -13,6 +13,7 @@ |
20 |
8 |
21 #ifdef SUPPORT_MAILDIR |
9 #ifdef SUPPORT_MAILDIR |
22 #include "tf_maildir.h" |
10 #include "tf_maildir.h" |
23 +extern int lockfd; /* from tf_maildir */ // hs12 |
11 +extern int lockfd; /* from tf_maildir */ // hs12 |
28 TRUE /* quota_is_inclusive */ |
16 TRUE /* quota_is_inclusive */ |
29 }; |
17 }; |
30 |
18 |
31 +void hs12_lock(int fd, int type, const char* msg) |
19 +void hs12_lock(int fd, int type, const char* msg) |
32 +{ |
20 +{ |
33 + struct timespec t0, t1; |
21 + struct timeval t0, t1; |
34 + clock_gettime(CLOCK_REALTIME, &t0); |
22 + gettimeofday(&t0, NULL); |
35 + const char *ltype = |
23 + const char *ltype = |
36 + type == F_UNLCK ? "UNLOCK" |
24 + type == F_UNLCK ? "UNLOCK" |
37 + : type == F_RDLCK ? "READ LOCK" |
25 + : type == F_RDLCK ? "READ LOCK" |
38 + : "WRITE LOCK"; |
26 + : "WRITE LOCK"; |
39 + |
27 + |
41 + |
29 + |
42 + |
30 + |
43 + (void)apply_lock(fd, type, 1, 120, 0, 0); |
31 + (void)apply_lock(fd, type, 1, 120, 0, 0); |
44 + if (type == F_UNLCK) return; |
32 + if (type == F_UNLCK) return; |
45 + |
33 + |
46 + clock_gettime(CLOCK_REALTIME, &t1); |
34 + gettimeofday(&t1, NULL); |
47 + t1.tv_sec -= t0.tv_sec; |
35 + t1.tv_sec -= t0.tv_sec; |
48 + t1.tv_nsec -= t0.tv_nsec; |
36 + t1.tv_usec -= t0.tv_usec; |
49 + if (t1.tv_nsec < 0) { t1.tv_sec--; t1.tv_nsec *= -1; } |
37 + if (t1.tv_usec < 0) { t1.tv_usec *= -1; t1.tv_sec--; } |
50 + DEBUG(D_transport) |
38 + DEBUG(D_transport) |
51 + debug_printf("%s: %s was waiting for %d.%09d seconds\n", |
39 + debug_printf("%s: %s was waiting for %d.%06d seconds\n", |
52 + ltype, msg, t1.tv_sec, t1.tv_nsec); |
40 + ltype, msg, t1.tv_sec, t1.tv_usec); |
53 + return; |
41 + return; |
54 +} |
42 +} |
55 |
43 |
56 |
44 |
57 /************************************************* |
45 /************************************************* |
133 + (void)close(lockfd); |
121 + (void)close(lockfd); |
134 + } |
122 + } |
135 |
123 |
136 #ifdef SUPPORT_MBX |
124 #ifdef SUPPORT_MBX |
137 if (mbx_lockfd >= 0) |
125 if (mbx_lockfd >= 0) |
138 diff -r d242bf664878 src/transports/appendfile.h |
126 diff -r 64ab3b627703 src/transports/appendfile.h |
139 --- a/src/transports/appendfile.h Thu Feb 24 20:12:03 2011 +0100 |
127 --- a/src/transports/appendfile.h Thu Feb 24 20:29:56 2011 +0100 |
140 +++ b/src/transports/appendfile.h Thu Feb 24 20:29:13 2011 +0100 |
128 +++ b/src/transports/appendfile.h Thu Feb 24 22:29:28 2011 +0100 |
141 @@ -95,5 +95,8 @@ |
129 @@ -95,5 +95,8 @@ |
142 /* Function that is shared with tf_maildir.c */ |
130 /* Function that is shared with tf_maildir.c */ |
143 |
131 |
144 extern off_t check_dir_size(uschar *, int *, const pcre *); |
132 extern off_t check_dir_size(uschar *, int *, const pcre *); |
145 +extern int apply_lock(int fd, int fcntltype, BOOL dofcntl, int fcntltime, BOOL doflock, |
133 +extern int apply_lock(int fd, int fcntltype, BOOL dofcntl, int fcntltime, BOOL doflock, |
146 + int flocktime); |
134 + int flocktime); |
147 + |
135 + |
148 |
136 |
149 /* End of transports/appendfile.h */ |
137 /* End of transports/appendfile.h */ |
150 diff -r d242bf664878 src/transports/tf_maildir.c |
138 diff -r 64ab3b627703 src/transports/tf_maildir.c |
151 --- a/src/transports/tf_maildir.c Thu Feb 24 20:12:03 2011 +0100 |
139 --- a/src/transports/tf_maildir.c Thu Feb 24 20:29:56 2011 +0100 |
152 +++ b/src/transports/tf_maildir.c Thu Feb 24 20:29:13 2011 +0100 |
140 +++ b/src/transports/tf_maildir.c Thu Feb 24 22:29:28 2011 +0100 |
153 @@ -367,13 +367,16 @@ |
141 @@ -367,13 +367,16 @@ |
154 |
142 |
155 Returns: >=0 a file descriptor for an open maildirsize file |
143 Returns: >=0 a file descriptor for an open maildirsize file |
156 -1 there was an error opening or accessing the file |
144 -1 there was an error opening or accessing the file |
157 + or locking |
145 + or locking |
268 /* Return the sizes and the file descriptor, if any */ |
256 /* Return the sizes and the file descriptor, if any */ |
269 - |
257 - |
270 DEBUG(D_transport) debug_printf("returning maildir size=" OFF_T_FMT |
258 DEBUG(D_transport) debug_printf("returning maildir size=" OFF_T_FMT |
271 " filecount=%d\n", size, filecount); |
259 " filecount=%d\n", size, filecount); |
272 *returned_size = size; |
260 *returned_size = size; |
273 diff -r d242bf664878 src/transports/tf_maildir.h |
261 diff -r 64ab3b627703 src/transports/tf_maildir.h |
274 --- a/src/transports/tf_maildir.h Thu Feb 24 20:12:03 2011 +0100 |
262 --- a/src/transports/tf_maildir.h Thu Feb 24 20:29:56 2011 +0100 |
275 +++ b/src/transports/tf_maildir.h Thu Feb 24 20:29:13 2011 +0100 |
263 +++ b/src/transports/tf_maildir.h Thu Feb 24 22:29:28 2011 +0100 |
276 @@ -16,7 +16,7 @@ |
264 @@ -16,7 +16,7 @@ |
277 uschar *); |
265 uschar *); |
278 extern int maildir_ensure_sizefile(uschar *, |
266 extern int maildir_ensure_sizefile(uschar *, |
279 appendfile_transport_options_block *, const pcre *, |
267 appendfile_transport_options_block *, const pcre *, |
280 - const pcre *, off_t *, int *); |
268 - const pcre *, off_t *, int *); |