From ccb6c9b9b63b6cedecfa532b8790246f1c395c43 Mon Sep 17 00:00:00 2001 From: alex Date: Wed, 4 May 2022 18:42:40 -0700 Subject: [PATCH] ... --- src/net/loop.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/net/loop.c b/src/net/loop.c index 0ee81bf..9770436 100644 --- a/src/net/loop.c +++ b/src/net/loop.c @@ -13,6 +13,7 @@ void net_loop(struct net_info *info) { static void net_await_epoll_event(struct net_info *info) { struct epoll_event ev, events[MAX_EVENTS]; + struct peer *peer; int nfds, conn_sock; nfds = epoll_wait(info->epoll_fd,events,MAX_EVENTS,-1); @@ -34,11 +35,12 @@ static void net_await_epoll_event(struct net_info *info) { ev.events = EPOLLIN | EPOLLET; ev.data.fd = conn_sock; - if(peer_init((struct peer**)ev.data.ptr)<0) { + if(peer_init(&peer)<0) { return; } - ((struct peer*)ev.data.ptr)->sock = conn_sock; + peer->sock = conn_sock; + ev.data.ptr = peer; if(-1==epoll_ctl(info->epoll_fd,EPOLL_CTL_ADD,conn_sock,&ev)) { peer_free(ev.data.ptr); -- 2.30.2