aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2020-06-14 13:16:41 +0300
committerSergey Poznyakoff <gray@gnu.org>2020-06-14 13:16:41 +0300
commit3d9bdf4a0efd58202aa2b847d1fdc0afb2760345 (patch)
tree5cbbe136c02b18021adb3b441a29de6eb2619bdf
parent49de98a30b8b5b45d30bcd4b8136a5b4cfe80fcd (diff)
downloadwydawca-3d9bdf4a0efd58202aa2b847d1fdc0afb2760345.tar.gz
wydawca-3d9bdf4a0efd58202aa2b847d1fdc0afb2760345.tar.bz2
Use grecs with wordsplit v1.1
m---------grecs0
-rw-r--r--modules/mailutils/mod_mailutils.c25
2 files changed, 9 insertions, 16 deletions
diff --git a/grecs b/grecs
-Subproject b47bfb2cc836d3961bd0b8a4748e5dbb42e3727
+Subproject 893d875a4065acb757fef55876c391b1dd07004
diff --git a/modules/mailutils/mod_mailutils.c b/modules/mailutils/mod_mailutils.c
index 2ca231d..ca27a8e 100644
--- a/modules/mailutils/mod_mailutils.c
+++ b/modules/mailutils/mod_mailutils.c
@@ -23,11 +23,13 @@
#include <wydawca/cfg.h>
#include <mailutils/mailutils.h>
#include <wydawca/wordsplit.h>
+#include <pthread.h>
#define WY_MODULE mod_mailutils
-static int mailer_opened;
static mu_mailer_t mailer;
+static pthread_mutex_t mailer_mutex = PTHREAD_MUTEX_INITIALIZER;
+
static mu_address_t admin_address;
static mu_address_t from_address;
unsigned long mail_admin_mask;
@@ -354,18 +356,14 @@ mail_send_message(mu_address_t rcpt, const char *text, const char *signer_key)
mu_debug_set_category_level(MU_DEBCAT_MAILER, level);
}
- if (!mailer_opened) {
+ pthread_mutex_lock(&mailer_mutex);
if ((rc = mu_mailer_open(mailer, 0))) {
mu_url_t url = NULL;
mu_mailer_get_url(mailer, &url);
wy_log(LOG_CRIT, _("opening mailer `%s' failed: %s"),
url ? mu_url_to_string(url) : "(unknown URL)",
mu_strerror(rc));
- return;
- }
- mailer_opened = 1;
- }
-
+ } else {
if (signer_key)
sign_message(&msg, signer_key);
@@ -375,6 +373,10 @@ mail_send_message(mu_address_t rcpt, const char *text, const char *signer_key)
wy_log(LOG_CRIT, _("cannot send message: %s"), mu_strerror(rc));
}
+ mu_mailer_close(mailer);
+ }
+ pthread_mutex_unlock(&mailer_mutex);
+
mu_message_destroy(&msg, mu_message_get_owner(msg));
}
@@ -602,15 +604,6 @@ wy_config(grecs_node_t *node)
return evt;
}
-void
-wy_flush(void)
-{
- if (mailer_opened) {
- mu_mailer_close(mailer);
- mailer_opened = 0;
- }
-}
-
static mu_address_t
get_uploader_email(wy_triplet_t *trp, const char **errp)
{

Return to:

Send suggestions and report system problems to the System administrator.