Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 5113A429E21 for ; Sun, 11 Sep 2011 17:21:03 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.7 X-Spam-Level: X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id TF1FI7JjZL+z for ; Sun, 11 Sep 2011 17:21:02 -0700 (PDT) Received: from dmz-mailsec-scanner-3.mit.edu (DMZ-MAILSEC-SCANNER-3.MIT.EDU [18.9.25.14]) by olra.theworths.org (Postfix) with ESMTP id 6F6E5431FB6 for ; Sun, 11 Sep 2011 17:21:02 -0700 (PDT) X-AuditID: 1209190e-b7c60ae000000a26-cf-4e6d4fe0ed82 Received: from mailhub-auth-1.mit.edu ( [18.9.21.35]) by dmz-mailsec-scanner-3.mit.edu (Symantec Messaging Gateway) with SMTP id A4.26.02598.0EF4D6E4; Sun, 11 Sep 2011 20:18:40 -0400 (EDT) Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) by mailhub-auth-1.mit.edu (8.13.8/8.9.2) with ESMTP id p8C0KxuV022843; Sun, 11 Sep 2011 20:21:00 -0400 Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91]) (authenticated bits=0) (User authenticated as amdragon@ATHENA.MIT.EDU) by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id p8C0Kw6E006017 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); Sun, 11 Sep 2011 20:20:58 -0400 (EDT) Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.72) (envelope-from ) id 1R2uJ5-0000Q6-A9; Sun, 11 Sep 2011 20:23:27 -0400 Date: Sun, 11 Sep 2011 20:23:27 -0400 From: Austin Clements To: Martin Owens Subject: Re: Patch: Flush and Reopen Message-ID: <20110912002327.GC23603@mit.edu> References: <1315445674.32058.183.camel@delen> <1315536861.2435.34.camel@delen> <87obyuj7q1.fsf@zancas.localnet> <1315590950.2435.59.camel@delen> <1315615433.2435.62.camel@delen> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1315615433.2435.62.camel@delen> User-Agent: Mutt/1.5.20 (2009-06-14) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupnleLIzCtJLcpLzFFi42IR4hRV1n3gn+tncOy5vMWN1m5Gi3n3/zJb XL85k9mB2WPnrLvsHs9W3WL22HLoPXMAcxSXTUpqTmZZapG+XQJXxsy/t5gLFmlV/F/wiq2B 8bZCFyMnh4SAicTtdS+YIWwxiQv31rN1MXJxCAnsY5R4ffoaI4SzgVFi0Z+F7BDOSSaJmUdP MEM4SxglHlzZwg7SzyKgKnH2ynkmEJtNQENi2/7ljCC2CFB8UmsrK4jNLJAgsXjra7AaYQEV iemrbrGB2LwCOhKTp4H0ggw9wSTxoHEnI0RCUOLkzCcsEM1aEjf+vQQq4gCypSWW/+MACXMK 6Eos/dUINlMUaOa1/e1sExiFZiHpnoWkexZC9wJG5lWMsim5Vbq5iZk5xanJusXJiXl5qUW6 xnq5mSV6qSmlmxjB4S7Jt4Px60GlQ4wCHIxKPLyB13L8hFgTy4orcw8xSnIwKYnyKvrl+gnx JeWnVGYkFmfEF5XmpBYfYpTgYFYS4W3QAyrnTUmsrEotyodJSXOwKInzrt7h4CckkJ5Ykpqd mlqQWgSTleHgUJLgPQWMayHBotT01Iq0zJwShDQTByfIcB6g4ftBaniLCxJzizPTIfKnGBWl xHkvgSQEQBIZpXlwvbB09IpRHOgVYd4vIFU8wFQG1/0KaDAT0OCA7Zkgg0sSEVJSDYziumnP Dr9WFcrYXH6s+kZWMkPD13Qu2yvbTV2W3t/aGa26/hTXJTOZ+xECwm8bb39dvOXBtHkbvToN /pxj32bTZTDTNeKCvsuO/zJX9T+Uit756vdQ+9ECtiYjhku3lvz9oPLl2OJlja+1r0j5pqrf TRP+86OypPJGTb5nst/ClPfGeXt3XeNVYinOSDTUYi4qTgQAA0ziIiIDAAA= Cc: Notmuch developer list X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 12 Sep 2011 00:21:03 -0000 BTW, in the future, you should send patches inline (see the patch formatting guide I linked to earlier for easy ways to do this). It makes them much easier to review and reply to. Quoth Martin Owens on Sep 09 at 8:43 pm: > On Fri, 2011-09-09 at 19:40 -0400, Austin Clements wrote: > > > > (indented correctly, of course). Reopen is a method of > > Xapian::Database, which is what notmuch->xapian_db is anyway (unlike, > > flush, which is a member of the subclass WritableDatabase and hence > > requires the cast). And reopening is a sensible thing to do on both > > read-only and read/write databases. > > See attached for the removal of the cast and conditional for reopen. Great. That looks like how I would expect a reopen function to work. I assume you've tested it? Speaking of testing, I'm not sure what the best way to test this is, but it needs something. notmuch's testing system is great for testing the CLI, but it's poorly suited to lower-level library things. > > Also, in keeping with notmuch code style, you should use tabs for > > indentation and put a space before the open paren argument lists. > > I couldn't detect a consistant style for the tab/spacing and it confused > me greatly. Especially coming from python where spacing is critical. > > I've put in tabs, not sure if I've put in enough in the form required. Notmuch is quite consistent about indentation, though the rule may not be something you'd expect coming from Python. It uses four space indentation, but each group of eight spaces is replaced with a tab, so for example notmuch_database_reopen (notmuch_database_t *notmuch) { ____try { -> notmuch->xapian_db->reopen (); ____} catch (const Xapian::Error &error) { -> if (! notmuch->exception_reported) { -> ____fprintf (stderr, "Error: A Xapian exception occurred reopening database: %s\n", -> -> _____error.get_msg().c_str()); -> } ____} } Yeah, it's weird; blame RMS. If you're using Emacs, the .dir-locals.el should set this up automatically for you. (If you're not using Emacs, the easiest way might be to pop it up in Emacs, select the code to indent, and do M-x indent-region.) > diff --git a/debian/changelog b/debian/changelog > index c2b7552..565edfb 100644 > --- a/debian/changelog > +++ b/debian/changelog > @@ -1,8 +1,12 @@ > notmuch (0.8~rc1-1) experimental; urgency=low > > + [ David Bremner ] > * Upstream release candidate. > > - -- David Bremner Tue, 06 Sep 2011 22:24:24 -0300 > + [ Martin Owens (DoctorMO) ] > + * Re-new-world-order > + > + -- Martin Owens (DoctorMO) Wed, 07 Sep 2011 18:19:50 -0400 > > notmuch (0.7-1) unstable; urgency=low > > diff --git a/debian/control b/debian/control > index 03afdf4..a72fe1b 100644 > --- a/debian/control > +++ b/debian/control > @@ -5,7 +5,7 @@ Maintainer: Carl Worth > Uploaders: Jameson Graef Rollins , martin f. krafft , > David Bremner > Build-Depends: debhelper (>= 7.0.50~), pkg-config, libxapian-dev, > - libgmime-2.4-dev, libtalloc-dev, libz-dev, python-all (>= 2.6.6-3~), > + libgmime-2.4-dev, libtalloc-dev, libz-dev, python-all (>= 2.6.6), > emacs23-nox | emacs23 (>=23~) | emacs23-lucid (>=23~) > Standards-Version: 3.9.2 > Homepage: http://notmuchmail.org/ Even if you found the above two changes necessary, they shouldn't be included in this patch because they aren't related to reopen/flush. > --- a/lib/database.cc > +++ b/lib/database.cc > @@ -700,18 +700,36 @@ notmuch_database_open (const char *path, > } > > void > -notmuch_database_close (notmuch_database_t *notmuch) > +notmuch_database_reopen (notmuch_database_t *notmuch) > +{ > + try { > + notmuch->xapian_db->reopen (); > + } catch (const Xapian::Error &error) { > + if (! notmuch->exception_reported) { > + fprintf (stderr, "Error: A Xapian exception occurred reopening database: %s\n", > + error.get_msg().c_str()); > + } > + } > +} > + > +void > +notmuch_database_flush (notmuch_database_t *notmuch) > { > try { > if (notmuch->mode == NOTMUCH_DATABASE_MODE_READ_WRITE) > - (static_cast (notmuch->xapian_db))->flush (); > + (static_cast (notmuch->xapian_db))->flush (); > } catch (const Xapian::Error &error) { > - if (! notmuch->exception_reported) { > - fprintf (stderr, "Error: A Xapian exception occurred flushing database: %s\n", > - error.get_msg().c_str()); > + if (! notmuch->exception_reported) { > + fprintf (stderr, "Error: A Xapian exception occurred flushing database: %s\n", > + error.get_msg().c_str()); > + } > } > - } > +} Both catch blocks should set notmuch->exception_reported = TRUE; (notmuch_database_close happens to be the one exception to this since it's closing the database; see other catch blocks in lib/database.cc). The catch block in notmuch_database_flush shouldn't appear as changed in the diff; you should leave the spacing the way it originally was.