kore

An easy to use, scalable and secure web application framework for writing web APIs in C.
Commits | Files | Refs | README | LICENSE | git clone https://git.kore.io/kore.git

commit 28e48727a56263ce7466e3cc69419a7cbe722a78
parent e9832b441621b2d9b2c2e924e035e42806ed6702
Author: Joris Vink <joris@coders.se>
Date:   Mon, 22 Jun 2015 22:11:03 +0200

Kill TCP_NODELAY warnings for socketpair() fds.

Diffstat:
includes/kore.h | 2+-
src/connection.c | 16+++++++++-------
src/kore.c | 2+-
src/worker.c | 4++--
4 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/includes/kore.h b/includes/kore.h @@ -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 *); diff --git a/src/connection.c b/src/connection.c @@ -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); diff --git a/src/kore.c b/src/kore.c @@ -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); diff --git a/src/worker.c b/src/worker.c @@ -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();