Add/remove from epoll set.

This commit is contained in:
Ian Gulliver
2016-03-04 21:28:22 -08:00
parent a6edb9cdad
commit a507b09332

View File

@@ -229,6 +229,13 @@ static void conn_new() {
conn->file = file_next(); conn->file = file_next();
conn->offset = 0; conn->offset = 0;
list_add(&conn->conn_list, &conn_pending_head); list_add(&conn->conn_list, &conn_pending_head);
struct epoll_event ev = {
.events = EPOLLOUT,
.data = {
.ptr = conn,
},
};
assert(!epoll_ctl(epoll_fd, EPOLL_CTL_ADD, conn->fd, &ev));
open_conns++; open_conns++;
} }
@@ -273,6 +280,7 @@ static void conn_check(struct conn *conn) {
if (!error) { if (!error) {
list_del(&conn->conn_list); list_del(&conn->conn_list);
list_add(&conn->conn_list, &conn_open_head); list_add(&conn->conn_list, &conn_open_head);
assert(!epoll_ctl(epoll_fd, EPOLL_CTL_DEL, conn->fd, NULL));
return; return;
} }
if (error == EINPROGRESS) { if (error == EINPROGRESS) {