RFR: JDK-8301621: libzip should use pread instead of lseek+read
Vyom Tewari
vtewari at openjdk.org
Mon Feb 6 12:48:49 UTC 2023
On Fri, 3 Feb 2023 19:49:44 GMT, Justin King <jcking at openjdk.org> wrote:
> Avoid using `lseek` + `read` in favor of `pread`. For Windows, we can do the same thing by using `OVERLAPPED`, as we are in synchronous mode we can use `Offset` and `OffsetHigh` to achieve the same thing.
>
> Additionally I updated open to use `O_CLOEXEC` when available, as that really should be used.
src/java.base/share/native/libzip/zip_util.c line 227:
> 225: number_of_bytes_to_read = (DWORD) (nbytes - total);
> 226: }
> 227: number_of_bytes_read = 0;
do we really need to set number_of_bytes_read = 0 in every iteration ? . As per MSDN it looks like ReadFile will do it implicitly.
[out, optional] lpNumberOfBytesRead
A pointer to the variable that receives the number of bytes read when using a synchronous hFile parameter. ReadFile sets this value to zero before doing any work or error checking. Use NULL for this parameter if this is an asynchronous operation to avoid potentially erroneous results.
-------------
PR: https://git.openjdk.org/jdk/pull/12417
More information about the core-libs-dev
mailing list