mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-06 15:17:01 +02:00
tune.rcvbuf.client and tune.rcvbuf.server are not suitable for shared dgram sockets because they're per connection so their units are not the same. However, QUIC's listener and log servers are not connected and take per-thread or per-process traffic where a socket log buffer might be too small, causing undesirable packet losses and retransmits in the case of QUIC. This essentially manifests in listener mode with new connections taking a lot of time to set up under heavy traffic due to the small queues causing delays. Let's add a few new settings allowing to set these shared socket sizes on the frontend and backend side (which reminds that these are per-front/back and not per client/server hence not per connection).
80 lines
2.2 KiB
C
80 lines
2.2 KiB
C
/*
|
|
* Datagram processing functions
|
|
*
|
|
* Copyright 2014 Baptiste Assmann <bedis9@gmail.com>
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public License
|
|
* as published by the Free Software Foundation; either version
|
|
* 2 of the License, or (at your option) any later version.
|
|
*
|
|
*/
|
|
|
|
#include <haproxy/fd.h>
|
|
#include <haproxy/cfgparse.h>
|
|
#include <haproxy/dgram.h>
|
|
#include <haproxy/errors.h>
|
|
#include <haproxy/tools.h>
|
|
|
|
/* datagram handler callback */
|
|
void dgram_fd_handler(int fd)
|
|
{
|
|
struct dgram_conn *dgram = fdtab[fd].owner;
|
|
|
|
if (unlikely(!dgram))
|
|
return;
|
|
|
|
if (fd_recv_ready(fd))
|
|
dgram->data->recv(dgram);
|
|
if (fd_send_ready(fd))
|
|
dgram->data->send(dgram);
|
|
|
|
return;
|
|
}
|
|
|
|
/* config parser for global "tune.{rcv,snd}buf.{frontend,backend}" */
|
|
static int dgram_parse_tune_bufs(char **args, int section_type, struct proxy *curpx,
|
|
const struct proxy *defpx, const char *file, int line,
|
|
char **err)
|
|
{
|
|
int *valptr;
|
|
int val;
|
|
|
|
if (too_many_args(1, args, err, NULL))
|
|
return -1;
|
|
|
|
/* "tune.rcvbuf.frontend", "tune.rcvbuf.backend",
|
|
* "tune.sndbuf.frontend", "tune.sndbuf.backend"
|
|
*/
|
|
valptr = (args[0][5] == 'r' && args[0][12] == 'f') ? &global.tune.frontend_rcvbuf :
|
|
(args[0][5] == 'r' && args[0][12] == 'b') ? &global.tune.backend_rcvbuf :
|
|
(args[0][5] == 's' && args[0][12] == 'f') ? &global.tune.frontend_sndbuf :
|
|
&global.tune.backend_sndbuf;
|
|
|
|
if (*valptr != 0) {
|
|
memprintf(err, "parsing [%s:%d] : ignoring '%s' which was already specified.\n", file, line, args[0]);
|
|
return 1;
|
|
}
|
|
|
|
val = atoi(args[1]);
|
|
|
|
if (*(args[1]) == 0 || val <= 0) {
|
|
memprintf(err, "parsing [%s:%d] : '%s' expects a strictly positive integer argument.\n", file, line, args[0]);
|
|
return -1;
|
|
}
|
|
|
|
*valptr = val;
|
|
return 0;
|
|
}
|
|
|
|
/* register "global" section keywords */
|
|
static struct cfg_kw_list dgram_cfg_kws = {ILH, {
|
|
{ CFG_GLOBAL, "tune.rcvbuf.backend", dgram_parse_tune_bufs },
|
|
{ CFG_GLOBAL, "tune.rcvbuf.frontend", dgram_parse_tune_bufs },
|
|
{ CFG_GLOBAL, "tune.sndbuf.backend", dgram_parse_tune_bufs },
|
|
{ CFG_GLOBAL, "tune.sndbuf.frontend", dgram_parse_tune_bufs },
|
|
{ 0, NULL, NULL }
|
|
}};
|
|
|
|
INITCALL1(STG_REGISTER, cfg_register_keywords, &dgram_cfg_kws);
|