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 440D140D148 for ; Sun, 24 Oct 2010 14:01:39 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -2.6 X-Spam-Level: X-Spam-Status: No, score=-2.6 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7] autolearn=ham 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 N6nvxMX8CEYi for ; Sun, 24 Oct 2010 14:01:25 -0700 (PDT) Received: from tempo.its.unb.ca (tempo.its.unb.ca [131.202.1.21]) by olra.theworths.org (Postfix) with ESMTP id A87D540D154 for ; Sun, 24 Oct 2010 14:01:14 -0700 (PDT) Received: from rocinante.cs.unb.ca (fctnnbsc30w-142167176217.pppoe-dynamic.High-Speed.nb.bellaliant.net [142.167.176.217]) (authenticated bits=0) by tempo.its.unb.ca (8.13.8/8.13.8) with ESMTP id o9OL1Bab017814 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO); Sun, 24 Oct 2010 18:01:14 -0300 Received: from bremner by rocinante.cs.unb.ca with local (Exim 4.72) (envelope-from ) id 1PA7gl-0006Op-HB; Sun, 24 Oct 2010 18:01:11 -0300 From: david@tethera.net To: notmuch@notmuchmail.org Subject: [PATCH 3/4] Add logging to low level message handling routines. Date: Sun, 24 Oct 2010 18:01:05 -0300 Message-Id: <1287954066-24512-4-git-send-email-david@tethera.net> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1286803617-17328-1-git-send-email-david@tethera.net> References: <1286803617-17328-1-git-send-email-david@tethera.net> Cc: David Bremner 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: Sun, 24 Oct 2010 21:01:39 -0000 From: David Bremner This might not be ideal from the point of view of "atomic" transactions, but it is transparent to the caller of the library. --- lib/message.cc | 30 ++++++++++++++++++++++++++++++ 1 files changed, 30 insertions(+), 0 deletions(-) diff --git a/lib/message.cc b/lib/message.cc index 71f5619..0385e68 100644 --- a/lib/message.cc +++ b/lib/message.cc @@ -600,12 +600,17 @@ void _notmuch_message_sync (notmuch_message_t *message) { Xapian::WritableDatabase *db; + notmuch_log_t *log; if (message->notmuch->mode == NOTMUCH_DATABASE_MODE_READ_ONLY) return; db = static_cast (message->notmuch->xapian_db); db->replace_document (message->doc_id, message->doc); + + log = notmuch_database_get_log(message->notmuch); + if (log) + notmuch_log_sync (log); } /* Ensure that 'message' is not holding any file object open. Future @@ -635,10 +640,16 @@ _notmuch_message_add_term (notmuch_message_t *message, { char *term; + notmuch_log_t *log; if (value == NULL) return NOTMUCH_PRIVATE_STATUS_NULL_POINTER; + log=notmuch_database_get_log(message->notmuch); + if (log) + notmuch_log_words (log,"+", prefix_name, value, + notmuch_message_get_message_id (message), NULL); + term = talloc_asprintf (message, "%s%s", _find_prefix (prefix_name), value); @@ -691,10 +702,16 @@ _notmuch_message_remove_term (notmuch_message_t *message, const char *value) { char *term; + notmuch_log_t *log; if (value == NULL) return NOTMUCH_PRIVATE_STATUS_NULL_POINTER; + log=notmuch_database_get_log(message->notmuch); + if (log) + notmuch_log_words (log,"-", prefix_name, value, + notmuch_message_get_message_id (message), NULL); + term = talloc_asprintf (message, "%s%s", _find_prefix (prefix_name), value); @@ -806,6 +823,7 @@ notmuch_status_t notmuch_message_freeze (notmuch_message_t *message) { notmuch_status_t status; + notmuch_log_t* log; status = _notmuch_database_ensure_writable (message->notmuch); if (status) @@ -813,6 +831,10 @@ notmuch_message_freeze (notmuch_message_t *message) message->frozen++; + log = notmuch_database_get_log (message->notmuch); + if (log) + notmuch_log_start_transaction (log); + return NOTMUCH_STATUS_SUCCESS; } @@ -820,6 +842,7 @@ notmuch_status_t notmuch_message_thaw (notmuch_message_t *message) { notmuch_status_t status; + notmuch_log_t* log; status = _notmuch_database_ensure_writable (message->notmuch); if (status) @@ -827,12 +850,19 @@ notmuch_message_thaw (notmuch_message_t *message) if (message->frozen > 0) { message->frozen--; + + log = notmuch_database_get_log (message->notmuch); + if (log) + notmuch_log_finish_transaction (log); + if (message->frozen == 0) _notmuch_message_sync (message); + return NOTMUCH_STATUS_SUCCESS; } else { return NOTMUCH_STATUS_UNBALANCED_FREEZE_THAW; } + } void -- 1.7.1