-
Notifications
You must be signed in to change notification settings - Fork 181
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove custom permission error code and restore path in read error #451
Conversation
391f276
to
a3157d8
Compare
ext/bootsnap/bootsnap.c
Outdated
@@ -368,7 +368,8 @@ open_current_file(char * path, struct bs_cache_key * key, const char ** errno_pr | |||
|
|||
fd = open(path, O_RDONLY); | |||
if (fd < 0) { | |||
*errno_provenance = "bs_fetch:open_current_file:open"; | |||
// ensure error for reading the input file contains the original path | |||
*errno_provenance = path; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So open_current_file
is only called from bs_fetch
, and path
here is RSTRING_PTR
of the path_v
bs_fetch
received.
If we return fd <0
, bs_fetch
jumps to the fail_errno
label, so we're not actually giving more information to the caller here, since it already have path_v
on its stack.
If we wish to augment or change the error message, we can directly do it there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I like that idea.
In bs_fetch
we will goto fail_errno
in several cases:
-
an error opening (or
fstat
-ing) the file inopen_current_file
(the most likely case to be useful to the user)
bootsnap/ext/bootsnap/bootsnap.c
Line 688 in 34dba5c
if (current_fd < 0) goto fail_errno; -
after
open_cache_file
... this returns CACHE_MISS for reading the cache file,
but will forward the errno from aread
inbs_read_key
bootsnap/ext/bootsnap/bootsnap.c
Line 698 in 34dba5c
goto fail_errno; -
after
bs_read_contents
callsread
on thefd
of the current file
bootsnap/ext/bootsnap/bootsnap.c
Line 720 in 34dba5c
if ((input_data = bs_read_contents(current_fd, current_key.size, &errno_provenance)) == Qfalse) goto fail_errno;
and
bootsnap/ext/bootsnap/bootsnap.c
Line 733 in 34dba5c
if ((input_data = bs_read_contents(current_fd, current_key.size, &errno_provenance)) == Qfalse) goto fail_errno; -
after
fetch_cached_data
if it fails to read the rest of the cache file (after the key has been read)
bootsnap/ext/bootsnap/bootsnap.c
Line 725 in 34dba5c
else if (res == ERROR_WITH_ERRNO) goto fail_errno; -
after
unlink
-ing the cache file
bootsnap/ext/bootsnap/bootsnap.c
Line 770 in 34dba5c
goto fail_errno;
I updated the code to set the message to the file the operation was on, but I may have gone a little overboard. 😅
a3157d8
to
c094e57
Compare
I like it, thanks. |
The existing error message says
but at this point i think the error will never be about the cache and only for the original file.
We stopped reporting write errors in
d878622
and read errors in
503e9d5
In that case it seems like we may as well remove the wrapper class and let the original error bubble up...
but when I did that the exception message was the code "bs_fetch:open_current_file:open" rather than mentioning what file path failed to be read.
My C is incredibly rusty; I don't know if this is a good idea.
What do you think? Do we want to do it this way?
Are there other places we should replace the "bs:*" code with the file path (like the fstat that follows?)
Another option would be to keep the ruby method and just simplify the message
(in which case the C code wouldn't have to change).