A systematic way of handling Xapian lock errors?
[notmuch-archives.git] / 10 / 828c9ea1f101359b65a848c8ff398308a3789c
1 Return-Path: <too@guru-group.fi>\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 480AC431FB6\r
6         for <notmuch@notmuchmail.org>; Tue, 18 Sep 2012 07:23:13 -0700 (PDT)\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 WmdgJk1idKOn for <notmuch@notmuchmail.org>;\r
16         Tue, 18 Sep 2012 07:23:12 -0700 (PDT)\r
17 Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])\r
18         by olra.theworths.org (Postfix) with ESMTP id 3143E431FAF\r
19         for <notmuch@notmuchmail.org>; Tue, 18 Sep 2012 07:23:12 -0700 (PDT)\r
20 Received: by guru.guru-group.fi (Postfix, from userid 501)\r
21         id 39C18100387; Tue, 18 Sep 2012 17:23:18 +0300 (EEST)\r
22 From: Tomi Ollila <tomi.ollila@iki.fi>\r
23 To: notmuch@notmuchmail.org\r
24 Subject: [PATCH V3 2/2] test/test-lib.sh: take the --background feature in\r
25         smtp-dummy into use\r
26 Date: Tue, 18 Sep 2012 17:23:02 +0300\r
27 Message-Id: <1347978182-8771-2-git-send-email-tomi.ollila@iki.fi>\r
28 X-Mailer: git-send-email 1.7.1\r
29 In-Reply-To: <1347978182-8771-1-git-send-email-tomi.ollila@iki.fi>\r
30 References: <1347978182-8771-1-git-send-email-tomi.ollila@iki.fi>\r
31 Cc: Tomi Ollila <too@iki.fi>\r
32 X-BeenThere: notmuch@notmuchmail.org\r
33 X-Mailman-Version: 2.1.13\r
34 Precedence: list\r
35 List-Id: "Use and development of the notmuch mail system."\r
36         <notmuch.notmuchmail.org>\r
37 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
38         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
39 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
40 List-Post: <mailto:notmuch@notmuchmail.org>\r
41 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
42 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
43         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
44 X-List-Received-Date: Tue, 18 Sep 2012 14:23:13 -0000\r
45 \r
46 From: Tomi Ollila <too@iki.fi>\r
47 \r
48 The use of --background option (instead of shell '&') ensures that\r
49 smtp-dummy is listening its server socket until execution of shell\r
50 script can continue, thus the client will always have socket where\r
51 to connect.\r
52 \r
53 smtp-dummy outputs smtp_dummy_pid variable in shell assignment format;\r
54 eval'ing that output makes that variable available for the shell.\r
55 \r
56 As the smtp-dummy instance is no longer child process of the script\r
57 the SIGKILL signal sent to it will ensure it is going away in case\r
58 the mail sender fails to connect to smtp-dummy.\r
59 ---\r
60  test/test-lib.sh | 15 ++++++++++-----\r
61  1 file changed, 10 insertions(+), 5 deletions(-)\r
62 \r
63 diff --git a/test/test-lib.sh b/test/test-lib.sh\r
64 index f34b1fb..c902b2c 100644\r
65 --- a/test/test-lib.sh\r
66 +++ b/test/test-lib.sh\r
67 @@ -403,8 +403,11 @@ emacs_deliver_message ()\r
68      shift 2\r
69      # before we can send a message, we have to prepare the FCC maildir\r
70      mkdir -p "$MAIL_DIR"/sent/{cur,new,tmp}\r
71 -    $TEST_DIRECTORY/smtp-dummy sent_message &\r
72 -    smtp_dummy_pid=$!\r
73 +    # eval'ing smtp-dummy --background will set smtp_dummy_pid\r
74 +    smtp_dummy_pid=\r
75 +    eval `$TEST_DIRECTORY/smtp-dummy --background sent_message`\r
76 +    test -n "$smtp_dummy_pid" || return 1\r
77 +\r
78      test_emacs \\r
79         "(let ((message-send-mail-function 'message-smtpmail-send-it)\r
80                (smtpmail-smtp-server \"localhost\")\r
81 @@ -419,9 +422,11 @@ emacs_deliver_message ()\r
82            (insert \"${body}\")\r
83            $@\r
84            (message-send-and-exit))"\r
85 -    # opportunistically quit smtp-dummy in case above fails.\r
86 -    { echo QUIT > /dev/tcp/localhost/25025; } 2>/dev/null\r
87 -    wait ${smtp_dummy_pid}\r
88 +\r
89 +    # In case message was sent properly, client waits for confirmation\r
90 +    # before exiting and resuming control here; therefore making sure\r
91 +    # that server exits by sending (KILL) signal to it is safe.\r
92 +    kill -9 $smtp_dummy_pid\r
93      notmuch new >/dev/null\r
94  }\r
95  \r
96 -- \r
97 1.7.11.4\r
98 \r