Skip to content

Commit

Permalink
io/FdCache: close file descriptor on statx() error
Browse files Browse the repository at this point in the history
Fixes an assertion failure in InvokeError() caused by commit 122e191
  • Loading branch information
MaxKellermann committed Feb 15, 2025
1 parent 95ff997 commit a70d2d8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion debian/changelog
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cm4all-beng-proxy (19.9) unstable; urgency=low

*
* bp: fix assertion failure in the file descriptor cache

--

Expand Down
12 changes: 12 additions & 0 deletions src/io/FdCache.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,18 @@ struct FdCache::Item final
if (_error == ENOENT)
cache.SetExpiresSoon(*this, std::chrono::seconds{1});

/* if this error happened during statx(), then we have
a file descriptor already; discard it because we
don't want to have a file descriptor that cannot
even statx() - it's probably a stale */
if (fd.IsDefined()) [[unlikely]] {
#ifdef HAVE_URING
Uring::Close(cache.uring_queue, fd.Release());
#else
fd.Close();
#endif
}

error = _error;
InvokeError();
}
Expand Down

0 comments on commit a70d2d8

Please sign in to comment.