Merge pull request #3255 from tchaikov/async-leak

AsyncMessenger: fix the leak of file_events
This commit is contained in:
Haomai Wang 2014-12-26 22:42:33 +08:00
commit 3f83e88008
2 changed files with 5 additions and 2 deletions

View File

@ -92,9 +92,10 @@ int EventCenter::init(int n)
EventCenter::~EventCenter()
{
if (driver)
delete driver;
delete driver;
if (file_events)
free(file_events);
if (notify_receive_fd > 0)
::close(notify_receive_fd);
if (notify_send_fd > 0)
@ -119,6 +120,7 @@ int EventCenter::create_file_event(int fd, int mask, EventCallbackRef ctxt)
lderr(cct) << __func__ << " failed to realloc file_events" << cpp_strerror(errno) << dendl;
return -errno;
}
memset(file_events+sizeof(FileEvent)*nevent, 0, sizeof(FileEvent)*(new_size-nevent));
file_events = new_events;
nevent = new_size;
}

View File

@ -128,6 +128,7 @@ class EventCenter {
EventCenter(CephContext *c):
cct(c), nevent(0),
lock("AsyncMessenger::lock"),
file_events(NULL),
driver(NULL), time_event_next_id(0),
notify_receive_fd(-1), notify_send_fd(-1), net(c), owner(0) {
last_time = time(NULL);