[sheepdog] [PATCH v2] try to set RLIMIT_NOFILE to recommended value
Alexander Guy
alexander at andern.org
Tue Mar 17 00:19:01 CET 2015
Hey Vasiliy,
Thanks for updating your patch.
On Tue, Mar 17, 2015 at 12:46:10AM +0300, Vasiliy Tolstov wrote:
> Signed-off-by: Vasiliy Tolstov <v.tolstov at selfip.ru>
> ---
> sheep/sheep.c | 31 ++++++++++++++++++-------------
> 1 file changed, 18 insertions(+), 13 deletions(-)
>
> diff --git a/sheep/sheep.c b/sheep/sheep.c
> index fc53ec9..4a93825 100644
> --- a/sheep/sheep.c
> +++ b/sheep/sheep.c
> @@ -522,20 +522,25 @@ static int create_work_queues(void)
>
> static void check_host_env(void)
> {
> - struct rlimit r;
> + struct rlimit r;
You'll want to modify your editor's indentation to match the existing formatting in
the code base.
If you use './script/checkpatch.pl' it will perform a good sanity check before
you send code to the list.
> + int ret;
> +
> + ret = getrlimit(RLIMIT_NOFILE, &r);
> + if (ret < 0)
> + sd_err("failed to getrlimit");
If getrlimit fails, you don't want to assume that the contents of r is any good. You need
to wrap the code below:
> +
> + if (r.rlim_cur < SD_RLIM_NOFILE) {
> + sd_warn("Allowed open files %lu, suggested %u", r.rlim_cur, SD_RLIM_NOFILE);
It doesn't seem like you want to warn here. If the setrlimit below succeeds, then
there's no problem.
> + if (setrlimit(RLIMIT_NOFILE, &r) != 0) {
> + sd_warn("Failed to set open files limit to suggested %lu",
> + r.rlim_cur);
> + } else {
> + sd_info("Allowed open files set to suggested %lu", r.rlim_cur);
> + }
> + }
Thanks.
Alexander
More information about the sheepdog
mailing list