From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qk1-x72e.google.com (mail-qk1-x72e.google.com [IPv6:2607:f8b0:4864:20::72e]) by sourceware.org (Postfix) with ESMTPS id 6D0AD3955434 for ; Tue, 13 Apr 2021 21:04:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 6D0AD3955434 Received: by mail-qk1-x72e.google.com with SMTP id b139so13966130qkc.10 for ; Tue, 13 Apr 2021 14:04:16 -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=BLoc5B7SF58wEgfBylThUloOT3gr+JzFFVzXeT6d8LA=; b=ijUIdTz2339+dj0etEn1HY9oO+t0Yd9+abjLneBwbfhRfRxKIs4R82X+qQ9rUy1Hqx bedHVyJZ54K5L0TtpLpWYsHHNTxpW/Re5bmjFMmJl31oyVlwKQKUC4yg8QP3VhoA/S0y KMhYG0+VbWxTR5vdNUu38HggQQjxx7ZOmdycbiajta6J2m4DmoWoroVaDSKkbOWGUXNi Iuyq/MpwX8BbzHoQq4MAtDo5Qp6kfXARfSVYuA7rw9+6sL53ji3kC/rAS921G11XlUUc yRqdVD+jSq6MNWdJRRYcmA6iSPn/vZ4ygeVwG9VH0KMZFXaedmn1U0pM2cs6w1cJuYqZ MTfw== X-Gm-Message-State: AOAM532zHX7cV+KP4b5njqZpwd068Ah//RcKbJn9yw3bygdYxYboqcMW cCh9BgUcfLRAVVSzNSXX3xJ4TPal404OmE9P X-Google-Smtp-Source: ABdhPJzV8cQyGgWG7zaG6wgfh7b/8r8s0cCtWRqY5IS91pIjQDGNG2eIKs1PAmBIoqKYZbsgQ5tulw== X-Received: by 2002:a05:620a:806:: with SMTP id s6mr15716955qks.57.1618347855916; Tue, 13 Apr 2021 14:04:15 -0700 (PDT) Received: from localhost.localdomain ([177.194.41.149]) by smtp.googlemail.com with ESMTPSA id g8sm10003383qtm.29.2021.04.13.14.04.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Apr 2021 14:04:15 -0700 (PDT) From: Adhemerval Zanella To: libc-stable@sourceware.org Subject: [PATCH 2.33 COMMITTED 6/6] linux: always update select timeout (BZ #27706) Date: Tue, 13 Apr 2021 18:04:05 -0300 Message-Id: <20210413210405.913196-6-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210413210405.913196-1-adhemerval.zanella@linaro.org> References: <20210413210405.913196-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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-stable@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-stable mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 13 Apr 2021 21:04:18 -0000 The timeout should be updated even on failure for time64 support. Checked on i686-linux-gnu. (cherry-pick from commit cedbf6d5f3f70ca911176de87d6e453eeab4b7a1) --- NEWS | 1 + misc/tst-select.c | 30 ++++++++++++++++++++++++++++++ sysdeps/unix/sysv/linux/select.c | 4 ++-- 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 52d676f6c5..769aeb24b7 100644 --- a/NEWS +++ b/NEWS @@ -23,6 +23,7 @@ The following bugs are resolved with this release: [27577] elf/ld.so --help doesn't work [27648] FAIL: misc/tst-select [27651] Performance regression after updating to 2.33 + [27706] select fails to update timeout on error Version 2.33 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 3b67ff4476..dc16a816ed 100644 --- a/sysdeps/unix/sysv/linux/select.c +++ b/sysdeps/unix/sysv/linux/select.c @@ -107,7 +107,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 @@ -128,7 +128,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; -- 2.27.0