--- mlmmj-maintd.c 12 Nov 2004 01:28:32 -0000 1.42
+++ mlmmj-maintd.c 13 Jan 2005 10:19:04 -0000
@@ -178,16 +178,29 @@
{
struct stat st;
time_t t;
+ int fd, ret = 0;
+
+ fd = open(old, O_RDWR);
+ if(fd < 0)
+ return 0;
+
+ if(myexcllock(fd) < 0) {
+ close(fd);
+ return 0;
+ }
stat(old, &st);
t = time(NULL);
- if(t - st.st_mtime > age) {
- rename(old, new);
- return 1;
- }
+ if(t - st.st_mtime > age)
+ if(rename(old, new) < 0)
+ ret = 0;
+ else
+ ret = 1;
- return 0;
+ myunlock(fd);
+ close(fd);
+ return ret;
}
int resend_queue(const char *listdir, const char *mlmmjsend)
{
struct stat st;
time_t t;
+ int fd, ret = 0;
+
+ fd = open(old, O_RDWR);
+ if(fd < 0)
+ return 0;
+
+ if(myexcllock(fd) < 0) {
+ close(fd);
+ return 0;
+ }
stat(old, &st);
t = time(NULL);
- if(t - st.st_mtime > age) {
- rename(old, new);
- return 1;
- }
+ if(t - st.st_mtime > age)
+ if(rename(old, new) < 0)
+ ret = 0;
+ else
+ ret = 1;
- return 0;
+ myunlock(fd);
+ close(fd);
+ return ret;
}
int resend_queue(const char *listdir, const char *mlmmjsend)