aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/nfs/Connection.hxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-10-01 22:05:51 +0200
committerMax Kellermann <max@duempel.org>2014-10-01 23:03:31 +0200
commitedd003b62af802fae7828336628adb0ea3f6bd21 (patch)
treea8abc4b09e2dd84722f9ce682441c4a4a738f8da /src/lib/nfs/Connection.hxx
parent10cc87e422e09f437f86f56074dc2e018ed75bf1 (diff)
downloadmpd-edd003b62af802fae7828336628adb0ea3f6bd21.tar.gz
mpd-edd003b62af802fae7828336628adb0ea3f6bd21.tar.xz
mpd-edd003b62af802fae7828336628adb0ea3f6bd21.zip
lib/nfs/Connection: fix memory leak when cancelling Open()
Close the newly allocated file handle passed to the callback.
Diffstat (limited to 'src/lib/nfs/Connection.hxx')
-rw-r--r--src/lib/nfs/Connection.hxx14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/lib/nfs/Connection.hxx b/src/lib/nfs/Connection.hxx
index f6e5d2949..880b7d467 100644
--- a/src/lib/nfs/Connection.hxx
+++ b/src/lib/nfs/Connection.hxx
@@ -39,11 +39,21 @@ class NfsConnection : SocketMonitor, DeferredMonitor {
class CancellableCallback : public CancellablePointer<NfsCallback> {
NfsConnection &connection;
+ /**
+ * Is this a nfs_open_async() operation? If yes, then
+ * we need to call nfs_close_async() on the new file
+ * handle as soon as the callback is invoked
+ * successfully.
+ */
+ const bool open;
+
public:
explicit CancellableCallback(NfsCallback &_callback,
- NfsConnection &_connection)
+ NfsConnection &_connection,
+ bool _open)
:CancellablePointer<NfsCallback>(_callback),
- connection(_connection) {}
+ connection(_connection),
+ open(_open) {}
bool Open(nfs_context *context, const char *path, int flags,
Error &error);