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<FileEvent *>(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;
}
}
if (notify_send_fd >= 0)
::close(notify_send_fd);
-
+
delete driver;
+ delete notify_handler;
if (file_events)
free(file_events);
}
int notify_send_fd;
NetHandler net;
pthread_t owner;
+ EventCallbackRef notify_handler;
int process_time_events();
FileEvent *_get_file_event(int fd) {
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();