2006-06-03 [colin] 2.2.0cvs76
authorColin Leroy <colin@colino.net>
Sat, 3 Jun 2006 06:43:39 +0000 (06:43 +0000)
committerColin Leroy <colin@colino.net>
Sat, 3 Jun 2006 06:43:39 +0000 (06:43 +0000)
* src/mbox.c
Fix bug #962 (Manual and/or UI should
warn about incompatible locking
causing dataloss)

ChangeLog
PATCHSETS
configure.ac
src/mbox.c

index 2ac6160f23ca68c4e8cd6aaf1e13a38e8fd82c71..1431144b6ded0a2bcfc06304b05727ee466eb3cc 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2006-06-03 [colin]     2.2.0cvs76
+
+       * src/mbox.c
+               Fix bug #962 (Manual and/or UI should 
+               warn about incompatible locking 
+               causing dataloss)
+
 2006-06-02 [cleroy]    2.2.0cvs75
 
        * src/filtering.c
index e3f31226ce1197ac394bcc2c29324241e738c0dc..3e1eb202d716413c2c67174ac1893f70e670a26e 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.1.2.6 -r 1.1.2.7 manual/fr/glossary.xml;  cvs diff -u -r 1.1.2.3 -r 1.1.2.4 manual/fr/ack.xml;  cvs diff -u -r 1.1.2.3 -r 1.1.2.4 manual/ack.xml;  ) > 2.2.0cvs73.patchset
 ( cvs diff -u -r 1.115.2.88 -r 1.115.2.89 src/main.c;  cvs diff -u -r 1.150.2.65 -r 1.150.2.66 src/procmsg.c;  cvs diff -u -r 1.17.2.29 -r 1.17.2.30 src/send_message.c;  cvs diff -u -r 1.43.2.45 -r 1.43.2.46 src/toolbar.c;  ) > 2.2.0cvs74.patchset
 ( cvs diff -u -r 1.60.2.18 -r 1.60.2.19 src/filtering.c;  cvs diff -u -r 1.213.2.95 -r 1.213.2.96 src/folder.c;  cvs diff -u -r 1.150.2.66 -r 1.150.2.67 src/procmsg.c;  cvs diff -u -r 1.395.2.214 -r 1.395.2.215 src/summaryview.c;  ) > 2.2.0cvs75.patchset
+( cvs diff -u -r 1.28.2.15 -r 1.28.2.16 src/mbox.c;  ) > 2.2.0cvs76.patchset
index 8b4b06d42cb75b20bdd99a3d76ffa1d52eb1f6c3..0b7c48384824695578d514e7f0b66488bf3af6ef 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=2
 MICRO_VERSION=0
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=75
+EXTRA_VERSION=76
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index 21ed549508dfbe5ce8362859192a431aa2f291e6..f865aba06a23667ae4cf98aa32a7e2e6a12c65c1 100644 (file)
@@ -277,15 +277,30 @@ gint lock_mbox(const gchar *base, LockType type)
                g_free(lockfile);
        } else if (type == LOCK_FLOCK) {
                gint lockfd;
+#if HAVE_FCNTL_H
+               struct flock fl;
+               fl.l_type = F_WRLCK;
+               fl.l_whence = SEEK_SET;
+               fl.l_start = 0;
+               fl.l_len = 0;
+#endif
 
 #if HAVE_FLOCK
-               if ((lockfd = open(base, O_RDONLY)) < 0) {
+               if ((lockfd = open(base, O_RDWR)) < 0) {
 #else
                if ((lockfd = open(base, O_RDWR)) < 0) {
 #endif
                        FILE_OP_ERROR(base, "open");
                        return -1;
                }
+               
+#if HAVE_FCNTL_H
+               if (fcntl(lockfd, F_SETLK, &fl) == -1) {
+                       g_warning("can't fnctl %s (%s)", base, strerror(errno));
+                       return -1;
+               }
+#endif
+
 #if HAVE_FLOCK
                if (flock(lockfd, LOCK_EX|LOCK_NB) < 0) {
                        perror("flock");
@@ -329,6 +344,18 @@ gint unlock_mbox(const gchar *base, gint fd, LockType type)
 
                return 0;
        } else if (type == LOCK_FLOCK) {
+#if HAVE_FCNTL_H
+               struct flock fl;
+               fl.l_type = F_UNLCK;
+               fl.l_whence = SEEK_SET;
+               fl.l_start = 0;
+               fl.l_len = 0;
+
+               if (fcntl(fd, F_SETLK, &fl) == -1) {
+                       g_warning("can't fnctl %s", base);
+                       return -1;
+               }
+#endif
 #if HAVE_FLOCK
                if (flock(fd, LOCK_UN) < 0) {
                        perror("flock");