From 159389164a589bba0328dfdc661740aeb7c3fca0 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 23 Apr 2020 14:51:09 +0200 Subject: [PATCH] lib/nfs/FileReader: set `state=IDLE` before invoking callback Fixes assertion failure if the callback fails. --- NEWS | 2 ++ src/lib/nfs/FileReader.cxx | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 264ac1737..81a5e6b26 100644 --- a/NEWS +++ b/NEWS @@ -4,6 +4,8 @@ ver 0.21.23 (not yet released) * storage - curl: fix corrupt "href" values in the presence of XML entities - curl: unescape "href" values +* input + - nfs: fix crash bug * decoder - gme: adapt to API change in the upcoming version 0.7.0 * output diff --git a/src/lib/nfs/FileReader.cxx b/src/lib/nfs/FileReader.cxx index 6fe4faaab..02900a059 100644 --- a/src/lib/nfs/FileReader.cxx +++ b/src/lib/nfs/FileReader.cxx @@ -186,6 +186,8 @@ NfsFileReader::OpenCallback(nfsfh *_fh) noexcept fh = _fh; + state = State::IDLE; + try { connection->Stat(fh, *this); } catch (...) { @@ -204,13 +206,13 @@ NfsFileReader::StatCallback(const struct stat *st) noexcept assert(fh != nullptr); assert(st != nullptr); + state = State::IDLE; + if (!S_ISREG(st->st_mode)) { OnNfsFileError(std::make_exception_ptr(std::runtime_error("Not a regular file"))); return; } - state = State::IDLE; - OnNfsFileOpen(st->st_size); }