diff options
author | David Härdeman <david@hardeman.nu> | 2020-06-22 15:50:06 +0200 |
---|---|---|
committer | David Härdeman <david@hardeman.nu> | 2020-06-22 15:50:06 +0200 |
commit | 80623b9ac9aedce77d27b7c0a54c1b1c245d9279 (patch) | |
tree | 36f368e5f1cd8dfcc6b4fe22806a8b4bf70582e5 | |
parent | fcd154280c21746db7d994ed1be77f20f91c90c0 (diff) |
Try to bump the max number of fds
-rw-r--r-- | main.c | 20 | ||||
-rw-r--r-- | utils.c | 8 |
2 files changed, 24 insertions, 4 deletions
@@ -14,6 +14,8 @@ #include <cap-ng.h> #include <pwd.h> #include <grp.h> +#include <sys/time.h> +#include <sys/resource.h> #include "main.h" #include "signal-handler.h" @@ -565,6 +567,7 @@ main(int argc, char **argv) { struct server *server; unsigned server_count; + struct rlimit old_rlimit; cfg_init(argc, argv); @@ -572,6 +575,23 @@ main(int argc, char **argv) cfg_read(); + /* + * In the splice case we use 4 fds per proxy connection... + */ + if (prlimit(0, RLIMIT_NOFILE, NULL, &old_rlimit) == 0) { + struct rlimit new_rlimit; + + new_rlimit.rlim_cur = old_rlimit.rlim_max; + new_rlimit.rlim_max = old_rlimit.rlim_max; + + if (prlimit(0, RLIMIT_NOFILE, &new_rlimit, NULL) == 0) + debug(DBG_MALLOC, "prlimit(NOFILE): %u/%u -> %u/%u", + (unsigned)old_rlimit.rlim_cur, + (unsigned)old_rlimit.rlim_max, + (unsigned)new_rlimit.rlim_cur, + (unsigned)new_rlimit.rlim_cur); + } + uring_init(); igmp_init(); @@ -224,7 +224,7 @@ connect_cb(struct uring_task *task, int res) conn = task->priv; if (res < 0) { - debug(DBG_UR, "%s: connection to %s failed", + debug(DBG_SRV, "%s: connection to %s failed", task->name, conn->remote.addrstr); uring_task_close_fd(task); connect_next(task, conn); @@ -233,7 +233,7 @@ connect_cb(struct uring_task *task, int res) connection_set_local(conn, task->fd); - debug(DBG_UR, "%s: connection established %s -> %s", + debug(DBG_SRV, "%s: connection established %s -> %s", task->name, conn->local.addrstr, conn->remote.addrstr); conn->cb(conn, true); @@ -261,14 +261,14 @@ again: } if (!remote) { - debug(DBG_UR, "%s: no more remote addresses to attempt", + debug(DBG_SRV, "%s: no more remote addresses to attempt", task->name); goto out; } conn->next_addr++; connection_set_remote(conn, remote); - debug(DBG_MALLOC, "%s: attempting to connect to %s", + debug(DBG_SRV, "%s: attempting to connect to %s", task->name, conn->remote.addrstr); sfd = socket(conn->remote.storage.ss_family, SOCK_STREAM | SOCK_CLOEXEC, 0); |