Fix error

This commit is contained in:
Alexey Milovidov 2021-07-28 02:47:28 +03:00
parent fd5c1561e2
commit 46723a2c3c
4 changed files with 22 additions and 1 deletions

View File

@ -71,6 +71,9 @@ AsynchronousReadBufferFromFile::AsynchronousReadBufferFromFile(
AsynchronousReadBufferFromFile::~AsynchronousReadBufferFromFile()
{
/// Must wait for events in flight before closing the file.
finalize();
if (fd < 0)
return;
@ -89,5 +92,13 @@ void AsynchronousReadBufferFromFile::close()
fd = -1;
}
AsynchronousReadBufferFromFileWithCache::~AsynchronousReadBufferFromFileWithCache()
{
/// Must wait for events in flight before potentially closing the file by destroying OpenedFilePtr.
finalize();
}
}

View File

@ -58,6 +58,8 @@ public:
fd = file->getFD();
}
~AsynchronousReadBufferFromFileWithCache() override;
std::string getFileName() const override
{
return file_name;

View File

@ -62,7 +62,7 @@ bool AsynchronousReadBufferFromFileDescriptor::nextImpl()
}
AsynchronousReadBufferFromFileDescriptor::~AsynchronousReadBufferFromFileDescriptor()
void AsynchronousReadBufferFromFileDescriptor::finalize()
{
if (prefetch_request_id)
{
@ -72,6 +72,12 @@ AsynchronousReadBufferFromFileDescriptor::~AsynchronousReadBufferFromFileDescrip
}
AsynchronousReadBufferFromFileDescriptor::~AsynchronousReadBufferFromFileDescriptor()
{
finalize();
}
/// If 'offset' is small enough to stay in buffer after seek, then true seek in file does not happen.
off_t AsynchronousReadBufferFromFileDescriptor::seek(off_t offset, int whence)
{

View File

@ -30,6 +30,8 @@ protected:
/// Name or some description of file.
std::string getFileName() const override;
void finalize();
public:
AsynchronousReadBufferFromFileDescriptor(
AsynchronousReaderPtr reader_,