Non-blocking connection support.

This commit is contained in:
Ian Gulliver
2016-02-17 08:05:18 +00:00
parent a8f1cb5767
commit 0db4d15897
5 changed files with 124 additions and 96 deletions

View File

@@ -3,11 +3,27 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/epoll.h>
#include <uuid/uuid.h>
#include "common.h"
void peer_epoll_add(struct peer *peer, int epoll_fd, uint32_t events) {
struct epoll_event ev = {
.events = events,
.data = {
.ptr = peer,
},
};
assert(epoll_ctl(epoll_fd, EPOLL_CTL_ADD, peer->fd, &ev) == 0);
}
void peer_epoll_del(struct peer *peer, int epoll_fd) {
assert(epoll_ctl(epoll_fd, EPOLL_CTL_DEL, peer->fd, NULL) == 0);
}
void buf_init(struct buf *buf) {
buf->start = 0;
buf->length = 0;