fix use-after-free when client disconnects intentionally

This commit is contained in:
Martin Michelsen
2022-12-05 20:40:27 -08:00
parent d4115450b2
commit 8c2ea48b80
4 changed files with 62 additions and 8 deletions
+6
View File
@@ -35,6 +35,7 @@ public:
private:
std::shared_ptr<struct event_base> base;
std::shared_ptr<struct event> destroy_clients_ev;
struct ListeningSocket {
std::string addr_str;
@@ -52,9 +53,14 @@ private:
};
std::unordered_map<int, ListeningSocket> listening_sockets;
std::unordered_map<Channel*, std::shared_ptr<Client>> channel_to_client;
std::unordered_set<std::shared_ptr<Client>> clients_to_destroy;
std::shared_ptr<ServerState> state;
void enqueue_destroy_clients();
static void dispatch_destroy_clients(evutil_socket_t, short, void* ctx);
void destroy_clients();
static void dispatch_on_listen_accept(struct evconnlistener* listener,
evutil_socket_t fd, struct sockaddr *address, int socklen, void* ctx);
static void dispatch_on_listen_error(struct evconnlistener* listener, void* ctx);