From: Haomai Wang Date: Fri, 19 Feb 2016 05:48:35 +0000 (+0800) Subject: Event: delete leak event callback X-Git-Tag: v10.1.0~334^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d5463d76d9ac715e65401c3035de29ebbd1b13e0;p=ceph.git Event: delete leak event callback Signed-off-by: Haomai Wang --- diff --git a/src/msg/async/Event.cc b/src/msg/async/Event.cc index 00abef4fa022..fb5ea3e509e4 100644 --- a/src/msg/async/Event.cc +++ b/src/msg/async/Event.cc @@ -92,25 +92,28 @@ int EventCenter::init(int n) int fds[2]; if (pipe(fds) < 0) { lderr(cct) << __func__ << " can't create notify pipe" << dendl; - return -1; + return -errno; } notify_receive_fd = fds[0]; notify_send_fd = fds[1]; r = net.set_nonblock(notify_receive_fd); if (r < 0) { - return -1; + return r; } r = net.set_nonblock(notify_send_fd); if (r < 0) { - return -1; + return r; } file_events = static_cast(malloc(sizeof(FileEvent)*n)); memset(file_events, 0, sizeof(FileEvent)*n); nevent = n; - create_file_event(notify_receive_fd, EVENT_READABLE, EventCallbackRef(new C_handle_notify(this, cct))); + notify_handler = new C_handle_notify(this, cct), + r = create_file_event(notify_receive_fd, EVENT_READABLE, notify_handler); + if (r < 0) + return r; return 0; } @@ -122,8 +125,9 @@ EventCenter::~EventCenter() } if (notify_send_fd >= 0) ::close(notify_send_fd); - + delete driver; + delete notify_handler; if (file_events) free(file_events); } diff --git a/src/msg/async/Event.h b/src/msg/async/Event.h index 526f8b3d5e46..14979e6b344d 100644 --- a/src/msg/async/Event.h +++ b/src/msg/async/Event.h @@ -115,6 +115,7 @@ class EventCenter { int notify_send_fd; NetHandler net; pthread_t owner; + EventCallbackRef notify_handler; int process_time_events(); FileEvent *_get_file_event(int fd) { @@ -136,7 +137,9 @@ class EventCenter { external_num_events(0), file_events(NULL), driver(NULL), time_event_next_id(1), - notify_receive_fd(-1), notify_send_fd(-1), net(c), owner(0), already_wakeup(0) { + notify_receive_fd(-1), notify_send_fd(-1), net(c), owner(0), + notify_handler(NULL), + already_wakeup(0) { last_time = time(NULL); } ~EventCenter();