lib/nfs/Connection: pass status and data to the NfsClientError ctor

This way, we avoid calling the FormatNfsClientError() which crashes
when nfs_get_error() returns nullptr; that can happen on RPC errors:
then, libnfs's check_nfs4_error() doesn't call nfs_set_error().

Closes https://github.com/MusicPlayerDaemon/MPD/issues/2040
This commit is contained in:
Max Kellermann 2024-05-10 16:34:10 +02:00
parent 9384bff6f9
commit 227ab998bc
1 changed files with 3 additions and 2 deletions

View File

@ -529,7 +529,7 @@ NfsConnection::OnSocketReady(unsigned flags) noexcept
inline void
NfsConnection::MountCallback(int status, [[maybe_unused]] nfs_context *nfs,
[[maybe_unused]] void *data) noexcept
void *data) noexcept
{
assert(GetEventLoop().IsInside());
assert(context == nfs);
@ -541,7 +541,8 @@ NfsConnection::MountCallback(int status, [[maybe_unused]] nfs_context *nfs,
mount_timeout_event.Cancel();
if (status < 0) {
auto e = NfsClientError(context, "nfs_mount_async() failed");
auto e = NfsClientError(status, context, data,
"nfs_mount_async() failed");
postponed_mount_error = std::make_exception_ptr(e);
return;
}