lib/nfs/Connection: fix memory leak (and assertion failure)

nfs_destroy_context() will invoke all pending callbacks with
err==-EINTR.  In CancellableCallback::Callback(), this will invoke
NfsConnection::DeferClose(), which however is only designed to be
called from nfs_service().  In non-debug mode, this will leak memory
because nfs_close_async() is never called.

Workaround: before nfs_destroy_context(), invoke nfs_close_async() on
all pending file handles.
This commit is contained in:
Max Kellermann
2014-12-14 15:56:53 +01:00
parent 80f2ba7fca
commit a543627abd
4 changed files with 29 additions and 0 deletions

View File

@@ -157,6 +157,12 @@ public:
return *i;
}
template<typename F>
void ForEach(F &&f) {
for (CT &i : list)
f(i);
}
};
#endif