aboutgitcodebugslistschat
path: root/pif.c
diff options
context:
space:
mode:
Diffstat (limited to 'pif.c')
-rw-r--r--pif.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/pif.c b/pif.c
index 4cf0f6e..8ade587 100644
--- a/pif.c
+++ b/pif.c
@@ -125,11 +125,17 @@ int pif_listen(const struct ctx *c, uint8_t proto, uint8_t pif,
ref.listen.pif = pif;
ref.listen.rule = rule;
- ret = epoll_add(c->epollfd, EPOLLIN, ref);
- if (ret < 0) {
- close(ref.fd);
- return ret;
+ if (proto == IPPROTO_TCP && listen(ref.fd, 128) < 0) {
+ ret = -errno;
+ goto fail;
}
+ ret = epoll_add(c->epollfd, EPOLLIN, ref);
+ if (ret < 0)
+ goto fail;
+
return ref.fd;
+fail:
+ close(ref.fd);
+ return ret;
}