From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id iMNMJoT6nGD6ngAAgWs5BA (envelope-from ) for ; Thu, 13 May 2021 12:08:04 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id gGDVIYT6nGBVcgAAbx9fmQ (envelope-from ) for ; Thu, 13 May 2021 10:08:04 +0000 Received: from mail.notmuchmail.org (nmbug.tethera.net [144.217.243.247]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 2D14D2FC39 for ; Thu, 13 May 2021 12:08:04 +0200 (CEST) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 36E422828F; Thu, 13 May 2021 06:07:36 -0400 (EDT) Received: from fethera.tethera.net (fethera.tethera.net [IPv6:2607:5300:60:c5::1]) by mail.notmuchmail.org (Postfix) with ESMTP id D8ED2271E9 for ; Thu, 13 May 2021 06:07:21 -0400 (EDT) Received: by fethera.tethera.net (Postfix, from userid 1001) id CAA8660018; Thu, 13 May 2021 06:07:21 -0400 (EDT) Received: (nullmailer pid 1460736 invoked by uid 1000); Thu, 13 May 2021 10:07:13 -0000 From: David Bremner To: notmuch@notmuchmail.org Cc: David Bremner Subject: [PATCH 4/7] CLI: centralize initialization in notmuch_client_init Date: Thu, 13 May 2021 07:07:07 -0300 Message-Id: <20210513100710.1460566-5-david@tethera.net> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210513100710.1460566-1-david@tethera.net> References: <20210513100710.1460566-1-david@tethera.net> MIME-Version: 1.0 Message-ID-Hash: R4MC6NHCBRWXRYIB6V2CKGYADTMIM2FH X-Message-ID-Hash: R4MC6NHCBRWXRYIB6V2CKGYADTMIM2FH X-MailFrom: bremner@tethera.net X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-notmuch.notmuchmail.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.1 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1620900484; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=X624iMydVN7/ppwLtbLdiB4QMfUfUp2AL+XpJESZUck=; b=S/pykiij+tEnadsnlGgLxKcY7Su3xV/Dr0I3kxTYNo5Hu0nkcExsBE3DBAb4RJEuIKhRZ7 DnZCgUQbmTdxvpy/1FiYPn0+zi9gswpXQE8Ebpap1Eu7HF1ChL8PTqo+0s/YuG7oCegXAN +7t9ZiDu4STq7gk9IS35PQG4ZKFwb2OT3DdMYj92UDBMgOUJCRuvL2FJd5BwB98+YNw/iB x8LbVf5TKISa3Fxn0Pq6Epq3qfURp4Mjb43go5Hp2ZrClECXEMgX29cUWIRUQ7hoy6+48w tTZTzDKni2ZveSgA8Ptlzb+Yg5YPYh2Ol3vlxGVhr7iz8VuSvaFkUpquWRJAjw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1620900484; a=rsa-sha256; cv=none; b=tWHJ0OqNp10Po063CDg4nqzKCnffjfuE3QLf/E/mo6/W4kbJZOKbKvDckodxMaUwIqZ54K HFvnhTAhduFojkRZDHXqSOTYh+oWJgTX1zXT5XQ/XAY3VpXoCGzvcDJh8G0F6+M78L59mP 7lkF7Kb4EKnY1vJzC2bNJrFul2gK/gnwowh6bfosj24zzjzgRkQ5dve/Q4LHwbnkLoNcef xX5U2OIADNGPQAtv4PdPpoTKkk/AVc4ESzVvRK5ccldlCoIxsXlRkhy0RlePcdXW23etkc U14y2rpuTYjrZjyhzajoqAnjaMrGyrNWyUbLh2XY9dGHI8guiJYQxRrpSv5Wbw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 144.217.243.247 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Spam-Score: 0.43 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 144.217.243.247 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: 2D14D2FC39 X-Spam-Score: 0.43 X-Migadu-Scanner: scn0.migadu.com X-TUID: MqQBvHduXIbR Initially make sure gmime_filter_reply initialization is thread-safe (assuming notmuch_client_init is only called once). For tidyness, also put talloc initialization in the new function. --- Makefile.local | 1 + gmime-filter-reply.c | 42 +++++++++++++++++++++--------------------- gmime-filter-reply.h | 2 ++ notmuch-client.h | 4 ++++ notmuch.c | 7 +------ 5 files changed, 29 insertions(+), 27 deletions(-) diff --git a/Makefile.local b/Makefile.local index bbb8f0b6..e12b94cd 100644 --- a/Makefile.local +++ b/Makefile.local @@ -231,6 +231,7 @@ notmuch_client_srcs = \ gmime-filter-reply.c \ hooks.c \ notmuch.c \ + notmuch-client-init.c \ notmuch-compact.c \ notmuch-config.c \ notmuch-count.c \ diff --git a/gmime-filter-reply.c b/gmime-filter-reply.c index 2b067669..35349cc8 100644 --- a/gmime-filter-reply.c +++ b/gmime-filter-reply.c @@ -43,29 +43,31 @@ static void filter_reset (GMimeFilter *filter); static GMimeFilterClass *parent_class = NULL; +static GType type = 0; +static const GTypeInfo info = { + .class_size = sizeof (GMimeFilterReplyClass), + .base_init = NULL, + .base_finalize = NULL, + .class_init = (GClassInitFunc) g_mime_filter_reply_class_init, + .class_finalize = NULL, + .class_data = NULL, + .instance_size = sizeof (GMimeFilterReply), + .n_preallocs = 0, + .instance_init = (GInstanceInitFunc) g_mime_filter_reply_init, + .value_table = NULL, +}; + + +void +g_mime_filter_reply_module_init (void) +{ + type = g_type_register_static (GMIME_TYPE_FILTER, "GMimeFilterReply", &info, (GTypeFlags) 0); + parent_class = (GMimeFilterClass *) g_type_class_ref (GMIME_TYPE_FILTER); +} GType g_mime_filter_reply_get_type (void) { - static GType type = 0; - - if (! type) { - static const GTypeInfo info = { - .class_size = sizeof (GMimeFilterReplyClass), - .base_init = NULL, - .base_finalize = NULL, - .class_init = (GClassInitFunc) g_mime_filter_reply_class_init, - .class_finalize = NULL, - .class_data = NULL, - .instance_size = sizeof (GMimeFilterReply), - .n_preallocs = 0, - .instance_init = (GInstanceInitFunc) g_mime_filter_reply_init, - .value_table = NULL, - }; - - type = g_type_register_static (GMIME_TYPE_FILTER, "GMimeFilterReply", &info, (GTypeFlags) 0); - } - return type; } @@ -76,8 +78,6 @@ g_mime_filter_reply_class_init (GMimeFilterReplyClass *klass, unused (void *clas GObjectClass *object_class = G_OBJECT_CLASS (klass); GMimeFilterClass *filter_class = GMIME_FILTER_CLASS (klass); - parent_class = (GMimeFilterClass *) g_type_class_ref (GMIME_TYPE_FILTER); - object_class->finalize = g_mime_filter_reply_finalize; filter_class->copy = filter_copy; diff --git a/gmime-filter-reply.h b/gmime-filter-reply.h index 7cdefcd1..988fe2d6 100644 --- a/gmime-filter-reply.h +++ b/gmime-filter-reply.h @@ -21,6 +21,8 @@ #include +void g_mime_filter_reply_module_init (void); + G_BEGIN_DECLS #define GMIME_TYPE_FILTER_REPLY (g_mime_filter_reply_get_type ()) diff --git a/notmuch-client.h b/notmuch-client.h index 270553ad..8227fea4 100644 --- a/notmuch-client.h +++ b/notmuch-client.h @@ -250,6 +250,10 @@ json_quote_chararray (const void *ctx, const char *str, const size_t len); char * json_quote_str (const void *ctx, const char *str); +/* notmuch-client-init.c */ + +void notmuch_client_init (void); + /* notmuch-config.c */ typedef enum { diff --git a/notmuch.c b/notmuch.c index 2429999c..9ca3a4be 100644 --- a/notmuch.c +++ b/notmuch.c @@ -464,15 +464,10 @@ main (int argc, char *argv[]) { } }; - talloc_enable_null_tracking (); + notmuch_client_init (); local = talloc_new (NULL); - g_mime_init (); -#if ! GLIB_CHECK_VERSION (2, 35, 1) - g_type_init (); -#endif - /* Globally default to the current output format version. */ notmuch_format_version = NOTMUCH_FORMAT_CUR; -- 2.30.2