feat: reduce timeout, max file size, and use more workers by default

This commit is contained in:
Tom MTT. 2022-11-29 10:27:56 +01:00
parent 955c840ba4
commit 5ba58b1bd7
3 changed files with 13 additions and 11 deletions

View file

@ -68,13 +68,13 @@ Default: \f[V]/var/www/feuille\f[R]
.TP .TP
\f[B]-s bytes\f[R] \f[B]-s bytes\f[R]
Sets the maximum size for every paste (in bytes). 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 .TP
\f[B]-t seconds\f[R] \f[B]-t seconds\f[R]
Sets the timeout for the client to send the paste (in seconds). Sets the timeout for the client to send the paste (in seconds).
If set to zero, no timeout is set. If set to zero, no timeout is set.
(Not recommended.) (Not recommended.)
Default: \f[V]4\f[R]s Default: \f[V]2\f[R]s
.TP .TP
\f[B]-u\f[R] \f[B]-u\f[R]
Sets the user that will be used when dropping root privileges. 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. connections.
Those are \f[I]real\f[R] processes, not green / posix threads, you might Those are \f[I]real\f[R] processes, not green / posix threads, you might
not want to set this to a huge number. 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 .SH EXAMPLES
.TP .TP
\f[B]sudo feuille\f[R] \f[B]sudo feuille\f[R]

View file

@ -53,12 +53,12 @@ if possible).
**-s bytes** **-s bytes**
: Sets the maximum size for every paste (in bytes). : Sets the maximum size for every paste (in bytes).
: Default: `2097152`B (2MiB) : Default: `1048576`B (1MiB)
**-t seconds** **-t seconds**
: Sets the timeout for the client to send the paste (in seconds). : Sets the timeout for the client to send the paste (in seconds).
: If set to zero, no timeout is set. (Not recommended.) : If set to zero, no timeout is set. (Not recommended.)
: Default: `4`s : Default: `2`s
**-u** **-u**
: Sets the user that will be used when dropping root privileges. : Sets the user that will be used when dropping root privileges.
@ -83,7 +83,8 @@ client.
connections. connections.
: Those are *real* processes, not green / posix threads, : Those are *real* processes, not green / posix threads,
you might not want to set this to a huge number. 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 # EXAMPLES

View file

@ -44,10 +44,10 @@ Settings settings = {
.user = "www", .user = "www",
.id_length = 4, .id_length = 4,
.worker_count = 1, .worker_count = 4,
.port = 9999, .port = 9999,
.timeout = 4, .timeout = 2,
.max_size = 2097152, /* = 2MiB = 1024 * 1024 * 2 */ .max_size = 1048576, /* = 1MiB = 1024 * 1024 */
.buffer_size = 131072, /* = 128KiB = 1024 * 128 */ .buffer_size = 131072, /* = 128KiB = 1024 * 128 */
.verbose = 0, .verbose = 0,
@ -94,7 +94,7 @@ int main(int argc, char *argv[])
long long tmp; long long tmp;
/* set number of workers */ /* 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; settings.worker_count = tmp;
ARGBEGIN { ARGBEGIN {