This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] Also flush write when reading large amount of data (BZ #18659)
- From: OndÅej BÃlka <neleai at seznam dot cz>
- To: Siddhesh Poyarekar <siddhesh at redhat dot com>
- Cc: libc-alpha at sourceware dot org, carlos at redhat dot com
- Date: Sat, 11 Jul 2015 10:04:18 +0200
- Subject: Re: [PATCH] Also flush write when reading large amount of data (BZ #18659)
- Authentication-results: sourceware.org; auth=none
- References: <1436601380-12456-1-git-send-email-siddhesh at redhat dot com>
On Sat, Jul 11, 2015 at 01:26:20PM +0530, Siddhesh Poyarekar wrote:
> When a program calls fread on a file immediately after writing a small
> amount of data, it may fail to flush the written data if the read size
> is greater than or equal to the FILE buffer size. Trouble is that
> when we do fread directly after fwrite (where the former has not
> flushed), we don't bother to switch to get mode right away and we
> depend on __underflow to do that for us. Fix is to explicitly switch
> to get mode if we're currently putting.
>
> Verified on x86_64 that there are no regressions due to this fix.
>
Patch looks, but you need to trivial style fix in testcase.
+
> + fwrite(data, 1, strlen (data), f);
> +
> + n = fread(foo, 1, BUF_LEN, f);
space before ( here
> + if (n != 0)
> + {
> + printf ("fread before seek: expected %d but got %zu\n", 0, n);
> + return 1;
> + }
> +
> + fseek(f, 0, SEEK_SET);
> + n = fread(foo, 1, BUF_LEN, f);
and here.