From 5ba58b1bd7ca9376b20c31c17ce86dd161c053e7 Mon Sep 17 00:00:00 2001 From: Tom MTT Date: Tue, 29 Nov 2022 10:27:56 +0100 Subject: [PATCH] feat: reduce timeout, max file size, and use more workers by default --- feuille.1 | 7 ++++--- feuille.1.md | 7 ++++--- feuille.c | 10 +++++----- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/feuille.1 b/feuille.1 index 80877ba..f790afe 100644 --- a/feuille.1 +++ b/feuille.1 @@ -68,13 +68,13 @@ Default: \f[V]/var/www/feuille\f[R] .TP \f[B]-s bytes\f[R] Sets the maximum size for every paste (in bytes). -Default: \f[V]2097152\f[R]B (2MiB) +Default: \f[V]1048576\f[R]B (1MiB) .TP \f[B]-t seconds\f[R] Sets the timeout for the client to send the paste (in seconds). If set to zero, no timeout is set. (Not recommended.) -Default: \f[V]4\f[R]s +Default: \f[V]2\f[R]s .TP \f[B]-u\f[R] Sets the user that will be used when dropping root privileges. @@ -99,7 +99,8 @@ Sets the number of processes that will be spawned to handle the connections. Those are \f[I]real\f[R] processes, not green / posix threads, you might not want to set this to a huge number. -Default: the number of threads configured on your machine. +Default: the greater of the number of cores in your computer and +\f[V]4\f[R] workers. .SH EXAMPLES .TP \f[B]sudo feuille\f[R] diff --git a/feuille.1.md b/feuille.1.md index b11458d..aecc491 100644 --- a/feuille.1.md +++ b/feuille.1.md @@ -53,12 +53,12 @@ if possible). **-s bytes** : Sets the maximum size for every paste (in bytes). -: Default: `2097152`B (2MiB) +: Default: `1048576`B (1MiB) **-t seconds** : Sets the timeout for the client to send the paste (in seconds). : If set to zero, no timeout is set. (Not recommended.) -: Default: `4`s +: Default: `2`s **-u** : Sets the user that will be used when dropping root privileges. @@ -83,7 +83,8 @@ client. connections. : Those are *real* processes, not green / posix threads, you might not want to set this to a huge number. -: Default: the number of threads configured on your machine. +: Default: the greater of the number of cores in your computer and +`4` workers. # EXAMPLES diff --git a/feuille.c b/feuille.c index a3064b9..c262bcd 100644 --- a/feuille.c +++ b/feuille.c @@ -44,11 +44,11 @@ Settings settings = { .user = "www", .id_length = 4, - .worker_count = 1, + .worker_count = 4, .port = 9999, - .timeout = 4, - .max_size = 2097152, /* = 2MiB = 1024 * 1024 * 2 */ - .buffer_size = 131072, /* = 128KiB = 1024 * 128 */ + .timeout = 2, + .max_size = 1048576, /* = 1MiB = 1024 * 1024 */ + .buffer_size = 131072, /* = 128KiB = 1024 * 128 */ .verbose = 0, .foreground = 0 @@ -94,7 +94,7 @@ int main(int argc, char *argv[]) long long tmp; /* set number of workers */ - if ((tmp = sysconf(_SC_NPROCESSORS_ONLN)) > 0 && tmp <= USHRT_MAX) + if ((tmp = sysconf(_SC_NPROCESSORS_ONLN)) > settings.worker_count && tmp <= USHRT_MAX) settings.worker_count = tmp; ARGBEGIN {