Commit 15d94efb 15d94efb33d688c9318bdad2e35a07d49327a8ec by Sergey Poznyakoff

Do not try to lock "/dev/null" mailboxes. These are used in several

programs (namely, comsat, imap4d, pop3d).
1 parent f431ce70
......@@ -98,14 +98,16 @@ locker_create (locker_t *plocker, const char *filename, int flags)
if(!l->dotlock)
{
free(l->file);
free(l);
free (l->file);
free (l);
return ENOMEM;
}
sprintf(l->dotlock, "%s.lock", l->file);
if (flags)
if (strcmp (filename, "/dev/null") == 0)
l->flags = MU_LOCKER_NULL;
else if (flags)
l->flags = flags;
else
l->flags = MU_LOCKER_DEFAULT;
......@@ -344,8 +346,10 @@ locker_lock (locker_t lock)
if (lock == NULL)
return EINVAL;
INVARIANT (lock);
if (lock->flags == MU_LOCKER_NULL)
return 0;
INVARIANT (lock)
/* Is the lock already applied? */
if (lock->refcnt > 0)
{
......@@ -511,6 +515,9 @@ locker_touchlock (locker_t lock)
if (!lock)
return MU_ERR_LOCKER_NULL;
if (lock->flags == MU_LOCKER_NULL)
return 0;
assert(lock->dotlock);
INVARIANT(lock);
......@@ -524,6 +531,12 @@ locker_touchlock (locker_t lock)
int
locker_unlock (locker_t lock)
{
if (!lock)
return MU_ERR_LOCKER_NULL;
if (lock->flags == MU_LOCKER_NULL)
return 0;
assert(lock->refcnt >= 0);
if (!lock)
......@@ -549,6 +562,7 @@ locker_unlock (locker_t lock)
return 0;
}
int
locker_remove_lock (locker_t lock)
{
......@@ -557,6 +571,9 @@ locker_remove_lock (locker_t lock)
if (!lock)
return MU_ERR_LOCKER_NULL;
if (lock->flags == MU_LOCKER_NULL)
return 0;
INVARIANT(lock);
/* If we hold the lock, do an unlock... */
......