[Patch v5 6/8] lib: add private function to extract the database for a message.
[notmuch-archives.git] / cb / cae17dd5d36e81afbdbef8589fdc9f027c5cd6
1 Return-Path: <too@nixu.com>\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 A0AC8429E26\r
6         for <notmuch@notmuchmail.org>; Mon, 12 Dec 2011 14:30:35 -0800 (PST)\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 k4OB7j+afkGc for <notmuch@notmuchmail.org>;\r
16         Mon, 12 Dec 2011 14:30:35 -0800 (PST)\r
17 Received: from mail-gw3.nixu.fi (mail-gw3.nixu.fi [193.209.237.7])\r
18         (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
19         (No client certificate requested)\r
20         by olra.theworths.org (Postfix) with ESMTPS id B431A429E25\r
21         for <notmuch@notmuchmail.org>; Mon, 12 Dec 2011 14:30:34 -0800 (PST)\r
22 Received: from pps.filterd (mail-gw3 [127.0.0.1])\r
23         by mail-gw3.nixu.fi (8.14.4/8.14.4) with SMTP id pBCMS4bO012321;\r
24         Tue, 13 Dec 2011 00:30:26 +0200\r
25 Received: from taco2.nixu.fi (taco2.nixu.fi [194.197.118.31])\r
26         by mail-gw3.nixu.fi with ESMTP id 114cs0swqj-1\r
27         (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
28         Tue, 13 Dec 2011 00:30:25 +0200\r
29 Received: from taco2.nixu.fi (localhost [127.0.0.1])\r
30         by taco2.nixu.fi (8.14.3/8.14.3/Debian-5+lenny1) with ESMTP id\r
31         pBCMUPrC015197\r
32         (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT);\r
33         Tue, 13 Dec 2011 00:30:25 +0200\r
34 Received: (from too@localhost)\r
35         by taco2.nixu.fi (8.14.3/8.14.3/Submit) id pBCMUPB9015196;\r
36         Tue, 13 Dec 2011 00:30:25 +0200\r
37 From: Tomi Ollila <tomi.ollila@iki.fi>\r
38 To: notmuch@notmuchmail.org\r
39 Subject: [PATCH 1/2] test/smtp-dummy: add --background option for going\r
40         background after listen(2)\r
41 Date: Tue, 13 Dec 2011 00:29:55 +0200\r
42 Message-Id: <1323728996-15152-1-git-send-email-tomi.ollila@iki.fi>\r
43 X-Mailer: git-send-email 1.7.7.3\r
44 In-Reply-To: <20111212161800.GO2760@mit.edu>\r
45 References: <20111212161800.GO2760@mit.edu>\r
46 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.5.7110,\r
47  1.0.211,       0.0.0000        definitions=2011-12-12_10:2011-12-12, 2011-12-12,\r
48         1970-01-01 signatures=0\r
49 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0\r
50         ipscore=0 suspectscore=1\r
51         phishscore=0 bulkscore=0 adultscore=0 classifier=spam adjust=0\r
52         reason=mlx\r
53         scancount=1 engine=6.0.2-1012030000 definitions=main-1112120243\r
54 Cc: Tomi Ollila <tomi.ollila@iki.fi>\r
55 X-BeenThere: notmuch@notmuchmail.org\r
56 X-Mailman-Version: 2.1.13\r
57 Precedence: list\r
58 List-Id: "Use and development of the notmuch mail system."\r
59         <notmuch.notmuchmail.org>\r
60 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
61         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
62 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
63 List-Post: <mailto:notmuch@notmuchmail.org>\r
64 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
65 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
66         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
67 X-List-Received-Date: Mon, 12 Dec 2011 22:30:35 -0000\r
68 \r
69 To avoid the possibility that smtp-dummy doesn't have chance to bind\r
70 its listening socket until something tries to send message to it this\r
71 option makes caller wait until socket is already listening for connections.\r
72 \r
73 In case this --background option is used, the pid of running smtp-dummy\r
74 is printed on stdout.\r
75 ---\r
76  test/smtp-dummy.c |   35 ++++++++++++++++++++++++++++++++++-\r
77  1 files changed, 34 insertions(+), 1 deletions(-)\r
78 \r
79 diff --git a/test/smtp-dummy.c b/test/smtp-dummy.c\r
80 index 3801a5e..9126c00 100644\r
81 --- a/test/smtp-dummy.c\r
82 +++ b/test/smtp-dummy.c\r
83 @@ -124,9 +124,21 @@ main (int argc, char *argv[])\r
84         struct hostent *hostinfo;\r
85         socklen_t peer_addr_len;\r
86         int reuse;\r
87 +       int bg;\r
88 +\r
89 +       /* XXX Quick implementation -- fix if more functionality is desired. */\r
90 +       if (argc >= 2 && strcmp(argv[1], "--background") == 0) {\r
91 +               argc--;\r
92 +               argv[1] = argv[0];\r
93 +               argv++;\r
94 +               bg = 1;\r
95 +       }\r
96 +       else\r
97 +               bg = 0;\r
98  \r
99         if (argc != 2) {\r
100 -               fprintf (stderr, "Usage: %s <output-file>\n", argv[0]);\r
101 +               fprintf (stderr, "Usage: %s [--background] <output-file>\n",\r
102 +                        argv[0]);\r
103                 return 1;\r
104         }\r
105  \r
106 @@ -179,6 +191,27 @@ main (int argc, char *argv[])\r
107                 return 1;\r
108         }\r
109  \r
110 +       if (bg) {\r
111 +               int pid = fork ();\r
112 +               if (pid > 0) {\r
113 +                       printf ("%d\n", pid);\r
114 +                       return 0;\r
115 +               }\r
116 +               if (pid < 0) {\r
117 +                       fprintf (stderr, "Error: fork() failed: %s\n",\r
118 +                                strerror (errno));\r
119 +                       close (sock);\r
120 +                       return 1;\r
121 +               }\r
122 +               /* Reached if pid == 0. */\r
123 +               /* Close stdout so that the one interested in pid value will\r
124 +                  also get EOF. */\r
125 +               close (1);\r
126 +               /* dup2() will re-reserve fd 1 (opportunistically, in case fd 2\r
127 +                  is open. If that was not open we don't care fd 1 either.) */\r
128 +               dup2 (2, 1);\r
129 +       }\r
130 +\r
131         peer_addr_len = sizeof (peer_addr);\r
132         peer = accept (sock, (struct sockaddr *) &peer_addr, &peer_addr_len);\r
133         if (peer == -1) {\r
134 -- \r
135 1.7.7.3\r
136 \r