diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2021-05-01 11:55:48 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2021-05-01 12:22:02 +0300 |
commit | 5a5dddb6e1fc39efaeaa029d0b5fb7a29306fba4 (patch) | |
tree | d5c1a656797d2e694f6164480bbe45901ad11f39 /mail/copy.c | |
parent | 5daca02feaa90dcac68c03e479a0a61e51d2c7ca (diff) | |
download | mailutils-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 'mail/copy.c')
-rw-r--r-- | mail/copy.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/mail/copy.c b/mail/copy.c index 0d29bc679..8a2d2771c 100644 --- a/mail/copy.c +++ b/mail/copy.c @@ -97,6 +97,10 @@ append_to_file (char const *filename, msgset_t *msglist, int mark, mu_stream_t ostr, mstr; mu_message_t msg; mu_locker_t locker; + mu_locker_hints_t hints = { + .flags = MU_LOCKER_FLAG_TYPE | MU_LOCKER_FLAG_RETRY, + .type = MU_LOCKER_TYPE_KERNEL + }; mu_stream_stat_buffer stat; status = mu_file_stream_create (&ostr, filename, @@ -108,8 +112,7 @@ append_to_file (char const *filename, msgset_t *msglist, int mark, return 1; } - status = mu_locker_create (&locker, filename, - MU_LOCKER_KERNEL|MU_LOCKER_RETRY); + status = mu_locker_create_ext (&locker, filename, &hints); if (status) { mu_error (_("Cannot create locker %s: %s"), |