Re: [PATCH v2 5/5] cli: lazily create the crypto gpg context only when needed
authorDaniel Kahn Gillmor <dkg@fifthhorseman.net>
Fri, 18 May 2012 20:37:09 +0000 (16:37 +2000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:47:14 +0000 (09:47 -0800)
8b/a2158e62fe27a6d22ce1e51b386aa738dd7930 [new file with mode: 0644]

diff --git a/8b/a2158e62fe27a6d22ce1e51b386aa738dd7930 b/8b/a2158e62fe27a6d22ce1e51b386aa738dd7930
new file mode 100644 (file)
index 0000000..fb94a55
--- /dev/null
@@ -0,0 +1,130 @@
+Return-Path: <dkg@fifthhorseman.net>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id E0271431FB6\r
+       for <notmuch@notmuchmail.org>; Fri, 18 May 2012 13:37:19 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
+       autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id GuKB1eiofPX8 for <notmuch@notmuchmail.org>;\r
+       Fri, 18 May 2012 13:37:19 -0700 (PDT)\r
+Received: from che.mayfirst.org (che.mayfirst.org [209.234.253.108])\r
+       by olra.theworths.org (Postfix) with ESMTP id 53809431FAE\r
+       for <notmuch@notmuchmail.org>; Fri, 18 May 2012 13:37:19 -0700 (PDT)\r
+Received: from [192.168.23.207] (dsl254-070-154.nyc1.dsl.speakeasy.net\r
+       [216.254.70.154])\r
+       by che.mayfirst.org (Postfix) with ESMTPSA id E0385F970\r
+       for <notmuch@notmuchmail.org>; Fri, 18 May 2012 16:37:14 -0400 (EDT)\r
+Message-ID: <4FB6B2F5.6090105@fifthhorseman.net>\r
+Date: Fri, 18 May 2012 16:37:09 -0400\r
+From: Daniel Kahn Gillmor <dkg@fifthhorseman.net>\r
+User-Agent: Mozilla/5.0 (X11; Linux i686;\r
+       rv:10.0.3) Gecko/20120329 Icedove/10.0.3\r
+MIME-Version: 1.0\r
+To: Notmuch Mail <notmuch@notmuchmail.org>\r
+Subject: Re: [PATCH v2 5/5] cli: lazily create the crypto gpg context only\r
+       when needed\r
+References: <1337362357-31281-1-git-send-email-jrollins@finestructure.net>\r
+       <1337362357-31281-2-git-send-email-jrollins@finestructure.net>\r
+       <1337362357-31281-3-git-send-email-jrollins@finestructure.net>\r
+       <1337362357-31281-4-git-send-email-jrollins@finestructure.net>\r
+       <1337362357-31281-5-git-send-email-jrollins@finestructure.net>\r
+       <1337362357-31281-6-git-send-email-jrollins@finestructure.net>\r
+       <20120518192157.GV11804@mit.edu>\r
+       <87txzd9su3.fsf@servo.finestructure.net>\r
+In-Reply-To: <87txzd9su3.fsf@servo.finestructure.net>\r
+X-Enigmail-Version: 1.4.1\r
+Content-Type: multipart/signed; micalg=pgp-sha512;\r
+       protocol="application/pgp-signature";\r
+       boundary="------------enig95E528317834EF181F89AF5F"\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+Reply-To: notmuch <notmuch@notmuchmail.org>\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Fri, 18 May 2012 20:37:20 -0000\r
+\r
+This is an OpenPGP/MIME signed message (RFC 2440 and 3156)\r
+--------------enig95E528317834EF181F89AF5F\r
+Content-Type: text/plain; charset=UTF-8\r
+Content-Transfer-Encoding: quoted-printable\r
+\r
+On 05/18/2012 03:45 PM, Jameson Graef Rollins wrote:\r
+> On Fri, May 18 2012, Austin Clements <amdragon@MIT.EDU> wrote:\r
+>> It's slightly awkward that it's the caller's responsibility to free\r
+>> this lazily constructed object.  That should probably be documented.\r
+>> We could more carefully reference count it, but I think that would\r
+>> actually be worse because the reference count would probably bounce\r
+>> through zero frequently.\r
+>=20\r
+> I agree that this is awkward.  Is there a suggestion on how to do it\r
+> better?  We only want to initialize it if it's needed, and only\r
+> _mime_node_create knows that.  And we don't want to free it with\r
+> _mime_node_context_free, or something, only to have to reinitialize it\r
+> again with the next node or message.  Thoughts?\r
+\r
+You could provide a "destructor" function for notmuch_crypto_t, which\r
+whoever is responsible for the struct would need to call when they are\r
+ready to dispose of it.\r
+\r
+The destructor would just destroy any GMIME crypto contexts pointed to\r
+by the struct, and reset those pointers to NULL.\r
+\r
+Since the common workflow is a singleton notmuch_crypto_t that is a\r
+subobject of the singleton notmuch_params_t, you could just call that\r
+destructor function before the notmuch_params_t falls out of scope.\r
+\r
+If you want to be fancy/symmetric, you could use the same pattern to\r
+create a "destructor" function for notmuch_params_t (it would just\r
+invoke the destructor on its crypto member), but this seems like\r
+overkill to me, and not in line with the talloc approach of the rest of\r
+the codebase.\r
+\r
+I agree that it's a little awkward, but i think there's something of an\r
+impedance mismatch between gmime's object interface and notmuch's use of\r
+talloc and friends.\r
+\r
+       --dkg\r
+\r
+\r
+--------------enig95E528317834EF181F89AF5F\r
+Content-Type: application/pgp-signature; name="signature.asc"\r
+Content-Description: OpenPGP digital signature\r
+Content-Disposition: attachment; filename="signature.asc"\r
+\r
+-----BEGIN PGP SIGNATURE-----\r
+Version: GnuPG v1.4.12 (GNU/Linux)\r
+Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/\r
+\r
+iQJ8BAEBCgBmBQJPtrL1XxSAAAAAAC4AKGlzc3Vlci1mcHJAbm90YXRpb25zLm9w\r
+ZW5wZ3AuZmlmdGhob3JzZW1hbi5uZXQwRUU1QkU5NzkyODJEODBCOUY3NTQwRjFD\r
+Q0QyRUQ5NEQyMTczOUU5AAoJEMzS7ZTSFznpm0gQAKXRfjkE3yzlbGVGfOj8HzP4\r
+nLHpm5fmPUkd6cZegq51a21lNHkO02zKGQonPHO2mUQHnZ3616sdK/BqBiBebB8b\r
+sXWwl+d2n8OOnxNh9L/I4ihSL5mn86+fC6eTR/TVQjVE7jKSdkK0pRSbZUN8atYd\r
+JirQ2TyyqUr4IVaD3RGHdeOU/cAPbPLjbS7YcdRep0ImfFSADZmvZE1weImy721S\r
+0v4otH87fim5trf3tBIpJqFFfgXMMxmlw+L2xFGGewdnEwliB8v0se+pTJiABjHW\r
+u8l3EUU5Y7GRzjv3RoLLdUooergHQi2I9Z+AZK1fcVwWicxLhVWIXuOcJ4KpknNi\r
+MCuN5+S+EGCvK8lcfbUyy5UiDm5fF270xR/mAeTbm2/hQ3Y+MAFRuhT4ZZIlpMOP\r
+Ldzk92B/zSh4mxRCZtoi6lLnRsd6B3GP2VRlHs5caKXG3weQhGTQIO7QmpcIcAFf\r
+Rp+eH83OgaTQ2UEmzfQLVMlenF+NBykurRJ2//bC7kHbliMj0NKp5DqRnWChjLiB\r
+oBBE4CMjkPYCX1PWnS/XJhwL/DZAvPNTghqIDq3hcAZRu13Hc0xXpIAUTx3lYOfc\r
+TCPamfMs1ZhogJDjNOfhhRo+KQgjPKpR2HIDn2VU3xMlTHG7PquuLY2WkqPoYAsP\r
+dBw+rfzJywAASGm1WxtC\r
+=W4+Y\r
+-----END PGP SIGNATURE-----\r
+\r
+--------------enig95E528317834EF181F89AF5F--\r