1 Return-Path: <polatel@gmail.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 82284431FB6
\r
6 for <notmuch@notmuchmail.org>; Mon, 26 Nov 2012 08:21:12 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5
\r
12 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,
\r
13 FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled
\r
14 Received: from olra.theworths.org ([127.0.0.1])
\r
15 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
16 with ESMTP id kk3GvowG6cZm for <notmuch@notmuchmail.org>;
\r
17 Mon, 26 Nov 2012 08:21:11 -0800 (PST)
\r
18 Received: from mail-ea0-f181.google.com (mail-ea0-f181.google.com
\r
19 [209.85.215.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))
\r
20 (No client certificate requested)
\r
21 by olra.theworths.org (Postfix) with ESMTPS id CD0B4431FAF
\r
22 for <notmuch@notmuchmail.org>; Mon, 26 Nov 2012 08:21:10 -0800 (PST)
\r
23 Received: by mail-ea0-f181.google.com with SMTP id k14so3537183eaa.26
\r
24 for <notmuch@notmuchmail.org>; Mon, 26 Nov 2012 08:21:09 -0800 (PST)
\r
25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
\r
26 h=date:from:to:cc:subject:message-id:mail-followup-to:references
\r
27 :mime-version:content-type:content-disposition:in-reply-to
\r
28 :user-agent; bh=y6z/HWJKreT5pNzGGB/oUDN9ZcgrSEZkWxq83FP1QKY=;
\r
29 b=ZbjOdsZeioJdO6J2J7LcyMqX3on6HyW0pw+0CH0jBKFF6yMnovlJ+r6yKaukDNuwwS
\r
30 BKA43RO8KOxZsPWnq2DRu/vifIsrqcOL/V8mGr5i0p9MJfs79QSQRdFbetsV1+DcRzr1
\r
31 kATbEM/Tq6bET2gAxKN/dNmjqhO1tZ+qeu2Gnts5cbOeWEsYXF5YXXPDjbuK49Nm0dTq
\r
32 L3qzC8p5Z4BwJufklRcdzQIbZg6jo/SiNyYYNDugQAitUxebHjLlSIaiuGkNZKo5+Rmx
\r
33 nrV43cBh/T9NA5h6d3hatXkgP+3XKR0DZFGXcL7bcC4wKglFxmfbKM+hZxBAL/6ywNQE
\r
35 Received: by 10.14.223.4 with SMTP id u4mr46738185eep.19.1353946869630;
\r
36 Mon, 26 Nov 2012 08:21:09 -0800 (PST)
\r
37 Received: from localhost ([88.233.27.222])
\r
38 by mx.google.com with ESMTPS id y44sm34960557eel.14.2012.11.26.08.21.07
\r
39 (version=TLSv1/SSLv3 cipher=OTHER);
\r
40 Mon, 26 Nov 2012 08:21:08 -0800 (PST)
\r
41 Date: Mon, 26 Nov 2012 18:21:21 +0200
\r
42 From: Ali Polatel <polatel@gmail.com>
\r
43 To: Peter Wang <novalazy@gmail.com>
\r
44 Subject: Re: [PATCH 04/18] insert: copy stdin to Maildir tmp file
\r
45 Message-ID: <20121126162121.GA5669@hayalet>
\r
46 Mail-Followup-To: Peter Wang <novalazy@gmail.com>, notmuch@notmuchmail.org
\r
47 References: <1343223767-9812-1-git-send-email-novalazy@gmail.com>
\r
48 <1343223767-9812-4-git-send-email-novalazy@gmail.com>
\r
50 Content-Type: multipart/signed; micalg=pgp-sha1;
\r
51 protocol="application/pgp-signature"; boundary="2oS5YaxWCcQjTEyO"
\r
52 Content-Disposition: inline
\r
53 In-Reply-To: <1343223767-9812-4-git-send-email-novalazy@gmail.com>
\r
54 User-Agent: Mutt/1.5.21 (2011-07-01)
\r
55 Cc: notmuch@notmuchmail.org
\r
56 X-BeenThere: notmuch@notmuchmail.org
\r
57 X-Mailman-Version: 2.1.13
\r
59 List-Id: "Use and development of the notmuch mail system."
\r
60 <notmuch.notmuchmail.org>
\r
61 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
62 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
63 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
64 List-Post: <mailto:notmuch@notmuchmail.org>
\r
65 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
66 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
67 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
68 X-List-Received-Date: Mon, 26 Nov 2012 16:21:12 -0000
\r
72 Content-Type: text/plain; charset=us-ascii; format=flowed
\r
73 Content-Disposition: inline
\r
74 Content-Transfer-Encoding: quoted-printable
\r
76 On Wed, Jul 25, 2012 at 11:42:33PM +1000, Peter Wang wrote:
\r
77 >Read the new message from standard input into the Maildir tmp file.
\r
79 > notmuch-insert.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++=
\r
81 > 1 files changed, 49 insertions(+), 2 deletions(-)
\r
83 >diff --git a/notmuch-insert.c b/notmuch-insert.c
\r
84 >index f01a6f2..340f7e4 100644
\r
85 >--- a/notmuch-insert.c
\r
86 >+++ b/notmuch-insert.c
\r
87 >@@ -75,21 +75,68 @@ maildir_open_tmp (void *ctx, const char *dir, char **t=
\r
88 mppath, char **newpath)
\r
91 > static notmuch_bool_t
\r
92 >+copy_fd_data (int fdin, int fdout)
\r
100 >+ remain =3D read (fdin, buf, sizeof(buf));
\r
101 >+ if (remain =3D=3D 0)
\r
103 >+ if (remain < 0) {
\r
104 >+ if (errno =3D=3D EINTR)
\r
106 >+ fprintf (stderr, "Error: reading from standard input: %s\n",
\r
107 >+ strerror (errno));
\r
113 >+ written =3D write (fdout, p, remain);
\r
114 >+ if (written =3D=3D 0)
\r
116 >+ if (written < 0) {
\r
117 >+ if (errno =3D=3D EINTR)
\r
119 >+ fprintf (stderr, "Error: writing to temporary file: %s",
\r
120 >+ strerror (errno));
\r
124 >+ remain -=3D written;
\r
125 >+ } while (remain > 0);
\r
131 LGTM. As an optimisation we can also consider using the splice(2) system
\r
132 call if it is available (as notmuch-deliver does). In case splice()
\r
133 fails with ENOSYS or EINVAL we can fall back to this method.
\r
135 I can write the patch for it once this is accepted.
\r
136 Thanks for the good work!
\r
138 >+static notmuch_bool_t
\r
139 > insert_message (void *ctx, notmuch_database_t *notmuch, int fdin,
\r
145 >+ notmuch_bool_t ret;
\r
147 > fdout =3D maildir_open_tmp (ctx, dir, &tmppath, &newpath);
\r
152 >+ ret =3D copy_fd_data (fdin, fdout);
\r
155 >- unlink (tmppath);
\r
159 >+ unlink (tmppath);
\r
169 >_______________________________________________
\r
170 >notmuch mailing list
\r
171 >notmuch@notmuchmail.org
\r
172 >http://notmuchmail.org/mailman/listinfo/notmuch
\r
175 Content-Type: application/pgp-signature
\r
177 -----BEGIN PGP SIGNATURE-----
\r
178 Version: GnuPG v2.0.19 (GNU/Linux)
\r
180 iEYEARECAAYFAlCzlwEACgkQQU4yORhF8iCxXQCdH4l/LZZ3WlIPEf6a3FslsISc
\r
181 OqkAni9Xj57Fn3fqwix5X3BiJJgB4Nni
\r
183 -----END PGP SIGNATURE-----
\r
185 --2oS5YaxWCcQjTEyO--
\r