summaryrefslogtreecommitdiff
path: root/ndb
diff options
context:
space:
mode:
authorunknown <stewart@willster.(none)>2006-08-16 14:39:27 +0800
committerunknown <stewart@willster.(none)>2006-08-16 14:39:27 +0800
commit105ed9dec3dfe5939e6d50a3ea8bd3ff3572d93e (patch)
treeacf06fa61b96d0ad827a3d99a7421209ffca1e15 /ndb
parent60a0e3d0dd4c63639039ceb9ae8135291764c0f3 (diff)
downloadmariadb-git-105ed9dec3dfe5939e6d50a3ea8bd3ff3572d93e.tar.gz
BUG#21671 memory leak for mgmapi event listeners
fixes the following valgrind warning (when running ndb_mgm under valgrind, or, indeed any other mgmapi program listening to events): ==23291== 190 (20 direct, 170 indirect) bytes in 1 blocks are definitely lost in loss record 13 of 22 ==23291== at 0x401C895: operator new(unsigned) (vg_replace_malloc.c:163) ==23291== by 0x8075300: ParserImpl::run(Parser<ParserImpl::Dummy>::Context*, Properties const**, bool volatile*) const (Parser.cpp:178) ==23291== by 0x806D09B: Parser<ParserDummy>::parse(Parser<ParserDummy>::Context&, ParserDummy&) (Parser.hpp:219) ==23291== by 0x80671C4: ndb_mgm_call(ndb_mgm_handle*, ParserRow<ParserDummy> const*, char const*, Properties const*) (mgmapi.cpp:355) ==23291== by 0x806AB79: ndb_mgm_listen_event_internal(ndb_mgm_handle*, int const*, int) (mgmapi.cpp:1419) ==23291== by 0x806AC1F: ndb_mgm_listen_event (mgmapi.cpp:1434) ==23291== by 0x805EB5D: event_thread_run(void*) (CommandInterpreter.cpp:467) ==23291== by 0x806F70A: ndb_thread_wrapper (NdbThread.c:68) ==23291== by 0x4042340: start_thread (in /lib/tls/i686/cmov/libpthread-2.3.6.so) ==23291== by 0x429D4ED: clone (in /lib/tls/i686/cmov/libc-2.3.6.so) ndb/src/mgmapi/mgmapi.cpp: fix memory leak for mgmapi event listeners (1 per connect) (missing delete of reply Properties object returned by ndb_mgm_call)
Diffstat (limited to 'ndb')
-rw-r--r--ndb/src/mgmapi/mgmapi.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/ndb/src/mgmapi/mgmapi.cpp b/ndb/src/mgmapi/mgmapi.cpp
index 4428b158b6b..9bf19dda3a4 100644
--- a/ndb/src/mgmapi/mgmapi.cpp
+++ b/ndb/src/mgmapi/mgmapi.cpp
@@ -1389,7 +1389,7 @@ ndb_mgm_listen_event_internal(NdbMgmHandle handle, const int filter[],
MGM_END()
};
CHECK_HANDLE(handle, -1);
-
+
const char *hostname= ndb_mgm_get_connected_host(handle);
int port= ndb_mgm_get_connected_port(handle);
SocketClient s(hostname, port);
@@ -1411,19 +1411,20 @@ ndb_mgm_listen_event_internal(NdbMgmHandle handle, const int filter[],
}
args.put("filter", tmp.c_str());
}
-
+
int tmp = handle->socket;
handle->socket = sockfd;
-
+
const Properties *reply;
reply = ndb_mgm_call(handle, stat_reply, "listen event", &args);
-
+
handle->socket = tmp;
-
+
if(reply == NULL) {
close(sockfd);
CHECK_REPLY(reply, -1);
}
+ delete reply;
return sockfd;
}