Fix bug #113: crash when using epoll backend.
This commit is contained in:
parent
896bbfcb5d
commit
6992043f9d
|
@ -59,17 +59,20 @@ int net_backend_poll_epoll(struct net_backend* data, int ms)
|
|||
|
||||
void net_backend_process_epoll(struct net_backend* data, int res)
|
||||
{
|
||||
int n;
|
||||
int n, ev;
|
||||
struct net_backend_epoll* backend = (struct net_backend_epoll*) data;
|
||||
for (n = 0; n < res; n++)
|
||||
{
|
||||
struct net_connection_epoll* con = (struct net_connection_epoll*) backend->events[n].data.ptr;
|
||||
int ev = 0;
|
||||
struct net_connection_epoll* con = backend->conns[backend->events[n].data.fd];
|
||||
if (con)
|
||||
{
|
||||
ev = 0;
|
||||
if (backend->events[n].events & EPOLLIN) ev |= NET_EVENT_READ;
|
||||
if (backend->events[n].events & EPOLLOUT) ev |= NET_EVENT_WRITE;
|
||||
net_con_callback((struct net_connection*) con, ev);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct net_connection* net_con_create_epoll(struct net_backend* data)
|
||||
{
|
||||
|
@ -86,7 +89,7 @@ void net_con_initialize_epoll(struct net_backend* data, struct net_connection* c
|
|||
con->callback = callback;
|
||||
con->ev.events = 0;
|
||||
con->ptr = (void*) ptr;
|
||||
con->ev.data.ptr = (void*) con;
|
||||
con->ev.data.fd = sd;
|
||||
}
|
||||
|
||||
void net_con_backend_add_epoll(struct net_backend* data, struct net_connection* con_, int events)
|
||||
|
|
Loading…
Reference in New Issue