summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2021-05-01 11:55:48 +0300
committerSergey Poznyakoff <gray@gnu.org>2021-05-01 12:22:02 +0300
commit5a5dddb6e1fc39efaeaa029d0b5fb7a29306fba4 (patch)
treed5c1a656797d2e694f6164480bbe45901ad11f39 /lib
parent5daca02feaa90dcac68c03e479a0a61e51d2c7ca (diff)
downloadmailutils-5a5dddb6e1fc39efaeaa029d0b5fb7a29306fba4.tar.gz
mailutils-5a5dddb6e1fc39efaeaa029d0b5fb7a29306fba4.tar.bz2
Revise the mailbox locking functions.
The locker is created by the following call: mu_locker_create_ext(&locker, filename, &hints); The last arguments points to a structure mu_locker_hints_t, which defines the settings for the locker. NULL value implies default. Settings of an existing locker can be modified using the following call: mu_locker_modify(locker, &hints); Current settings can be examined using mu_locker_get_hints. The functions mu_locker_destroy, mu_locker_lock_mode, mu_locker_lock, mu_locker_touchlock, mu_locker_unlock, and mu_locker_remove_lock remained unchanged. Rest of functions is deprecated, but retained for a couple of releases for the sake of backward compatibility. Constants (locker types, flags, etc) are also revisited. This commit also fixes a bug in mu_spawnvp function, which was discovered when testing external lockers. * include/mailutils/locker.h: Major rewrite. (MU_LOCKER_DEFAULT_EXPIRE_TIME) (MU_LOCKER_DEFAULT_RETRY_COUNT) (MU_LOCKER_DEFAULT_RETRY_SLEEP) (MU_LOCKER_DEFAULT_EXT_LOCKER): New defines. (mu_locker_hints_t): New data type. (MU_LOCKER_FLAG_RETRY) (MU_LOCKER_FLAG_EXPIRE_TIME) (MU_LOCKER_FLAG_CHECK_PID) (MU_LOCKER_FLAG_TYPE,MU_LOCKER_FLAGS_ALL): New defines. (mu_locker_create_ext, mu_locker_modify) (mu_locker_get_hints): New functions. (mu_locker_create,mu_locker_set_default_flags) (mu_locker_set_default_retry_timeout) (mu_locker_set_default_retry_count) (mu_locker_set_default_expire_timeout) (mu_locker_set_default_external_program) (mu_locker_set_flags,mu_locker_mod_flags) (mu_locker_set_expire_time,mu_locker_set_retries) (mu_locker_set_retry_sleep,mu_locker_set_external) (mu_locker_get_flags,mu_locker_get_expire_time) (mu_locker_get_retries,mu_locker_get_retry_sleep): Mark as deprecated. * libmailutils/base/locker.c: Rewrite. * libmailutils/cli/stdcapa.c: New locking statements: type and retry-sleep. retry-timeout is deprecated. * libmailutils/tests/lck.c: Use new locker functions. * libmailutils/tests/lock.at: Test the external locker. * libmailutils/base/spawnvp.c (mu_spawnvp): Restore the default SIGCHLD handler while waiting for the process to terminate. * dotlock/dotlock.c: Use new locker functions. * lib/manlock.c: Likewise. * libmailutils/base/amd.c: Likewise. * libmu_dbm/berkeley.c: Likewise. * libmu_sieve/extensions/vacation.c: Likewise. * libproto/dotmail/dotmail.c: Likewise. * libproto/mbox/mboxrd.c: Likewise. * mail/copy.c: Likewise. * mda/lmtpd/lmtpd.c: Modify mu_locker_defaults instead of using deprecated functions. * mda/mda/mda.c: Likewise. * mda/putmail/putmail.c: Likewise. * NEWS: Document changes. * configure.ac: Version 3.12.90. * doc/texinfo/Makefile.am: Add programs/dotlock.texi * doc/texinfo/programs.texi: Rewrite the locking section. New section: dotlock. * doc/texinfo/programs/dotlock.texi: New file.
Diffstat (limited to 'lib')
-rw-r--r--lib/manlock.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/lib/manlock.c b/lib/manlock.c
index 0c32115cc..e06387807 100644
--- a/lib/manlock.c
+++ b/lib/manlock.c
@@ -128,14 +128,17 @@ mailbox_open_and_lock (mu_mailbox_t mbox, int flags)
if (lock)
{
- status = mu_locker_get_flags (lock, &flags);
+ mu_locker_hints_t hints;
+
+ hints.flags = MU_LOCKER_FLAG_TYPE;
+ status = mu_locker_get_hints (lock, &hints);
if (status)
{
- mu_diag_funcall (MU_DIAG_ERROR, "mu_locker_get_flags", urlstr,
+ mu_diag_funcall (MU_DIAG_ERROR, "mu_locker_get_hints", urlstr,
status);
return MU_ERR_FAILURE;
}
- if (flags & MU_LOCKER_NULL)
+ if (hints.type == MU_LOCKER_TYPE_NULL)
lock = NULL;
}
@@ -157,10 +160,10 @@ mailbox_open_and_lock (mu_mailbox_t mbox, int flags)
if (!fname)
return MU_ERR_FAILURE;
- status = mu_locker_create (&lock, fname, 0);
+ status = mu_locker_create_ext (&lock, fname, NULL);
if (status)
{
- mu_diag_funcall (MU_DIAG_ERROR, "mu_locker_create", fname, status);
+ mu_diag_funcall (MU_DIAG_ERROR, "mu_locker_create_ext", fname, status);
free (fname);
return MU_ERR_FAILURE;
}
@@ -245,13 +248,14 @@ manlock_lock (mu_mailbox_t mbox)
mu_locker_t lock = NULL;
const char *name;
int status;
-
+ mu_locker_hints_t hints = { .flags = MU_LOCKER_FLAG_CHECK_PID };
+
if (!manlock_mandatory_locking)
return 0;
mu_mailbox_get_url (mbox, &url);
name = mu_url_to_string (url);
- mu_mailbox_get_locker (mbox, &lock);
- mu_locker_mod_flags (lock, MU_LOCKER_PID, mu_locker_set_bit);
+ mu_mailbox_get_locker (mbox, &lock);
+ mu_locker_modify (lock, &hints);
if ((status = mu_locker_lock (lock)))
{
mu_diag_output (MU_DIAG_NOTICE, _("locking mailbox `%s' failed: %s"),

Return to:

Send suggestions and report system problems to the System administrator.