Let cleanup resources things all in shutdown_socket
Signed-off-by: Haomai Wang <haomai@xsky.com>
}
write_lock.Lock();
- if (sd >= 0) {
- shutdown_socket();
- center->delete_file_event(sd, EVENT_READABLE|EVENT_WRITABLE);
- ::close(sd);
- sd = -1;
- }
+ shutdown_socket();
can_write = WriteStatus::NOWRITE;
open_write = false;
return !out_q.empty() || outcoming_bl.length();
}
void shutdown_socket() {
- if (sd >= 0)
+ for (auto &&t : register_time_events)
+ center->delete_time_event(t);
+ register_time_events.clear();
+ center->delete_time_event(last_tick_id);
+ if (sd >= 0) {
+ center->delete_file_event(sd, EVENT_READABLE|EVENT_WRITABLE);
::shutdown(sd, SHUT_RDWR);
+ ::close(sd);
+ sd = -1;
+ }
}
Message *_get_next_outgoing(bufferlist *bl) {
assert(write_lock.is_locked());