mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-29 11:41:21 +03:00
linux: always update select timeout (BZ #27706)
The timeout should be updated even on failure for time64 support. Checked on i686-linux-gnu.
This commit is contained in:
@ -23,6 +23,7 @@
|
|||||||
#include <support/timespec.h>
|
#include <support/timespec.h>
|
||||||
#include <support/xunistd.h>
|
#include <support/xunistd.h>
|
||||||
#include <support/xtime.h>
|
#include <support/xtime.h>
|
||||||
|
#include <support/xsignal.h>
|
||||||
|
|
||||||
struct child_args
|
struct child_args
|
||||||
{
|
{
|
||||||
@ -30,6 +31,12 @@ struct child_args
|
|||||||
struct timeval tmo;
|
struct timeval tmo;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void
|
||||||
|
alarm_handler (int signum)
|
||||||
|
{
|
||||||
|
/* Do nothing. */
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
do_test_child (void *clousure)
|
do_test_child (void *clousure)
|
||||||
{
|
{
|
||||||
@ -59,6 +66,22 @@ do_test_child (void *clousure)
|
|||||||
xwrite (args->fds[1][1], "foo", 3);
|
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
|
static int
|
||||||
do_test (void)
|
do_test (void)
|
||||||
{
|
{
|
||||||
@ -98,6 +121,13 @@ do_test (void)
|
|||||||
xclose (args.fds[0][0]);
|
xclose (args.fds[0][0]);
|
||||||
xclose (args.fds[1][1]);
|
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_set rfds;
|
||||||
FD_ZERO (&rfds);
|
FD_ZERO (&rfds);
|
||||||
|
@ -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,
|
r = SYSCALL_CANCEL (pselect6, nfds, readfds, writefds, exceptfds, pts32,
|
||||||
NULL);
|
NULL);
|
||||||
# endif
|
# endif
|
||||||
if (r >= 0 && timeout != NULL)
|
if (timeout != NULL)
|
||||||
*timeout = valid_timespec_to_timeval64 (ts32);
|
*timeout = valid_timespec_to_timeval64 (ts32);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -128,7 +128,7 @@ __select (int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
|
|||||||
ptv64 = &tv64;
|
ptv64 = &tv64;
|
||||||
}
|
}
|
||||||
int r = __select64 (nfds, readfds, writefds, exceptfds, ptv64);
|
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. */
|
/* The remanining timeout will be always less the input TIMEOUT. */
|
||||||
*timeout = valid_timeval64_to_timeval (tv64);
|
*timeout = valid_timeval64_to_timeval (tv64);
|
||||||
return r;
|
return r;
|
||||||
|
Reference in New Issue
Block a user