haproxy/include/haproxy/limits.h
Willy Tarreau f486f976c7 BUILD: limits: make normalize_rlim() take an rlim_t to fix build on m68k
As can be seen here, the build fails on m68k since commit 665dde648
("MINOR: debug: use LIM2A to show limits") in 3.1:

  https://github.com/haproxy/haproxy/actions/runs/12440234399/job/34735360177

The reason is the comparison between a ulong limit and RLIM_INFINITY.
Indeed, on m68k, rlim_t is an unsigned long long. Let's just change
the function's input type to take an rlim_t instead. This also allows
to get rid of the casts in the call place.

This can be backported to 3.1 though it's not important given the low
prevalence of this platform for such use cases.
2024-12-25 12:33:06 +01:00

49 lines
1.2 KiB
C

/*
* Handlers for process resources limits.
*
* SPDX-License-Identifier: LGPL-2.1-or-later.
*
*/
#ifndef _HAPROXY_LIMITS_H
#define _HAPROXY_LIMITS_H
#include <errno.h>
#include <fcntl.h>
#include <sys/resource.h>
#include <haproxy/compat.h>
extern unsigned int rlim_fd_cur_at_boot;
extern unsigned int rlim_fd_max_at_boot;
/* returns 0 if the given limit was not set (reported as infinity), otherwise
* returns the limit, useful to print limit values as strings in err messages
* via LIM2A macros.
*/
static inline ulong normalize_rlim(rlim_t rlim)
{
if (rlim == RLIM_INFINITY)
return 0;
return (ulong)rlim;
}
/* handlers to compute internal process limits, if they are not provided via
* cmd line or via configuration file.
*/
int compute_ideal_maxpipes();
int compute_ideal_maxsock(int maxconn);
int check_if_maxsock_permitted(int maxsock);
/* handlers to manipulate system resources limits granted by OS to process and
* to tie them up with the internal process limits
*/
int raise_rlim_nofile(struct rlimit *old_limit, struct rlimit *new_limit);
void set_global_maxconn(void);
void apply_nofile_limit(void);
void apply_memory_limit(void);
void check_nofile_lim_and_prealloc_fd(void);
#endif /* _HAPROXY_LIMITS_H */