This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Also flush write when reading large amount of data (BZ #18659)


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]