Re: pread, pwrite, etc return ssize_t not int

From: Peter Eisentraut <peter(at)eisentraut(dot)org>
To: Thomas Munro <thomas(dot)munro(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: pread, pwrite, etc return ssize_t not int
Date: 2024-03-02 05:16:04
Message-ID: 58a7dca2-bbe3-47bd-8e16-0de7ed36eafb@eisentraut.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 01.03.24 22:23, Thomas Munro wrote:
>> For the overflow of the input length (size_t -> DWORD), I don't think we
>> actually need to do anything. The size argument would be truncated, but
>> the callers would just repeat the calls with the remaining size, so in
>> effect they will read the data in chunks of rest + N * DWORD_MAX. The
>> patch just changes this to chunks of N * 1GB + rest.
>
> But implicit conversion size_t -> DWORD doesn't convert large numbers
> to DWORD_MAX, it just cuts off the high bits, and that might leave you
> with zero. Zero has a special meaning (if we assume that kernel
> doesn't reject a zero size argument outright, I dunno): if returned by
> reads it indicates EOF, and if returned by writes a typical caller
> would either loop forever making no progress or (in some of our code)
> conjure up a fake ENOSPC. Hence desire to impose a cap.

Right, my thinko. Your patch is correct then.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Bharath Rupireddy 2024-03-02 06:32:29 Re: New Table Access Methods for Multi and Single Inserts
Previous Message Zhijie Hou (Fujitsu) 2024-03-02 03:51:51 RE: Synchronizing slots from primary to standby