RE: Reply all - issue
[notmuch-archives.git] / 00 / d3b084ee50aed5d4b64b4443de0760834e76a4
1 Return-Path: <tomi.ollila@nixu.com>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id 6481D431FD0\r
6         for <notmuch@notmuchmail.org>; Mon,  2 Jan 2012 04:56:22 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 0\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
12         autolearn=disabled\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id PspL-I9nijmo for <notmuch@notmuchmail.org>;\r
16         Mon,  2 Jan 2012 04:56:21 -0800 (PST)\r
17 Received: from mail-gw3.nixu.fi (mail-gw3.nixu.fi [193.209.237.7])\r
18         (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
19         (No client certificate requested)\r
20         by olra.theworths.org (Postfix) with ESMTPS id 58009431FB6\r
21         for <notmuch@notmuchmail.org>; Mon,  2 Jan 2012 04:56:21 -0800 (PST)\r
22 Received: from pps.filterd (mail-gw3 [127.0.0.1])\r
23         by mail-gw3.nixu.fi (8.14.4/8.14.4) with SMTP id q02CqwbU004513;\r
24         Mon, 2 Jan 2012 14:56:15 +0200\r
25 Received: from taco2.nixu.fi (taco2.nixu.fi [194.197.118.31])\r
26         by mail-gw3.nixu.fi with ESMTP id 114cs0wwnv-1\r
27         (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
28         Mon, 02 Jan 2012 14:56:15 +0200\r
29 Received: from taco2.nixu.fi (taco2.nixu.fi [194.197.118.31])\r
30         by taco2.nixu.fi (8.14.3/8.14.3/Debian-5+lenny1) with ESMTP id\r
31         q02CuDPa028402; Mon, 2 Jan 2012 14:56:14 +0200\r
32 From: Tomi Ollila <tomi.ollila@iki.fi>\r
33 To: David Bremner <david@tethera.net>, Kazuo Teramoto <kaz.rag@gmail.com>,\r
34         notmuch@notmuchmail.org\r
35 Subject: Re: [PATCH 2/2] lib: call g_mime_init from notmuch_database_open\r
36 In-Reply-To: <87hb0h5tps.fsf@zancas.localnet>\r
37 References: <877h1e6r9d.fsf@zancas.localnet>\r
38         <1325282290-29565-1-git-send-email-kaz.rag@gmail.com>\r
39         <1325282290-29565-3-git-send-email-kaz.rag@gmail.com>\r
40         <87hb0h5tps.fsf@zancas.localnet>\r
41 User-Agent: Notmuch/0.10.2+157~g442d405 (http://notmuchmail.org) Emacs/23.3.1\r
42         (i686-pc-linux-gnu)\r
43 X-Face: HhBM'cA~<r"^Xv\KRN0P{vn'Y"Kd;zg_y3S[4)KSN~s?O\"QPoL\r
44         $[Xv_BD:i/F$WiEWax}R(MPS`^UaptOGD`*/=@\1lKoVa9tnrg0TW?"r7aRtgk[F\r
45         !)g;OY^,BjTbr)Np:%c_o'jj,Z\r
46 Date: Mon, 02 Jan 2012 14:56:13 +0200\r
47 Message-ID: <yf6obumz2j6.fsf@taco2.nixu.fi>\r
48 MIME-Version: 1.0\r
49 Content-Type: text/plain; charset=us-ascii\r
50 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.5.7110,\r
51  1.0.211,       0.0.0000        definitions=2012-01-02_03:2012-01-02, 2012-01-02,\r
52         1970-01-01 signatures=0\r
53 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0\r
54         ipscore=0 suspectscore=2\r
55         phishscore=0 bulkscore=0 adultscore=0 classifier=spam adjust=0\r
56         reason=mlx\r
57         scancount=1 engine=6.0.2-1012030000 definitions=main-1201020078\r
58 X-BeenThere: notmuch@notmuchmail.org\r
59 X-Mailman-Version: 2.1.13\r
60 Precedence: list\r
61 List-Id: "Use and development of the notmuch mail system."\r
62         <notmuch.notmuchmail.org>\r
63 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
64         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
65 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
66 List-Post: <mailto:notmuch@notmuchmail.org>\r
67 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
68 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
69         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
70 X-List-Received-Date: Mon, 02 Jan 2012 12:56:22 -0000\r
71 \r
72 On Fri, 30 Dec 2011 23:02:39 -0400, David Bremner <david@tethera.net> wrote:\r
73 > On Fri, 30 Dec 2011 19:58:10 -0200, Kazuo Teramoto <kaz.rag@gmail.com> wrote:\r
74 > > We need to call g_mime_init to correct initialize the structures needed\r
75 > > by gmime before using it.\r
76 > > ---\r
77 > >  lib/database.cc |    5 +++++\r
78  > >  1 files changed, 5 insertions(+), 0 deletions(-)\r
79\r
80 > I can confirm this patch (alone) fixes the segfault for me. and doesn't\r
81 > cause in test failures when applied against the release branch.  I'm\r
82 > considering pushing it into the 0.11 release. Any comments on that?\r
83 \r
84 Do it. The current implementation does not break anything (in our case\r
85 as we don't do g_mime_shutdown() (0, 1 or 2 times)... The usage needs to\r
86 be "fixed" soon after...\r
87 \r
88 > d\r
89 \r
90 .. my suggestions how to fix this:\r
91 \r
92 1) just call g_mime_init(0) without checking whether it is initialized\r
93    already. As it't return type is 'void' it can be expected to keep some\r
94    global storage (and reference count...). If it returned something else\r
95    it either returns common (singleton) instance (and keeps reference count)\r
96    or returns new instance each time called.... Never call g_mime_shutdown();\r
97    just let operating system free resources when program exits. The first\r
98    lines in g_mime_shutdown():\r
99 \r
100         if (--initialized)\r
101                 return;\r
102 \r
103    looks a bit suspicious -- what if application happens to call\r
104    g_mime_shutdown() too often and then trying to call g_mime_init() again...\r
105 \r
106 2) create function\r
107 \r
108   void\r
109   notmuch_g_type_init (void)\r
110   {\r
111         static int initialized;\r
112         if (initialized++)\r
113                 return;\r
114         g_mime_init(0)\r
115         atexit (g_mime_shutdown);\r
116   }\r
117 \r
118   and use that in place of g_mime_init() always (perhaps use macro trickery\r
119   to disallow g_mime_init (and g_mime_shutdown). \r
120 \r
121   Note that although atexit() makes pretty sure that in normal exit \r
122   g_mime_shutdown() is called due to various reasons that normal exit\r
123   case is not reached (dies by signal, usage of _exit, execve(2)\r
124   hardware failure, lost power etc.)(*). Therefore, IMO, I'd leave this\r
125   (particular) cleanup to be done by the operating system -- less, \r
126   simpler application code.\r
127 \r
128 \r
129 Tomi\r
130 \r
131 (*) I recall reading an article about 'design for failure' or 'expect\r
132     failure' like 5 years ago but cannot find it anymore. The point on that\r
133     article was that software can fail in any point (specially, compare\r
134     man 2 rename  and then around lines 580-610 in\r
135     http://git.busybox.net/busybox/tree/sysklogd/syslogd.c ). Since then\r
136     I've tried to prioritize in finalize things that matter early and leave\r
137     operating system to do other cleanpus for me (why do something yourself\r
138     that machine can do for you). Did you know that doing full windows\r
139     reboot is faster if the machine is just unplugged from power source\r
140     for a second and then restarted instead of doing "clean" reboot cycle.\r
141     Linux boots so fast I don't know if I'd notice the difference ;)\r