From patchwork Mon Jul 15 13:00:18 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 2827476 Return-Path: X-Original-To: patchwork-dm-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 3EE629F7D6 for ; Mon, 15 Jul 2013 13:05:42 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 35CFF20168 for ; Mon, 15 Jul 2013 13:05:41 +0000 (UTC) Received: from mx4-phx2.redhat.com (mx4-phx2.redhat.com [209.132.183.25]) by mail.kernel.org (Postfix) with ESMTP id D7FAA20163 for ; Mon, 15 Jul 2013 13:05:38 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx4-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r6FD1xWA006420; Mon, 15 Jul 2013 09:01:59 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r6FD0dsQ028959 for ; Mon, 15 Jul 2013 09:00:39 -0400 Received: from mx1.redhat.com (ext-mx16.extmail.prod.ext.phx2.redhat.com [10.5.110.21]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r6FD0dUh006044 for ; Mon, 15 Jul 2013 09:00:39 -0400 Received: from mx2.suse.de (cantor2.suse.de [195.135.220.15]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r6FD0c1r025974 for ; Mon, 15 Jul 2013 09:00:38 -0400 Received: from relay1.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 5400AA5396; Mon, 15 Jul 2013 15:00:35 +0200 (CEST) From: Hannes Reinecke To: Christophe Varoqui Date: Mon, 15 Jul 2013 15:00:18 +0200 Message-Id: <1373893230-26077-18-git-send-email-hare@suse.de> In-Reply-To: <1373893230-26077-1-git-send-email-hare@suse.de> References: <1373893230-26077-1-git-send-email-hare@suse.de> X-RedHat-Spam-Score: -7.69 (BAYES_00, DCC_REPUT_00_12, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, URIBL_BLOCKED) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-Scanned-By: MIMEDefang 2.68 on 10.5.110.21 X-loop: dm-devel@redhat.com Cc: dm-devel@redhat.com Subject: [dm-devel] [PATCH 17/29] Correctly set max_fds in case of failure X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk Reply-To: device-mapper development List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If we fail to get the system limit for max_fds we should assume a safe value of 4096. Signed-off-by: Hannes Reinecke --- libmultipath/dict.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/libmultipath/dict.c b/libmultipath/dict.c index 6a58fa2..4b840de 100644 --- a/libmultipath/dict.c +++ b/libmultipath/dict.c @@ -290,18 +290,27 @@ static int max_fds_handler(vector strvec) { char * buff; - int r = 0; + int r = 0, max_fds; buff = set_value(strvec); if (!buff) return 1; + r = get_sys_max_fds(&max_fds); + if (r) { + /* Assume safe limit */ + max_fds = 4096; + } if (strlen(buff) == 3 && !strcmp(buff, "max")) - r = get_sys_max_fds(&conf->max_fds); + conf->max_fds = max_fds; else conf->max_fds = atoi(buff); + + if (conf->max_fds > max_fds) + conf->max_fds = max_fds; + FREE(buff); return r; @@ -2571,7 +2580,7 @@ snprint_max_fds (char * buff, int len, void * data) return 0; r = get_sys_max_fds(&max_fds); - if (!r && max_fds == conf->max_fds) + if (!r && conf->max_fds >= max_fds) return snprintf(buff, len, "\"max\""); else return snprintf(buff, len, "%d", conf->max_fds);