commit 54d8140f6e0154c4af0c8c68e04e43b6d7e9c696
parent 418b5e9a7abbc5fc866dfb525b6688e6ecbe4f0d
Author: Michael Elkins <me@mutt.org>
Date: Wed, 19 Jun 2002 01:11:36 +0000
fixed unused var warning in imap_open()
locking cleanups from Oswald Buddenhagen <ossi@kde.org>
* don't need to stat the lockfile since it will always be size 0
* only remove lockfile when we actually succeeded in locking
Diffstat:
3 files changed, 14 insertions(+), 12 deletions(-)
diff --git a/AUTHORS b/AUTHORS
@@ -1 +1,5 @@
Michael Elkins <me@mutt.org>
+ * Author, Lead Developer
+
+Contributors:
+ Oswald Buddenhagen <ossi@kde.org>
diff --git a/imap.c b/imap.c
@@ -567,6 +567,8 @@ imap_open (config_t * box, unsigned int minuid, imap_t * imap, int flags)
int use_ssl = 0;
#endif
+ (void) flags;
+
if (imap)
{
/* determine whether or not we can reuse the existing session */
diff --git a/maildir.c b/maildir.c
@@ -34,24 +34,16 @@ static int
do_lock (int fd, int flag)
{
struct flock lck;
- struct stat sb;
-
- if (fstat (fd, &sb))
- {
- perror ("fstat");
- return -1;
- }
memset (&lck, 0, sizeof (lck));
lck.l_type = flag;
lck.l_whence = SEEK_SET;
lck.l_start = 0;
- lck.l_len = sb.st_size;
+ lck.l_len = 0;
if (fcntl (fd, F_SETLK, &lck))
{
perror ("fcntl");
- close (fd);
return -1;
}
@@ -141,6 +133,7 @@ maildir_lock (mailbox_t * m)
if (do_lock (m->lockfd, F_WRLCK))
{
close (m->lockfd);
+ m->lockfd = -1;
return -1;
}
return 0;
@@ -149,12 +142,16 @@ maildir_lock (mailbox_t * m)
static void
maildir_unlock (mailbox_t * m)
{
- char path[_POSIX_PATH_MAX];
+ char path[_POSIX_PATH_MAX];
+ if (m->lockfd != -1)
+ {
snprintf (path, sizeof (path), "%s/isynclock", m->path);
unlink (path);
do_lock (m->lockfd, F_UNLCK);
close (m->lockfd);
+ m->lockfd = -1;
+ }
}
/* open a maildir mailbox.
@@ -314,8 +311,7 @@ maildir_open (const char *path, int flags)
err:
if (m->db)
dbm_close (m->db);
- if (m->lockfd != -1)
- maildir_unlock (m);
+ maildir_unlock (m);
free (m->path);
free (m);
return NULL;