unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Tomi Ollila <tomi.ollila@iki.fi>
To: David Bremner <david@tethera.net>,
	Rob Browning <rlb@defaultvalue.org>,
	notmuch@notmuchmail.org
Subject: Re: [PATCH 1/2] test/raw: add some messages likely to be multiples of buffer size
Date: Sun, 05 May 2019 13:06:13 +0300	[thread overview]
Message-ID: <m2pnoxp65m.fsf@guru.guru-group.fi> (raw)
In-Reply-To: <m2v9ypdzu2.fsf@guru.guru-group.fi>

On Sun, May 05 2019, Tomi Ollila wrote:

> On Sat, May 04 2019, David Bremner wrote:
>
>>  
>> +test_python <<EOF
>> +from email.message import EmailMessage
>> +for pow in range(12,21):
>
> .......................^ space. i.e. (12, 21)
>
> from 4KiB to 1MiB. uh, perhaps I should have kept my fingers crossed.
> (that said, my range would have been 10, 17 (1024 - 65536))

except that...

if fread(3) (and friends) used 1024 byte buffer, for 4096 byte message
it would read full buffer 4 times (and not yet noticing EOF), and then
next fread() would return 0 (and now flag EOF)...

... and then the same would apply for 4096 byte message and we could
just test 65536 byte message.

(so, one alternative could be testing e.g. 4096 and 65536 byte messages)

linux namual page does not exactly say, whether reading full request
is "guaranteed", but 2 other documents found in the wild said:

" The total number of elements successfully read is returned.
    
  If this number differs from the count parameter, either a reading error
  occurred or the end-of-file was reached while reading. In both cases, the
  proper indicator is set, which can be checked with ferror and feof,
  respectively."

(so the fix could be different in other email, but at least it is short :D)

... anyway, fread could internally read(2) less than BUFSIZ, copy that to
output buffer and then read(2) more... but at least most of the times
this test in question can protect against regressions in this particular
case)


Tomi

  reply	other threads:[~2019-05-05 10:06 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-27 21:07 [PATCH 1/1] cli/show: avoid empty write to stdout in format_part_raw Rob Browning
2019-04-28 16:29 ` v2 format_raw fix David Bremner
2019-04-28 16:29   ` [PATCH 1/2] test: notmuch show --format=raw for 4096 byte messages David Bremner
2019-05-01 19:55     ` Tomi Ollila
2019-05-01 20:12       ` David Bremner
2019-04-28 16:29   ` [PATCH 2/2] cli/show: avoid empty write to stdout in format_part_raw David Bremner
2019-05-05  0:10     ` v3 raw output of messages with size multiples of stdio buffer size David Bremner
2019-05-05  0:10       ` [PATCH 1/2] test/raw: add some messages likely to be multiples of " David Bremner
2019-05-05  9:18         ` Tomi Ollila
2019-05-05 10:06           ` Tomi Ollila [this message]
2019-05-05 10:49             ` David Bremner
2019-05-05 15:15               ` Daniel Kahn Gillmor
2019-05-05  0:10       ` [PATCH 2/2] cli/show: avoid empty write to stdout in format_part_raw David Bremner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m2pnoxp65m.fsf@guru.guru-group.fi \
    --to=tomi.ollila@iki.fi \
    --cc=david@tethera.net \
    --cc=notmuch@notmuchmail.org \
    --cc=rlb@defaultvalue.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).