mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-07 07:37:02 +02:00
MINOR: debug: use LIM2A to show limits
It is more handy to use LIM2A in debug_parse_cli_show_dev(), as it allows to show a custom string ("unlimited"), if a given limit value equals to 0. normalize_rlim() handler is needed to convert properly RLIM_INFINITY to zero, with the respect of type sizes, as rlim_t is always 4 bytes on 32bit and 64bit arch.
This commit is contained in:
parent
93cc7df276
commit
665dde6481
@ -8,10 +8,23 @@
|
|||||||
#ifndef _HAPROXY_LIMITS_H
|
#ifndef _HAPROXY_LIMITS_H
|
||||||
#define _HAPROXY_LIMITS_H
|
#define _HAPROXY_LIMITS_H
|
||||||
#include <sys/resource.h>
|
#include <sys/resource.h>
|
||||||
|
#include <haproxy/compat.h>
|
||||||
|
|
||||||
extern unsigned int rlim_fd_cur_at_boot;
|
extern unsigned int rlim_fd_cur_at_boot;
|
||||||
extern unsigned int rlim_fd_max_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(ulong rlim)
|
||||||
|
{
|
||||||
|
if (rlim == RLIM_INFINITY)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return rlim;
|
||||||
|
}
|
||||||
|
|
||||||
/* handlers to compute internal process limits, if they are not provided via
|
/* handlers to compute internal process limits, if they are not provided via
|
||||||
* cmd line or via configuration file.
|
* cmd line or via configuration file.
|
||||||
*/
|
*/
|
||||||
|
17
src/debug.c
17
src/debug.c
@ -38,6 +38,7 @@
|
|||||||
#include <haproxy/global.h>
|
#include <haproxy/global.h>
|
||||||
#include <haproxy/hlua.h>
|
#include <haproxy/hlua.h>
|
||||||
#include <haproxy/http_ana.h>
|
#include <haproxy/http_ana.h>
|
||||||
|
#include <haproxy/limits.h>
|
||||||
#if defined(USE_LINUX_CAP)
|
#if defined(USE_LINUX_CAP)
|
||||||
#include <haproxy/linuxcap.h>
|
#include <haproxy/linuxcap.h>
|
||||||
#endif
|
#endif
|
||||||
@ -605,14 +606,14 @@ static int debug_parse_cli_show_dev(char **args, char *payload, struct appctx *a
|
|||||||
chunk_appendf(&trash, " capget() failed at runtime with: %s.\n",
|
chunk_appendf(&trash, " capget() failed at runtime with: %s.\n",
|
||||||
strerror(post_mortem.process.caps.err_run));
|
strerror(post_mortem.process.caps.err_run));
|
||||||
#endif
|
#endif
|
||||||
if ((ulong)post_mortem.process.limit_fd.rlim_cur != RLIM_INFINITY)
|
chunk_appendf(&trash, " fd limit (soft): %s\n",
|
||||||
chunk_appendf(&trash, " fd limit (soft): %lu\n", (ulong)post_mortem.process.limit_fd.rlim_cur);
|
LIM2A(normalize_rlim((ulong)post_mortem.process.limit_fd.rlim_cur), "unlimited"));
|
||||||
if ((ulong)post_mortem.process.limit_fd.rlim_max != RLIM_INFINITY)
|
chunk_appendf(&trash, " fd limit (hard): %s\n",
|
||||||
chunk_appendf(&trash, " fd limit (hard): %lu\n", (ulong)post_mortem.process.limit_fd.rlim_max);
|
LIM2A(normalize_rlim((ulong)post_mortem.process.limit_fd.rlim_max), "unlimited"));
|
||||||
if ((ulong)post_mortem.process.limit_ram.rlim_cur != RLIM_INFINITY)
|
chunk_appendf(&trash, " ram limit (soft): %s\n",
|
||||||
chunk_appendf(&trash, " ram limit (soft): %lu\n", (ulong)post_mortem.process.limit_ram.rlim_cur);
|
LIM2A(normalize_rlim((ulong)post_mortem.process.limit_ram.rlim_cur), "unlimited"));
|
||||||
if ((ulong)post_mortem.process.limit_ram.rlim_max != RLIM_INFINITY)
|
chunk_appendf(&trash, " ram limit (hard): %s\n",
|
||||||
chunk_appendf(&trash, " ram limit (hard): %lu\n", (ulong)post_mortem.process.limit_ram.rlim_max);
|
LIM2A(normalize_rlim((ulong)post_mortem.process.limit_ram.rlim_max), "unlimited"));
|
||||||
|
|
||||||
return cli_msg(appctx, LOG_INFO, trash.area);
|
return cli_msg(appctx, LOG_INFO, trash.area);
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <haproxy/compat.h>
|
|
||||||
#include <haproxy/global.h>
|
#include <haproxy/global.h>
|
||||||
#include <haproxy/limits.h>
|
#include <haproxy/limits.h>
|
||||||
#include <haproxy/proxy.h>
|
#include <haproxy/proxy.h>
|
||||||
|
Loading…
Reference in New Issue
Block a user