Skip to content

Commit

Permalink
ZPool related memory leak fix
Browse files Browse the repository at this point in the history
Close zpool_handle_t returned from zpool_iter, since they are opened
already by the function. This was leaking memory every time pools
were enumerated.
  • Loading branch information
cbreak-black committed Jun 12, 2017
1 parent a07df0b commit 9cd6186
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ZFSWrapper/ZFSNVList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,11 @@ namespace zfs
{
}

NVList::NVList(nvlist_t * list, TakeOwnership) :
m_list(list), m_ownsList(true)
{
}

NVList::~NVList()
{
reset();
Expand Down
2 changes: 2 additions & 0 deletions ZFSWrapper/ZFSUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ namespace zfs

ZPool::~ZPool()
{
if (m_handle)
zpool_close(m_handle);
}

ZPool::ZPool(ZPool && other) noexcept :
Expand Down
1 change: 1 addition & 0 deletions ZFSWrapper/ZFSUtils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ namespace zfs
class ZPool
{
public:
// Takes ownership
explicit ZPool(zpool_handle_t * handle);
~ZPool();

Expand Down

0 comments on commit 9cd6186

Please sign in to comment.