Do not try to lock "/dev/null" mailboxes. These are used in several
programs (namely, comsat, imap4d, pop3d).
Showing
1 changed file
with
21 additions
and
4 deletions
... | @@ -98,14 +98,16 @@ locker_create (locker_t *plocker, const char *filename, int flags) | ... | @@ -98,14 +98,16 @@ locker_create (locker_t *plocker, const char *filename, int flags) |
98 | 98 | ||
99 | if(!l->dotlock) | 99 | if(!l->dotlock) |
100 | { | 100 | { |
101 | free(l->file); | 101 | free (l->file); |
102 | free(l); | 102 | free (l); |
103 | return ENOMEM; | 103 | return ENOMEM; |
104 | } | 104 | } |
105 | 105 | ||
106 | sprintf(l->dotlock, "%s.lock", l->file); | 106 | sprintf(l->dotlock, "%s.lock", l->file); |
107 | 107 | ||
108 | if (flags) | 108 | if (strcmp (filename, "/dev/null") == 0) |
109 | l->flags = MU_LOCKER_NULL; | ||
110 | else if (flags) | ||
109 | l->flags = flags; | 111 | l->flags = flags; |
110 | else | 112 | else |
111 | l->flags = MU_LOCKER_DEFAULT; | 113 | l->flags = MU_LOCKER_DEFAULT; |
... | @@ -344,8 +346,10 @@ locker_lock (locker_t lock) | ... | @@ -344,8 +346,10 @@ locker_lock (locker_t lock) |
344 | if (lock == NULL) | 346 | if (lock == NULL) |
345 | return EINVAL; | 347 | return EINVAL; |
346 | 348 | ||
347 | INVARIANT (lock); | 349 | if (lock->flags == MU_LOCKER_NULL) |
350 | return 0; | ||
348 | 351 | ||
352 | INVARIANT (lock) | ||
349 | /* Is the lock already applied? */ | 353 | /* Is the lock already applied? */ |
350 | if (lock->refcnt > 0) | 354 | if (lock->refcnt > 0) |
351 | { | 355 | { |
... | @@ -511,6 +515,9 @@ locker_touchlock (locker_t lock) | ... | @@ -511,6 +515,9 @@ locker_touchlock (locker_t lock) |
511 | if (!lock) | 515 | if (!lock) |
512 | return MU_ERR_LOCKER_NULL; | 516 | return MU_ERR_LOCKER_NULL; |
513 | 517 | ||
518 | if (lock->flags == MU_LOCKER_NULL) | ||
519 | return 0; | ||
520 | |||
514 | assert(lock->dotlock); | 521 | assert(lock->dotlock); |
515 | 522 | ||
516 | INVARIANT(lock); | 523 | INVARIANT(lock); |
... | @@ -524,6 +531,12 @@ locker_touchlock (locker_t lock) | ... | @@ -524,6 +531,12 @@ locker_touchlock (locker_t lock) |
524 | int | 531 | int |
525 | locker_unlock (locker_t lock) | 532 | locker_unlock (locker_t lock) |
526 | { | 533 | { |
534 | if (!lock) | ||
535 | return MU_ERR_LOCKER_NULL; | ||
536 | |||
537 | if (lock->flags == MU_LOCKER_NULL) | ||
538 | return 0; | ||
539 | |||
527 | assert(lock->refcnt >= 0); | 540 | assert(lock->refcnt >= 0); |
528 | 541 | ||
529 | if (!lock) | 542 | if (!lock) |
... | @@ -549,6 +562,7 @@ locker_unlock (locker_t lock) | ... | @@ -549,6 +562,7 @@ locker_unlock (locker_t lock) |
549 | 562 | ||
550 | return 0; | 563 | return 0; |
551 | } | 564 | } |
565 | |||
552 | int | 566 | int |
553 | locker_remove_lock (locker_t lock) | 567 | locker_remove_lock (locker_t lock) |
554 | { | 568 | { |
... | @@ -557,6 +571,9 @@ locker_remove_lock (locker_t lock) | ... | @@ -557,6 +571,9 @@ locker_remove_lock (locker_t lock) |
557 | if (!lock) | 571 | if (!lock) |
558 | return MU_ERR_LOCKER_NULL; | 572 | return MU_ERR_LOCKER_NULL; |
559 | 573 | ||
574 | if (lock->flags == MU_LOCKER_NULL) | ||
575 | return 0; | ||
576 | |||
560 | INVARIANT(lock); | 577 | INVARIANT(lock); |
561 | 578 | ||
562 | /* If we hold the lock, do an unlock... */ | 579 | /* If we hold the lock, do an unlock... */ | ... | ... |
-
Please register or sign in to post a comment