fix botch in a fd_set boundary check which broke uses of

select(0,0,0,0,&to) as finegrained delay
This commit is contained in:
drochner 2002-10-23 10:04:15 +00:00
parent 40c4c0b63c
commit ecf9fbf1a3
2 changed files with 19 additions and 19 deletions

View file

@ -1,10 +1,10 @@
$NetBSD: distinfo,v 1.8 2002/10/14 11:49:54 skrll Exp $
$NetBSD: distinfo,v 1.9 2002/10/23 10:04:15 drochner Exp $
SHA1 (pth-1.4.1.tar.gz) = bc5b0847d57d2b78945a6c8d4ebab57e46213972
Size (pth-1.4.1.tar.gz) = 446287 bytes
SHA1 (patch-aa) = c2fafc8eba5f084468fe0d07b1763d801b9ead89
SHA1 (patch-ab) = 41dfb1d339d71ed344ab320d4f430ea8e1a04722
SHA1 (patch-ac) = ce52eaf1a7227abb31f45573ce7902c19cb16219
SHA1 (patch-ac) = 9bb3fe538a99b01a9719944d5c70f74d212dba87
SHA1 (patch-ad) = 6769672225854d3b8bc830dc223cccd72b629c8d
SHA1 (patch-ae) = 11ab7aa4e84eb01bb3956fdb58ff8d5f7e04a434
SHA1 (patch-af) = e6d065052b935a6a689603675b7d8a473b995a5b

View file

@ -1,7 +1,7 @@
$NetBSD: patch-ac,v 1.2 2002/10/14 11:49:55 skrll Exp $
$NetBSD: patch-ac,v 1.3 2002/10/23 10:04:16 drochner Exp $
--- pth_high.c.orig Sun Jan 27 13:14:36 2002
+++ pth_high.c
--- pth_high.c.orig Sun Jan 27 14:14:36 2002
+++ pth_high.c Wed Oct 23 11:38:37 2002
@@ -35,6 +35,42 @@
#include "pth_p.h"
@ -45,7 +45,7 @@ $NetBSD: patch-ac,v 1.2 2002/10/14 11:49:55 skrll Exp $
/* Pth variant of usleep(3) */
int pth_usleep(unsigned int usec)
{
@@ -141,8 +177,43 @@ int pth_sigwait_ev(const sigset_t *set,
@@ -141,8 +177,43 @@
return 0;
}
@ -90,7 +90,7 @@ $NetBSD: patch-ac,v 1.2 2002/10/14 11:49:55 skrll Exp $
{
pth_event_t ev;
static pth_key_t ev_key = PTH_KEY_INIT;
@@ -167,6 +238,8 @@ pid_t pth_waitpid(pid_t wpid, int *statu
@@ -167,6 +238,8 @@
pth_debug2("pth_waitpid: leave to thread \"%s\"", pth_current->name);
return pid;
}
@ -99,7 +99,7 @@ $NetBSD: patch-ac,v 1.2 2002/10/14 11:49:55 skrll Exp $
/* Pth variant of system(3) */
int pth_system(const char *cmd)
@@ -195,7 +268,7 @@ int pth_system(const char *cmd)
@@ -195,7 +268,7 @@
/* block SIGCHLD signal */
sigemptyset(&ss_block);
sigaddset(&ss_block, SIGCHLD);
@ -108,7 +108,7 @@ $NetBSD: patch-ac,v 1.2 2002/10/14 11:49:55 skrll Exp $
/* fork the current process */
pstat = -1;
@@ -207,7 +280,7 @@ int pth_system(const char *cmd)
@@ -207,7 +280,7 @@
/* restore original signal dispositions and execute the command */
sigaction(SIGINT, &sa_int, NULL);
sigaction(SIGQUIT, &sa_quit, NULL);
@ -117,7 +117,7 @@ $NetBSD: patch-ac,v 1.2 2002/10/14 11:49:55 skrll Exp $
/* stop the Pth scheduling */
pth_scheduler_kill();
@@ -227,7 +300,7 @@ int pth_system(const char *cmd)
@@ -227,7 +300,7 @@
/* restore original signal dispositions and execute the command */
sigaction(SIGINT, &sa_int, NULL);
sigaction(SIGQUIT, &sa_quit, NULL);
@ -126,17 +126,17 @@ $NetBSD: patch-ac,v 1.2 2002/10/14 11:49:55 skrll Exp $
/* return error or child process result code */
return (pid == -1 ? -1 : pstat);
@@ -258,6 +331,9 @@ int pth_select_ev(int nfd, fd_set *rfds,
@@ -258,6 +331,9 @@
pth_implicit_init();
pth_debug2("pth_select_ev: called from thread \"%s\"", pth_current->name);
+ if (!pth_util_fd_valid(nfd-1))
+ if (nfd < 0 || nfd > FD_SETSIZE)
+ return_errno(-1, EINVAL);
+
/* first deal with the special situation of a plain microsecond delay */
if (nfd == 0 && rfds == NULL && wfds == NULL && efds == NULL && timeout != NULL) {
if (timeout->tv_sec < 0 || timeout->tv_usec < 0)
@@ -280,10 +356,11 @@ int pth_select_ev(int nfd, fd_set *rfds,
@@ -280,10 +356,11 @@
return_errno(-1, EINTR);
}
}
@ -151,7 +151,7 @@ $NetBSD: patch-ac,v 1.2 2002/10/14 11:49:55 skrll Exp $
return 0;
}
@@ -295,36 +372,42 @@ int pth_select_ev(int nfd, fd_set *rfds,
@@ -295,36 +372,42 @@
delay.tv_sec = 0;
delay.tv_usec = 0;
rtmp = NULL;
@ -206,7 +206,7 @@ $NetBSD: patch-ac,v 1.2 2002/10/14 11:49:55 skrll Exp $
return 0;
}
}
@@ -350,10 +433,9 @@ int pth_select_ev(int nfd, fd_set *rfds,
@@ -350,10 +433,9 @@
pth_event_isolate(ev_timeout);
if (pth_event_occurred(ev_timeout)) {
selected = TRUE;
@ -220,7 +220,7 @@ $NetBSD: patch-ac,v 1.2 2002/10/14 11:49:55 skrll Exp $
rc = 0;
}
}
@@ -362,7 +444,7 @@ int pth_select_ev(int nfd, fd_set *rfds,
@@ -362,7 +444,7 @@
return rc;
}
@ -229,7 +229,7 @@ $NetBSD: patch-ac,v 1.2 2002/10/14 11:49:55 skrll Exp $
int pth_poll(struct pollfd *pfd, nfds_t nfd, int timeout)
{
return pth_poll_ev(pfd, nfd, timeout, NULL);
@@ -373,7 +455,7 @@ int pth_poll(struct pollfd *pfd, nfds_t
@@ -373,7 +455,7 @@
INTERNALLY THE SCHEDULER IS ONLY select(2) BASED!! */
int pth_poll_ev(struct pollfd *pfd, nfds_t nfd, int timeout, pth_event_t ev_extra)
{
@ -238,7 +238,7 @@ $NetBSD: patch-ac,v 1.2 2002/10/14 11:49:55 skrll Exp $
struct timeval tv, *ptv;
int maxfd, rc, ok;
unsigned int i;
@@ -410,58 +492,64 @@ int pth_poll_ev(struct pollfd *pfd, nfds
@@ -410,58 +492,64 @@
FD_ZERO(&rfds);
FD_ZERO(&wfds);
FD_ZERO(&efds);
@ -348,7 +348,7 @@ $NetBSD: patch-ac,v 1.2 2002/10/14 11:49:55 skrll Exp $
}
return rc;
}
@@ -498,6 +586,13 @@ int pth_connect_ev(int s, const struct s
@@ -498,6 +586,13 @@
/* if it is still on progress wait until socket is really writeable */
if (rv == -1 && errno == EINPROGRESS && fdmode != PTH_FDMODE_NONBLOCK) {
ev = pth_event(PTH_EVENT_FD|PTH_UNTIL_FD_WRITEABLE|PTH_MODE_STATIC, &ev_key, s);