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);
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);