commit - 16012c8fa7ede11487b07a31204fbe9a5238c632
commit + b5c4cc839e3178788f0203eb2cde9d0bf8fc0b76
blob - a13ac97dd52717b9f457db9b0d75dbc82be65dd9
blob + 9fef9a566dfecfdd2a78900599239189d6509306
--- kamid/control.c
+++ kamid/control.c
#include <net/if.h>
#include <errno.h>
+#include <fcntl.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
void
control_accept(int listenfd, short event, void *bula)
{
- int connfd;
+ int connfd, flags;
socklen_t len;
struct sockaddr_un sun;
struct ctl_conn *c;
return;
len = sizeof(sun);
- if ((connfd = accept4(listenfd, (struct sockaddr *)&sun, &len,
- SOCK_CLOEXEC | SOCK_NONBLOCK)) == -1) {
+ if ((connfd = accept(listenfd, (struct sockaddr *)&sun, &len)) == -1) {
/*
* Pause accept if we are out of file descriptors, or
* libevent will haunt us here too.
return;
}
+ if ((flags = fcntl(connfd, F_GETFL)) == -1) {
+ log_warn("%s: fcntl F_GETFL", __func__);
+ close(connfd);
+ return;
+ }
+ flags |= O_NONBLOCK;
+ if (fcntl(connfd, F_SETFL, flags) == -1 ||
+ fcntl(connfd, F_SETFD, FD_CLOEXEC) == -1) {
+ log_warn("%s: can't set nonblock/cloexec", __func__);
+ close(connfd);
+ return;
+ }
+
if ((c = calloc(1, sizeof(struct ctl_conn))) == NULL) {
log_warn("%s: calloc", __func__);
close(connfd);