mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-20 08:40:50 +00:00
try fix memory leak in StorageHDFS
This commit is contained in:
parent
b1325450e9
commit
7d7aea9826
@ -75,6 +75,13 @@ namespace ErrorCodes
|
||||
}
|
||||
namespace
|
||||
{
|
||||
struct HDFSFileInfoDeleter
|
||||
{
|
||||
/// Can have only one entry (see hdfsGetPathInfo())
|
||||
void operator()(hdfsFileInfo * info) { hdfsFreeFileInfo(info, 1); }
|
||||
};
|
||||
using HDFSFileInfoPtr = std::unique_ptr<hdfsFileInfo, HDFSFileInfoDeleter>;
|
||||
|
||||
/* Recursive directory listing with matched paths as a result.
|
||||
* Have the same method in StorageFile.
|
||||
*/
|
||||
@ -90,13 +97,12 @@ namespace
|
||||
if (first_glob_pos == std::string::npos)
|
||||
{
|
||||
const String path = fs::path(path_for_ls + for_match.substr(1)).lexically_normal();
|
||||
HDFSFileInfo ls;
|
||||
ls.file_info = hdfsGetPathInfo(fs.get(), path.c_str());
|
||||
if (ls.file_info != nullptr) // NOLINT
|
||||
HDFSFileInfoPtr hdfs_info(hdfsGetPathInfo(fs.get(), path.c_str()));
|
||||
if (hdfs_info) // NOLINT
|
||||
{
|
||||
result.push_back(StorageHDFS::PathWithInfo{
|
||||
String(path),
|
||||
StorageHDFS::PathInfo{ls.file_info->mLastMod, static_cast<size_t>(ls.file_info->mSize)}});
|
||||
StorageHDFS::PathInfo{hdfs_info->mLastMod, static_cast<size_t>(hdfs_info->mSize)}});
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -184,13 +190,6 @@ namespace
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
struct HDFSFileInfoDeleter
|
||||
{
|
||||
/// Can have only one entry (see hdfsGetPathInfo())
|
||||
void operator()(hdfsFileInfo * info) { hdfsFreeFileInfo(info, 1); }
|
||||
};
|
||||
using HDFSFileInfoPtr = std::unique_ptr<hdfsFileInfo, HDFSFileInfoDeleter>;
|
||||
}
|
||||
|
||||
StorageHDFS::StorageHDFS(
|
||||
|
Loading…
Reference in New Issue
Block a user