[PATCH] Also flush write when reading large amount of data (BZ #18659)
Ondřej Bílka
neleai@seznam.cz
Sat Jul 11 08:04:00 GMT 2015
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.
More information about the Libc-alpha
mailing list