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 AE61B431FD0 for ; Sat, 11 Jun 2011 13:07:32 -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 BaNZgMlh-15d for ; Sat, 11 Jun 2011 13:07:32 -0700 (PDT) Received: from dmz-mailsec-scanner-7.mit.edu (DMZ-MAILSEC-SCANNER-7.MIT.EDU [18.7.68.36]) by olra.theworths.org (Postfix) with ESMTP id 3255A431FB6 for ; Sat, 11 Jun 2011 13:07:32 -0700 (PDT) X-AuditID: 12074424-b7bc6ae000005a77-8e-4df3cb035304 Received: from mailhub-auth-1.mit.edu ( [18.9.21.35]) by dmz-mailsec-scanner-7.mit.edu (Symantec Messaging Gateway) with SMTP id 30.35.23159.30BC3FD4; Sat, 11 Jun 2011 16:07:31 -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 p5BK7VAB015089; Sat, 11 Jun 2011 16:07:31 -0400 Received: from drake.mit.edu (209-6-116-242.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com [209.6.116.242]) (authenticated bits=0) (User authenticated as amdragon@ATHENA.MIT.EDU) by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id p5BK7UgD006077 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); Sat, 11 Jun 2011 16:07:31 -0400 (EDT) Received: from amthrax by drake.mit.edu with local (Exim 4.76) (envelope-from ) id 1QVUSw-0000Ih-H6; Sat, 11 Jun 2011 16:07:30 -0400 From: Austin Clements To: notmuch@notmuchmail.org Subject: [PATCH 16/17] new: Wrap adding and removing messages in atomic sections. Date: Sat, 11 Jun 2011 16:04:42 -0400 Message-Id: <1307822683-848-17-git-send-email-amdragon@mit.edu> X-Mailer: git-send-email 1.7.5.1 In-Reply-To: <1307822683-848-1-git-send-email-amdragon@mit.edu> References: <87ei34rnc5.fsf@yoom.home.cworth.org> <1307822683-848-1-git-send-email-amdragon@mit.edu> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrPIsWRmVeSWpSXmKPExsUixCmqrMt8+rOvwddeM4vrN2cyOzB6PFt1 izmAMYrLJiU1J7MstUjfLoErY/fRnewFcwQrPuyay97AeJa3i5GTQ0LAROJPewsLhC0mceHe erYuRi4OIYF9jBLLruyBcjYwSqxeuoYZwrnPJPHrwC9WCGc+o8S+Q12MIP1sAhoS2/YvB7NF BKQldt6dDVTEwcEsoCbxp0sFJCwsECjR3f0WbB2LgKrE8l8L2EFsXgF7iaVnnjJDnKEgceXK PLAaTqD4vINXwWwhgTSJJbd2s09g5F/AyLCKUTYlt0o3NzEzpzg1Wbc4OTEvL7VI11wvN7NE LzWldBMjKGzYXVR2MDYfUjrEKMDBqMTDe2rVZ18h1sSy4srcQ4ySHExKorw6J4BCfEn5KZUZ icUZ8UWlOanFhxglOJiVRHjXt3/yFeJNSaysSi3Kh0lJc7AoifPOk1T3FRJITyxJzU5NLUgt gsnKcHAoSfBKngIaKliUmp5akZaZU4KQZuLgBBnOAzT86EmgGt7igsTc4sx0iPwpRl2Oxxs2 HWIUYsnLz0uVEudVBxkkAFKUUZoHNwcW768YxYHeEub9ATKKB5gq4Ca9AlrCBLREoBRsSUki QkqqgfFAlFq9VqJZ6P47enHWv8oMFxROY/779d5qt3QVXfPPDGpRkhL5JxsVvDw/2u7jv7cq hKWbl/32ZgnT2ANn0iQi1mzcc9D0z/HonTuuyk4v45rhr5N61Uh2RuNJux/a/FeCjF+0dHYd k7+dKGlo+mLnqk75hrjagAsxsYEWr9eHXvrw+EWXvxJLcUaioRZzUXEiACqJLmbSAgAA Cc: Austin Clements 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: Sat, 11 Jun 2011 20:07:32 -0000 This addresses atomicity of tag synchronization, the last atomicity problems in notmuch new. Each message add or remove is wrapped in its own atomic section, so interrupting notmuch new doesn't lose progress. --- notmuch-new.c | 16 ++++++++++++++++ test/atomicity | 2 +- 2 files changed, 17 insertions(+), 1 deletions(-) diff --git a/notmuch-new.c b/notmuch-new.c index b24eb51..fb92b03 100644 --- a/notmuch-new.c +++ b/notmuch-new.c @@ -428,6 +428,12 @@ add_files_recursive (notmuch_database_t *notmuch, fflush (stdout); } + status = notmuch_database_begin_atomic (notmuch); + if (status) { + ret = status; + goto DONE; + } + status = notmuch_database_add_message (notmuch, next, &message); switch (status) { /* success */ @@ -468,6 +474,12 @@ add_files_recursive (notmuch_database_t *notmuch, goto DONE; } + status = notmuch_database_end_atomic (notmuch); + if (status) { + ret = status; + goto DONE; + } + if (message) { notmuch_message_destroy (message); message = NULL; @@ -700,6 +712,9 @@ remove_filename (notmuch_database_t *notmuch, { notmuch_status_t status; notmuch_message_t *message; + status = notmuch_database_begin_atomic (notmuch); + if (status) + return status; message = notmuch_database_find_message_by_filename (notmuch, path); status = notmuch_database_remove_message (notmuch, path); if (status == NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID) { @@ -709,6 +724,7 @@ remove_filename (notmuch_database_t *notmuch, } else add_files_state->removed_messages++; notmuch_message_destroy (message); + notmuch_database_end_atomic (notmuch); return status; } diff --git a/test/atomicity b/test/atomicity index 817819a..f546c07 100755 --- a/test/atomicity +++ b/test/atomicity @@ -96,7 +96,7 @@ for ((i = 0; i < $outcount; i++)); do i=$(expr $end - 1) fi done -test_expect_equal_failure GDB "$(cat searchall)" "$(cat expectall)" +test_expect_equal GDB "$(cat searchall)" "$(cat expectall)" test_expect_success GDB "detected $outcount>10 abort points" "test $outcount -gt 10" -- 1.7.5.1