From patchwork Tue Aug 29 15:58:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 9927685 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D971E60383 for ; Tue, 29 Aug 2017 15:58:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CC862289A6 for ; Tue, 29 Aug 2017 15:58:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BBCCC2899F; Tue, 29 Aug 2017 15:58:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 647192899F for ; Tue, 29 Aug 2017 15:58:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752916AbdH2P6u (ORCPT ); Tue, 29 Aug 2017 11:58:50 -0400 Received: from quartz.orcorp.ca ([184.70.90.242]:52867 "EHLO quartz.orcorp.ca" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751808AbdH2P6t (ORCPT ); Tue, 29 Aug 2017 11:58:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=obsidianresearch.com; s=rsa1; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=XoDwXgUg+IRr0l9NuMEL18NKu/XcIhgN7b/BHqnwapM=; b=UcqMbozqtlUG7oaLI376EVr0Dwwp/1IqHNzQ7v7C6SUbEDq0+/irCkhRhj4fwXplvGMZDmUgrMVt7kFuJWezO9O/7uAJHj0gzdq6bd1ZG+AHghC9NOwkSHmt0kt2KrPcSxafmrQ0CsutuVFyQVxFyqdbU8KlL7uzb7xT4e0dOTc=; Received: from [10.0.0.156] (helo=jggl.edm.orcorp.ca) by quartz.orcorp.ca with esmtps (TLS1.2:ECDHE_RSA_AES_128_CBC_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1dmiud-0007uu-D0; Tue, 29 Aug 2017 09:58:47 -0600 From: Jason Gunthorpe To: linux-rdma@vger.kernel.org Cc: Bart Van Assche Subject: [PATCH rdma-core 2/4] srp_daemon: Use pipe2 instead of pip&fcntl Date: Tue, 29 Aug 2017 09:58:43 -0600 Message-Id: <1504022325-31039-3-git-send-email-jgunthorpe@obsidianresearch.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504022325-31039-1-git-send-email-jgunthorpe@obsidianresearch.com> References: <1504022325-31039-1-git-send-email-jgunthorpe@obsidianresearch.com> X-Broken-Reverse-DNS: no host name found for IP address 10.0.0.156 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Just make a nonblocking pipe directly. Signed-off-by: Jason Gunthorpe --- srp_daemon/srp_daemon.c | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/srp_daemon/srp_daemon.c b/srp_daemon/srp_daemon.c index 94d52673dc0fb6..2465ccd9e74f07 100644 --- a/srp_daemon/srp_daemon.c +++ b/srp_daemon/srp_daemon.c @@ -1998,25 +1998,12 @@ static int setup_wakeup_fd(void) { struct sigaction sa = {}; int ret; - int i; - int flags; - ret = pipe(wakeup_pipe); + ret = pipe2(wakeup_pipe, O_NONBLOCK | O_CLOEXEC); if (ret < 0) { pr_err("could not create pipe\n"); return -1; } - for (i = 0; i < 2; i++) { - flags = fcntl(wakeup_pipe[i], F_GETFL); - if (flags < 0) { - pr_err("fcntl F_GETFL failed for %d\n", wakeup_pipe[i]); - goto close_pipe; - } - if (fcntl(wakeup_pipe[i], F_SETFL, flags | O_NONBLOCK) < 0) { - pr_err("fcntl F_SETFL failed for %d\n", wakeup_pipe[i]); - goto close_pipe; - } - } sigemptyset(&sa.sa_mask); sa.sa_handler = signal_handler; @@ -2024,10 +2011,6 @@ static int setup_wakeup_fd(void) sigaction(SIGTERM, &sa, NULL); sigaction(SRP_CATAS_ERR, &sa, NULL); return 0; - -close_pipe: - cleanup_wakeup_fd(); - return -1; } static int ibsrpdm(int argc, char *argv[])