1 # HG changeset patch |
1 # HG changeset patch |
2 # Parent 52fd74447005c5bef643b4dbe767791d334312ad |
2 # Parent d242bf664878ef31577058ed193d7c04eb27f6d0 |
3 |
3 |
4 diff -r 52fd74447005 OS/Makefile-Linux |
4 diff -r d242bf664878 OS/Makefile-Linux |
5 --- a/OS/Makefile-Linux Thu Feb 24 17:19:04 2011 +0100 |
5 --- a/OS/Makefile-Linux Thu Feb 24 20:12:03 2011 +0100 |
6 +++ b/OS/Makefile-Linux Thu Feb 24 17:20:54 2011 +0100 |
6 +++ b/OS/Makefile-Linux Thu Feb 24 20:29:13 2011 +0100 |
7 @@ -16,7 +16,7 @@ |
7 @@ -16,7 +16,7 @@ |
8 DBMLIB = -ldb |
8 DBMLIB = -ldb |
9 USE_DB = yes |
9 USE_DB = yes |
10 |
10 |
11 -LIBS = -lnsl -lcrypt -lm |
11 -LIBS = -lnsl -lcrypt -lm |
12 +LIBS = -lnsl -lcrypt -lm -lrt |
12 +LIBS = -lnsl -lcrypt -lm -lrt |
13 LIBRESOLV = -lresolv |
13 LIBRESOLV = -lresolv |
14 |
14 |
15 X11=/usr/X11R6 |
15 X11=/usr/X11R6 |
16 diff -r 52fd74447005 src/transports/appendfile.c |
16 diff -r d242bf664878 src/transports/appendfile.c |
17 --- a/src/transports/appendfile.c Thu Feb 24 17:19:04 2011 +0100 |
17 --- a/src/transports/appendfile.c Thu Feb 24 20:12:03 2011 +0100 |
18 +++ b/src/transports/appendfile.c Thu Feb 24 17:20:54 2011 +0100 |
18 +++ b/src/transports/appendfile.c Thu Feb 24 20:29:13 2011 +0100 |
19 @@ -13,6 +13,7 @@ |
19 @@ -13,6 +13,7 @@ |
20 |
20 |
21 #ifdef SUPPORT_MAILDIR |
21 #ifdef SUPPORT_MAILDIR |
22 #include "tf_maildir.h" |
22 #include "tf_maildir.h" |
23 +extern int lockfd; /* from tf_maildir */ // hs12 |
23 +extern int lockfd; /* from tf_maildir */ // hs12 |
133 + (void)close(lockfd); |
133 + (void)close(lockfd); |
134 + } |
134 + } |
135 |
135 |
136 #ifdef SUPPORT_MBX |
136 #ifdef SUPPORT_MBX |
137 if (mbx_lockfd >= 0) |
137 if (mbx_lockfd >= 0) |
138 diff -r 52fd74447005 src/transports/appendfile.h |
138 diff -r d242bf664878 src/transports/appendfile.h |
139 --- a/src/transports/appendfile.h Thu Feb 24 17:19:04 2011 +0100 |
139 --- a/src/transports/appendfile.h Thu Feb 24 20:12:03 2011 +0100 |
140 +++ b/src/transports/appendfile.h Thu Feb 24 17:20:54 2011 +0100 |
140 +++ b/src/transports/appendfile.h Thu Feb 24 20:29:13 2011 +0100 |
141 @@ -95,5 +95,8 @@ |
141 @@ -95,5 +95,8 @@ |
142 /* Function that is shared with tf_maildir.c */ |
142 /* Function that is shared with tf_maildir.c */ |
143 |
143 |
144 extern off_t check_dir_size(uschar *, int *, const pcre *); |
144 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, |
145 +extern int apply_lock(int fd, int fcntltype, BOOL dofcntl, int fcntltime, BOOL doflock, |
146 + int flocktime); |
146 + int flocktime); |
147 + |
147 + |
148 |
148 |
149 /* End of transports/appendfile.h */ |
149 /* End of transports/appendfile.h */ |
150 diff -r 52fd74447005 src/transports/tf_maildir.c |
150 diff -r d242bf664878 src/transports/tf_maildir.c |
151 --- a/src/transports/tf_maildir.c Thu Feb 24 17:19:04 2011 +0100 |
151 --- a/src/transports/tf_maildir.c Thu Feb 24 20:12:03 2011 +0100 |
152 +++ b/src/transports/tf_maildir.c Thu Feb 24 17:20:54 2011 +0100 |
152 +++ b/src/transports/tf_maildir.c Thu Feb 24 20:29:13 2011 +0100 |
153 @@ -367,13 +367,16 @@ |
153 @@ -367,13 +367,16 @@ |
154 |
154 |
155 Returns: >=0 a file descriptor for an open maildirsize file |
155 Returns: >=0 a file descriptor for an open maildirsize file |
156 -1 there was an error opening or accessing the file |
156 -1 there was an error opening or accessing the file |
157 + or locking |
157 + or locking |
166 - int *returned_filecount) |
166 - int *returned_filecount) |
167 + int *returned_filecount, uschar **excuse) |
167 + int *returned_filecount, uschar **excuse) |
168 { |
168 { |
169 int count, fd; |
169 int count, fd; |
170 off_t cached_quota = 0; |
170 off_t cached_quota = 0; |
171 @@ -381,25 +384,48 @@ |
171 @@ -381,19 +384,41 @@ |
172 int filecount = 0; |
172 int filecount = 0; |
173 int linecount = 0; |
173 int linecount = 0; |
174 off_t size = 0; |
174 off_t size = 0; |
175 -uschar *filename; |
175 -uschar *filename; |
176 +uschar *filename, *lockname, *hitchname; |
176 +uschar *filename, *lockname, *hitchname; |
209 + |
209 + |
210 |
210 |
211 DEBUG(D_transport) debug_printf("looking for maildirsize in %s\n", path); |
211 DEBUG(D_transport) debug_printf("looking for maildirsize in %s\n", path); |
212 fd = Uopen(filename, O_RDWR|O_APPEND, ob->mode ? ob->mode : 0600); |
212 fd = Uopen(filename, O_RDWR|O_APPEND, ob->mode ? ob->mode : 0600); |
213 -if (fd < 0) |
213 -if (fd < 0) |
214 - { |
214 +if (fd < 0) |
215 +if (fd < 0) { |
215 { |
216 if (errno != ENOENT) return -1; |
216 if (errno != ENOENT) return -1; |
217 DEBUG(D_transport) |
217 DEBUG(D_transport) |
218 debug_printf("%s does not exist: recalculating\n", filename); |
218 @@ -401,6 +426,7 @@ |
219 goto RECALCULATE; |
219 goto RECALCULATE; |
220 - } |
220 } |
221 +} |
221 |
222 +(void)lseek(fd, 0, SEEK_SET); |
222 + |
223 + |
|
224 |
|
225 /* The file has been successfully opened. Check that the cached quota value is |
223 /* The file has been successfully opened. Check that the cached quota value is |
226 still correct, and that the size of the file is still small enough. If so, |
224 still correct, and that the size of the file is still small enough. If so, |
|
225 compute the maildir size from the file. */ |
227 @@ -520,16 +546,12 @@ |
226 @@ -520,16 +546,12 @@ |
228 } |
227 } |
229 } |
228 } |
230 } |
229 } |
231 - |
230 - |
256 + } |
255 + } |
257 + |
256 + |
258 if (fd >= 0) (void)close(fd); |
257 if (fd >= 0) (void)close(fd); |
259 old_latest = 0; |
258 old_latest = 0; |
260 filecount = 0; |
259 filecount = 0; |
261 @@ -586,10 +615,14 @@ |
260 @@ -588,8 +617,11 @@ |
262 (void)close(fd); |
|
263 fd = -2; |
|
264 } |
261 } |
265 + hs12_lock(lockfd, F_UNLCK, "done recalc"); |
|
266 } |
262 } |
267 |
263 |
268 + hs12_lock(lockfd, F_UNLCK, "done check"); |
264 + hs12_lock(lockfd, F_UNLCK, "done check"); |
269 + |
265 + |
270 + |
266 + |
271 + |
267 + |
272 /* Return the sizes and the file descriptor, if any */ |
268 /* Return the sizes and the file descriptor, if any */ |
273 - |
269 - |
274 DEBUG(D_transport) debug_printf("returning maildir size=" OFF_T_FMT |
270 DEBUG(D_transport) debug_printf("returning maildir size=" OFF_T_FMT |
275 " filecount=%d\n", size, filecount); |
271 " filecount=%d\n", size, filecount); |
276 *returned_size = size; |
272 *returned_size = size; |
277 diff -r 52fd74447005 src/transports/tf_maildir.h |
273 diff -r d242bf664878 src/transports/tf_maildir.h |
278 --- a/src/transports/tf_maildir.h Thu Feb 24 17:19:04 2011 +0100 |
274 --- a/src/transports/tf_maildir.h Thu Feb 24 20:12:03 2011 +0100 |
279 +++ b/src/transports/tf_maildir.h Thu Feb 24 17:20:54 2011 +0100 |
275 +++ b/src/transports/tf_maildir.h Thu Feb 24 20:29:13 2011 +0100 |
280 @@ -16,7 +16,7 @@ |
276 @@ -16,7 +16,7 @@ |
281 uschar *); |
277 uschar *); |
282 extern int maildir_ensure_sizefile(uschar *, |
278 extern int maildir_ensure_sizefile(uschar *, |
283 appendfile_transport_options_block *, const pcre *, |
279 appendfile_transport_options_block *, const pcre *, |
284 - const pcre *, off_t *, int *); |
280 - const pcre *, off_t *, int *); |