1 # HG changeset patch |
1 # HG changeset patch |
2 # Parent 3cbad740cf65b90cb75768c7784ac22a8ee7622d |
2 # Parent 725ab374f90553e848d1c418c11003dab45ec07c |
3 |
3 |
4 diff -r 3cbad740cf65 src/transports/appendfile.c |
4 diff -r 725ab374f905 src/transports/appendfile.c |
5 --- a/src/transports/appendfile.c Fri Apr 01 14:06:51 2011 +0200 |
5 --- a/src/transports/appendfile.c Wed Apr 13 12:08:31 2011 +0200 |
6 +++ b/src/transports/appendfile.c Fri Apr 01 14:06:51 2011 +0200 |
6 +++ b/src/transports/appendfile.c Wed Apr 13 12:08:39 2011 +0200 |
7 @@ -13,6 +13,7 @@ |
7 @@ -13,6 +13,7 @@ |
8 |
8 |
9 #ifdef SUPPORT_MAILDIR |
9 #ifdef SUPPORT_MAILDIR |
10 #include "tf_maildir.h" |
10 #include "tf_maildir.h" |
11 +extern int lockfd; /* from tf_maildir */ // hs12 |
11 +extern int lockfd; /* from tf_maildir */ // hs12 |
12 #endif |
12 #endif |
13 |
13 |
14 |
14 |
15 @@ -239,6 +240,30 @@ |
15 @@ -241,6 +242,30 @@ |
16 TRUE /* quota_is_inclusive */ |
16 FALSE /* quota_filecount_no_check */ |
17 }; |
17 }; |
18 |
18 |
19 +void hs12_lock(int fd, int type, const char* msg) |
19 +void hs12_lock(int fd, int type, const char* msg) |
20 +{ |
20 +{ |
21 + struct timeval t0, t1; |
21 + struct timeval t0, t1; |
41 + return; |
41 + return; |
42 +} |
42 +} |
43 |
43 |
44 |
44 |
45 /************************************************* |
45 /************************************************* |
46 @@ -278,8 +303,8 @@ |
46 @@ -280,8 +305,8 @@ |
47 gid = gid; |
47 gid = gid; |
48 |
48 |
49 if (ob->expand_maildir_use_size_file) |
49 if (ob->expand_maildir_use_size_file) |
50 - ob->maildir_use_size_file = expand_check_condition(ob->expand_maildir_use_size_file, |
50 - ob->maildir_use_size_file = expand_check_condition(ob->expand_maildir_use_size_file, |
51 - US"`maildir_use_size_file` in transport", tblock->name); |
51 - US"`maildir_use_size_file` in transport", tblock->name); |
52 + ob->maildir_use_size_file = expand_check_condition(ob->expand_maildir_use_size_file, |
52 + ob->maildir_use_size_file = expand_check_condition(ob->expand_maildir_use_size_file, |
53 + US"`maildir_use_size_file` in transport", tblock->name); |
53 + US"`maildir_use_size_file` in transport", tblock->name); |
54 |
54 |
55 /* Loop for quota, quota_filecount, quota_warn_threshold, mailbox_size, |
55 /* Loop for quota, quota_filecount, quota_warn_threshold, mailbox_size, |
56 mailbox_filecount */ |
56 mailbox_filecount */ |
57 @@ -841,7 +866,7 @@ |
57 @@ -855,7 +880,7 @@ |
58 sigalrm_seen set if there has been a timeout |
58 sigalrm_seen set if there has been a timeout |
59 */ |
59 */ |
60 |
60 |
61 -static int |
61 -static int |
62 +int |
62 +int |
63 apply_lock(int fd, int fcntltype, BOOL dofcntl, int fcntltime, BOOL doflock, |
63 apply_lock(int fd, int fcntltype, BOOL dofcntl, int fcntltime, BOOL doflock, |
64 int flocktime) |
64 int flocktime) |
65 { |
65 { |
66 @@ -887,7 +912,6 @@ |
66 @@ -901,7 +926,6 @@ |
67 |
67 |
68 |
68 |
69 |
69 |
70 - |
70 - |
71 #ifdef SUPPORT_MBX |
71 #ifdef SUPPORT_MBX |
72 /************************************************* |
72 /************************************************* |
73 * Copy message into MBX mailbox * |
73 * Copy message into MBX mailbox * |
74 @@ -2417,18 +2441,19 @@ |
74 @@ -2433,18 +2457,19 @@ |
75 { |
75 { |
76 off_t size; |
76 off_t size; |
77 int filecount; |
77 int filecount; |
78 + uschar *excuse; |
78 + uschar *excuse; |
79 |
79 |
92 |
92 |
93 + |
93 + |
94 if (mailbox_size < 0) mailbox_size = size; |
94 if (mailbox_size < 0) mailbox_size = size; |
95 if (mailbox_filecount < 0) mailbox_filecount = filecount; |
95 if (mailbox_filecount < 0) mailbox_filecount = filecount; |
96 } |
96 } |
97 @@ -3125,6 +3150,12 @@ |
97 @@ -3154,6 +3179,12 @@ |
98 uschar *renamename = newname; |
98 uschar *renamename = newname; |
99 fd = -1; |
99 fd = -1; |
100 |
100 |
101 + /* we could get a timeout here, but we don't check for it. Thus it *may* |
101 + /* we could get a timeout here, but we don't check for it. Thus it *may* |
102 + happen, that we deliver during an active RECALC process. Shit happens and it |
102 + happen, that we deliver during an active RECALC process. Shit happens and it |
105 + if (lockfd >= 0) hs12_lock(lockfd, F_RDLCK, "for renaming temporary file"); |
105 + if (lockfd >= 0) hs12_lock(lockfd, F_RDLCK, "for renaming temporary file"); |
106 + |
106 + |
107 DEBUG(D_transport) debug_printf("renaming temporary file\n"); |
107 DEBUG(D_transport) debug_printf("renaming temporary file\n"); |
108 |
108 |
109 /* If there is no rename name set, we are in a non-maildir, non-mailstore |
109 /* If there is no rename name set, we are in a non-maildir, non-mailstore |
110 @@ -3245,6 +3276,7 @@ |
110 @@ -3274,6 +3305,7 @@ |
111 filename = dataname = NULL; /* Prevents attempt to unlink at end */ |
111 filename = dataname = NULL; /* Prevents attempt to unlink at end */ |
112 } |
112 } |
113 } /* maildir or mailstore */ |
113 } /* maildir or mailstore */ |
114 + |
114 + |
115 } /* successful write + close */ |
115 } /* successful write + close */ |
116 } /* isdirectory */ |
116 } /* isdirectory */ |
117 } /* write success */ |
117 } /* write success */ |
118 @@ -3280,6 +3312,11 @@ |
118 @@ -3309,6 +3341,11 @@ |
119 detected, in order to get the file closed and the lock file tidied away. */ |
119 detected, in order to get the file closed and the lock file tidied away. */ |
120 |
120 |
121 RETURN: |
121 RETURN: |
122 +if (lockfd >= 0) |
122 +if (lockfd >= 0) |
123 + { |
123 + { |
125 + (void)close(lockfd); |
125 + (void)close(lockfd); |
126 + } |
126 + } |
127 |
127 |
128 #ifdef SUPPORT_MBX |
128 #ifdef SUPPORT_MBX |
129 if (mbx_lockfd >= 0) |
129 if (mbx_lockfd >= 0) |
130 diff -r 3cbad740cf65 src/transports/appendfile.h |
130 diff -r 725ab374f905 src/transports/appendfile.h |
131 --- a/src/transports/appendfile.h Fri Apr 01 14:06:51 2011 +0200 |
131 --- a/src/transports/appendfile.h Wed Apr 13 12:08:31 2011 +0200 |
132 +++ b/src/transports/appendfile.h Fri Apr 01 14:06:51 2011 +0200 |
132 +++ b/src/transports/appendfile.h Wed Apr 13 12:08:39 2011 +0200 |
133 @@ -95,5 +95,8 @@ |
133 @@ -97,5 +97,8 @@ |
134 /* Function that is shared with tf_maildir.c */ |
134 /* Function that is shared with tf_maildir.c */ |
135 |
135 |
136 extern off_t check_dir_size(uschar *, int *, const pcre *); |
136 extern off_t check_dir_size(uschar *, int *, const pcre *); |
137 +extern int apply_lock(int fd, int fcntltype, BOOL dofcntl, int fcntltime, BOOL doflock, |
137 +extern int apply_lock(int fd, int fcntltype, BOOL dofcntl, int fcntltime, BOOL doflock, |
138 + int flocktime); |
138 + int flocktime); |
139 + |
139 + |
140 |
140 |
141 /* End of transports/appendfile.h */ |
141 /* End of transports/appendfile.h */ |
142 diff -r 3cbad740cf65 src/transports/tf_maildir.c |
142 diff -r 725ab374f905 src/transports/tf_maildir.c |
143 --- a/src/transports/tf_maildir.c Fri Apr 01 14:06:51 2011 +0200 |
143 --- a/src/transports/tf_maildir.c Wed Apr 13 12:08:31 2011 +0200 |
144 +++ b/src/transports/tf_maildir.c Fri Apr 01 14:06:51 2011 +0200 |
144 +++ b/src/transports/tf_maildir.c Wed Apr 13 12:08:39 2011 +0200 |
145 @@ -367,13 +367,16 @@ |
145 @@ -367,13 +367,16 @@ |
146 |
146 |
147 Returns: >=0 a file descriptor for an open maildirsize file |
147 Returns: >=0 a file descriptor for an open maildirsize file |
148 -1 there was an error opening or accessing the file |
148 -1 there was an error opening or accessing the file |
149 + or locking |
149 + or locking |
246 /* Return the sizes and the file descriptor, if any */ |
246 /* Return the sizes and the file descriptor, if any */ |
247 - |
247 - |
248 DEBUG(D_transport) debug_printf("returning maildir size=" OFF_T_FMT |
248 DEBUG(D_transport) debug_printf("returning maildir size=" OFF_T_FMT |
249 " filecount=%d\n", size, filecount); |
249 " filecount=%d\n", size, filecount); |
250 *returned_size = size; |
250 *returned_size = size; |
251 diff -r 3cbad740cf65 src/transports/tf_maildir.h |
251 diff -r 725ab374f905 src/transports/tf_maildir.h |
252 --- a/src/transports/tf_maildir.h Fri Apr 01 14:06:51 2011 +0200 |
252 --- a/src/transports/tf_maildir.h Wed Apr 13 12:08:31 2011 +0200 |
253 +++ b/src/transports/tf_maildir.h Fri Apr 01 14:06:51 2011 +0200 |
253 +++ b/src/transports/tf_maildir.h Wed Apr 13 12:08:39 2011 +0200 |
254 @@ -16,7 +16,7 @@ |
254 @@ -16,7 +16,7 @@ |
255 uschar *); |
255 uschar *); |
256 extern int maildir_ensure_sizefile(uschar *, |
256 extern int maildir_ensure_sizefile(uschar *, |
257 appendfile_transport_options_block *, const pcre *, |
257 appendfile_transport_options_block *, const pcre *, |
258 - const pcre *, off_t *, int *); |
258 - const pcre *, off_t *, int *); |