Make epoll_fd global as a concession to clarity. Handle client disconnection even when silent.

This commit is contained in:
Ian Gulliver
2016-02-17 15:41:27 -08:00
parent 908a364aef
commit e14b444466
9 changed files with 107 additions and 87 deletions

View File

@@ -2,19 +2,23 @@
#include <stdint.h>
#include <unistd.h>
#include <sys/epoll.h>
//////// peer
// All specific peer structs must be castable to this.
struct peer;
typedef void (*peer_event_handler)(struct peer *, int epoll_fd);
typedef void (*peer_event_handler)(struct peer *);
struct peer {
int fd;
peer_event_handler event_handler;
};
void peer_epoll_add(struct peer *, int, uint32_t);
void peer_epoll_del(struct peer *, int);
extern int epoll_fd;
void peer_init();
void peer_epoll_add(struct peer *, uint32_t);
void peer_epoll_del(struct peer *);
void peer_loop();
//////// buf