From patchwork Fri Apr 9 15:53:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 42940 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id AD98A399C035; Fri, 9 Apr 2021 15:53:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AD98A399C035 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1617983637; bh=mjXRdJtqYUalSFbQkUKRI1hjDkTtjA3hTr6JM/TjKuY=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=orQ9vGHc2ql0H68W+dS3XeewRNXI2fM4jxmim7EMiYpRJF5VH7o38T/vtjXqkdZD2 5ylvyvFufaVyTDubthnFfEPiiAaCD5p4Ly0zRAmjBKswjtokRKboYkOSfByN1hTh0/ tXxy6z+U1D2NWeoiFqfXf0YSuSSLAt6i7S336pJc= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qt1-x830.google.com (mail-qt1-x830.google.com [IPv6:2607:f8b0:4864:20::830]) by sourceware.org (Postfix) with ESMTPS id 2BBAD399C015 for ; Fri, 9 Apr 2021 15:53:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 2BBAD399C015 Received: by mail-qt1-x830.google.com with SMTP id g24so4503879qts.6 for ; Fri, 09 Apr 2021 08:53:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mjXRdJtqYUalSFbQkUKRI1hjDkTtjA3hTr6JM/TjKuY=; b=nzeslktFMD+M30H05T4B8cWtWf8PvNlD7bLY72nQ003HFdJ0kv42cIi8qa8wha37D2 5ypSJBO2dlM/a/io5d0DDDIEB1yPOkst/ViSSzQtCSEA90upiC1wHn9faSh3Hmcankf/ erll08FofeOiFMOCqODKxobrxqNZO+ArFjnIpxQ4/6DVbcAjmmX4fcQfjeS2orLeykFO 5aKRnsU1VRAkoBePt3fakjJmclFJ3JO6GU2pUUp46/ntlwf4ZGt/C+FoZb1cPKhtAq/0 0LZyGF/3WjiqUIETBP+YXU7F2S3aUS671ongUzzr6nTTcn5LeTXuIFAuKfxyoX+GjJHY ceEQ== X-Gm-Message-State: AOAM533/LwdTsxsEHXZt10Dm2dM/jFR6dnyPdeszkEYPcvZ60ULIb0Ow tlDNJ3MeXfJmUWbBNuY+Fx/ZVNG7w0LJ4lLy X-Google-Smtp-Source: ABdhPJy7Tc/jEKNKo3a9M414OMZE93GwmZALQkpMvhthqZaXoSMX2Pj2287/TpWQPHK6YcznpwgM2Q== X-Received: by 2002:aed:306c:: with SMTP id 99mr12912509qte.352.1617983634603; Fri, 09 Apr 2021 08:53:54 -0700 (PDT) Received: from localhost.localdomain ([177.194.41.149]) by smtp.googlemail.com with ESMTPSA id 79sm2087632qki.37.2021.04.09.08.53.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Apr 2021 08:53:54 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH v3 4/4] linux: always update select timeout (BZ #27706) Date: Fri, 9 Apr 2021 12:53:46 -0300 Message-Id: <20210409155346.1357023-4-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210409155346.1357023-1-adhemerval.zanella@linaro.org> References: <20210409155346.1357023-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" The timeout should be updated even on failure for time64 support. Checked on i686-linux-gnu. --- misc/tst-select.c | 30 ++++++++++++++++++++++++++++++ sysdeps/unix/sysv/linux/select.c | 4 ++-- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/misc/tst-select.c b/misc/tst-select.c index 534105b500..52aa26651f 100644 --- a/misc/tst-select.c +++ b/misc/tst-select.c @@ -23,6 +23,7 @@ #include #include #include +#include struct child_args { @@ -30,6 +31,12 @@ struct child_args struct timeval tmo; }; +static void +alarm_handler (int signum) +{ + /* Do nothing. */ +} + static void do_test_child (void *clousure) { @@ -59,6 +66,22 @@ do_test_child (void *clousure) xwrite (args->fds[1][1], "foo", 3); } +static void +do_test_child_alarm (void *clousure) +{ + struct sigaction act = { .sa_handler = alarm_handler }; + xsigaction (SIGALRM, &act, NULL); + alarm (1); + + struct timeval tv = { .tv_sec = 10, .tv_usec = 0 }; + int r = select (0, NULL, NULL, NULL, &tv); + TEST_COMPARE (r, -1); + TEST_COMPARE (errno, EINTR); + + if (support_select_modifies_timeout ()) + TEST_VERIFY (tv.tv_sec < 10); +} + static int do_test (void) { @@ -98,6 +121,13 @@ do_test (void) xclose (args.fds[0][0]); xclose (args.fds[1][1]); + { + struct support_capture_subprocess result; + result = support_capture_subprocess (do_test_child_alarm, NULL); + support_capture_subprocess_check (&result, "tst-select-child", 0, + sc_allow_none); + } + { fd_set rfds; FD_ZERO (&rfds); diff --git a/sysdeps/unix/sysv/linux/select.c b/sysdeps/unix/sysv/linux/select.c index 8deab751c0..5d87a3d1f9 100644 --- a/sysdeps/unix/sysv/linux/select.c +++ b/sysdeps/unix/sysv/linux/select.c @@ -110,7 +110,7 @@ __select64 (int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, r = SYSCALL_CANCEL (pselect6, nfds, readfds, writefds, exceptfds, pts32, NULL); # endif - if (r >= 0 && timeout != NULL) + if (timeout != NULL) *timeout = valid_timespec_to_timeval64 (ts32); #endif @@ -131,7 +131,7 @@ __select (int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, ptv64 = &tv64; } int r = __select64 (nfds, readfds, writefds, exceptfds, ptv64); - if (r >= 0 && timeout != NULL) + if (timeout != NULL) /* The remanining timeout will be always less the input TIMEOUT. */ *timeout = valid_timeval64_to_timeval (tv64); return r;