Re: BUG #15858: could not stat file - over 4GB

From: Juan José Santamaría Flecha <juanjo(dot)santamaria(at)gmail(dot)com>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Emil Iggland <emil(at)iggland(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: BUG #15858: could not stat file - over 4GB
Date: 2020-10-10 14:29:38
Message-ID: CAC+AXB0f-pGWb2Rx1amCRCpjKohKLQ4L+Vsy7JaeHVgwJgbnGA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

On Sat, Oct 10, 2020 at 2:24 PM Michael Paquier <michael(at)paquier(dot)xyz> wrote:

>
> - _dosmaperr(GetLastError());
> + DWORD err = GetLastError();
> +
> + /* report when not ERROR_SUCCESS */
> + if (err == ERROR_FILE_NOT_FOUND || err ==
> ERROR_PATH_NOT_FOUND)
> + errno = ENOENT;
> + else
> + _dosmaperr(err);
> Why are you changing that? The original coding is fine, as
> _dosmaperr() already maps ERROR_FILE_NOT_FOUND and
> ERROR_PATH_NOT_FOUND to ENOENT.
>

If the file does not exist there is no need to call _dosmaperr() and log
the error.

>
> - _dosmaperr(GetLastError());
> + DWORD err = GetLastError();
> +
> CloseHandle(hFile);
> + _dosmaperr(err);
> These parts are indeed incorrect. CloseHandle() could overwrite
> errno.
>

The meaningful error should come from the previous call, and an error from
CloseHandle() could mask it. Not sure it makes a difference anyhow.

Regards,

Juan José Santamaría Flecha

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Raphael Megzari 2020-10-10 14:50:50 Re: BUG #16665: Segmentation fault
Previous Message Michael Paquier 2020-10-10 12:23:53 Re: BUG #15858: could not stat file - over 4GB

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrey Borodin 2020-10-10 16:00:07 Re: Batching page logging during B-tree build
Previous Message Michael Paquier 2020-10-10 12:23:53 Re: BUG #15858: could not stat file - over 4GB