Kill TCP_NODELAY warnings for socketpair() fds.

This commit is contained in:
Joris Vink 2015-06-22 22:11:03 +02:00
parent e9832b4416
commit 28e48727a5
4 changed files with 13 additions and 11 deletions

View File

@ -454,7 +454,7 @@ void kore_connection_init(void);
void kore_connection_prune(int);
struct connection *kore_connection_new(void *);
void kore_connection_check_timeout(void);
int kore_connection_nonblock(int);
int kore_connection_nonblock(int, int);
int kore_connection_handle(struct connection *);
void kore_connection_remove(struct connection *);
void kore_connection_disconnect(struct connection *);

View File

@ -100,7 +100,7 @@ kore_connection_accept(struct listener *l, struct connection **out)
return (KORE_RESULT_ERROR);
}
if (!kore_connection_nonblock(c->fd)) {
if (!kore_connection_nonblock(c->fd, 1)) {
close(c->fd);
kore_pool_put(&connection_pool, c);
return (KORE_RESULT_ERROR);
@ -410,7 +410,7 @@ kore_connection_stop_idletimer(struct connection *c)
}
int
kore_connection_nonblock(int fd)
kore_connection_nonblock(int fd, int nodelay)
{
int flags;
@ -427,11 +427,13 @@ kore_connection_nonblock(int fd)
return (KORE_RESULT_ERROR);
}
flags = 1;
if (setsockopt(fd, IPPROTO_TCP,
TCP_NODELAY, (char *)&flags, sizeof(flags)) == -1) {
kore_log(LOG_NOTICE,
"failed to set TCP_NODELAY on %d", fd);
if (nodelay) {
flags = 1;
if (setsockopt(fd, IPPROTO_TCP,
TCP_NODELAY, (char *)&flags, sizeof(flags)) == -1) {
kore_log(LOG_NOTICE,
"failed to set TCP_NODELAY on %d", fd);
}
}
return (KORE_RESULT_OK);

View File

@ -258,7 +258,7 @@ kore_server_bind(const char *ip, const char *port)
return (KORE_RESULT_ERROR);
}
if (!kore_connection_nonblock(l->fd)) {
if (!kore_connection_nonblock(l->fd, 1)) {
kore_mem_free(l);
freeaddrinfo(results);
printf("failed to make socket non blocking: %s\n", errno_s);

View File

@ -127,8 +127,8 @@ kore_worker_spawn(u_int16_t id, u_int16_t cpu)
if (socketpair(AF_UNIX, SOCK_STREAM, 0, kw->pipe) == -1)
fatal("socketpair(): %s", errno_s);
if (!kore_connection_nonblock(kw->pipe[0]) ||
!kore_connection_nonblock(kw->pipe[1]))
if (!kore_connection_nonblock(kw->pipe[0], 0) ||
!kore_connection_nonblock(kw->pipe[1], 0))
fatal("could not set pipe fds to nonblocking: %s", errno_s);
kw->pid = fork();