summaryrefslogtreecommitdiff
path: root/devel/pth
diff options
context:
space:
mode:
authorskrll <skrll@pkgsrc.org>2002-11-26 21:42:48 +0000
committerskrll <skrll@pkgsrc.org>2002-11-26 21:42:48 +0000
commitc8cce16f68f028ea1277b618dac353ec9e73a1e5 (patch)
treef8313e64a7b6fb3c6abf18319fd98a7b9965020c /devel/pth
parent04b9ad7a1f8bd093be6c22991597812b23ac2e58 (diff)
downloadpkgsrc-c8cce16f68f028ea1277b618dac353ec9e73a1e5.tar.gz
Improve error handling. Patches backported from pth -current.
PKGREVISION++ This fixes PR 19162 from Ingolf Steinbach.
Diffstat (limited to 'devel/pth')
-rw-r--r--devel/pth/Makefile4
-rw-r--r--devel/pth/distinfo7
-rw-r--r--devel/pth/patches/patch-ac148
-rw-r--r--devel/pth/patches/patch-ag17
-rw-r--r--devel/pth/patches/patch-ak38
5 files changed, 187 insertions, 27 deletions
diff --git a/devel/pth/Makefile b/devel/pth/Makefile
index 570d9e2497c..4c2bb4ed1ee 100644
--- a/devel/pth/Makefile
+++ b/devel/pth/Makefile
@@ -1,8 +1,8 @@
-# $NetBSD: Makefile,v 1.52 2002/10/23 10:18:10 drochner Exp $
+# $NetBSD: Makefile,v 1.53 2002/11/26 21:42:48 skrll Exp $
#
DISTNAME= pth-1.4.1
-PKGREVISION= 5
+PKGREVISION= 6
CATEGORIES= devel
MASTER_SITES= ${MASTER_SITE_GNU:=pth/}
diff --git a/devel/pth/distinfo b/devel/pth/distinfo
index 11f15e9819c..76d0735c99e 100644
--- a/devel/pth/distinfo
+++ b/devel/pth/distinfo
@@ -1,14 +1,15 @@
-$NetBSD: distinfo,v 1.9 2002/10/23 10:04:15 drochner Exp $
+$NetBSD: distinfo,v 1.10 2002/11/26 21:42:48 skrll 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) = 9bb3fe538a99b01a9719944d5c70f74d212dba87
+SHA1 (patch-ac) = 0c9409f90cfe3d8794af03236055b1bb27e9f88a
SHA1 (patch-ad) = 6769672225854d3b8bc830dc223cccd72b629c8d
SHA1 (patch-ae) = 11ab7aa4e84eb01bb3956fdb58ff8d5f7e04a434
SHA1 (patch-af) = e6d065052b935a6a689603675b7d8a473b995a5b
-SHA1 (patch-ag) = 6eea1e1a5e66e7f12ea279bcf80d5cbdfc14ac75
+SHA1 (patch-ag) = 1f4cdebe81b10e0cb9e38e6f3cb5aeb521038755
SHA1 (patch-ah) = e9080d4b1e81fd0058233cf776ac49d56d01b79a
SHA1 (patch-ai) = 0e9ef6a500470df351d616933fa086ad21e8b90c
SHA1 (patch-aj) = 7d45920f6d8aba1de8dd6a69f1ce4591c81247d2
+SHA1 (patch-ak) = 7a84b9e71466a7bb9c1eea0c0815b19d5dee5ad1
diff --git a/devel/pth/patches/patch-ac b/devel/pth/patches/patch-ac
index 5577fef00ac..1a8268e7c68 100644
--- a/devel/pth/patches/patch-ac
+++ b/devel/pth/patches/patch-ac
@@ -1,7 +1,7 @@
-$NetBSD: patch-ac,v 1.3 2002/10/23 10:04:16 drochner Exp $
+$NetBSD: patch-ac,v 1.4 2002/11/26 21:42:49 skrll Exp $
---- pth_high.c.orig Sun Jan 27 14:14:36 2002
-+++ pth_high.c Wed Oct 23 11:38:37 2002
+--- pth_high.c.orig Sun Jan 27 13:14:36 2002
++++ pth_high.c
@@ -35,6 +35,42 @@
#include "pth_p.h"
@@ -45,7 +45,7 @@ $NetBSD: patch-ac,v 1.3 2002/10/23 10:04:16 drochner Exp $
/* Pth variant of usleep(3) */
int pth_usleep(unsigned int usec)
{
-@@ -141,8 +177,43 @@
+@@ -141,8 +177,43 @@ int pth_sigwait_ev(const sigset_t *set,
return 0;
}
@@ -90,7 +90,7 @@ $NetBSD: patch-ac,v 1.3 2002/10/23 10:04:16 drochner Exp $
{
pth_event_t ev;
static pth_key_t ev_key = PTH_KEY_INIT;
-@@ -167,6 +238,8 @@
+@@ -167,6 +238,8 @@ pid_t pth_waitpid(pid_t wpid, int *statu
pth_debug2("pth_waitpid: leave to thread \"%s\"", pth_current->name);
return pid;
}
@@ -99,7 +99,7 @@ $NetBSD: patch-ac,v 1.3 2002/10/23 10:04:16 drochner Exp $
/* Pth variant of system(3) */
int pth_system(const char *cmd)
-@@ -195,7 +268,7 @@
+@@ -195,7 +268,7 @@ int pth_system(const char *cmd)
/* block SIGCHLD signal */
sigemptyset(&ss_block);
sigaddset(&ss_block, SIGCHLD);
@@ -108,7 +108,7 @@ $NetBSD: patch-ac,v 1.3 2002/10/23 10:04:16 drochner Exp $
/* fork the current process */
pstat = -1;
-@@ -207,7 +280,7 @@
+@@ -207,7 +280,7 @@ int pth_system(const char *cmd)
/* 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.3 2002/10/23 10:04:16 drochner Exp $
/* stop the Pth scheduling */
pth_scheduler_kill();
-@@ -227,7 +300,7 @@
+@@ -227,7 +300,7 @@ int pth_system(const char *cmd)
/* restore original signal dispositions and execute the command */
sigaction(SIGINT, &sa_int, NULL);
sigaction(SIGQUIT, &sa_quit, NULL);
@@ -126,7 +126,7 @@ $NetBSD: patch-ac,v 1.3 2002/10/23 10:04:16 drochner Exp $
/* return error or child process result code */
return (pid == -1 ? -1 : pstat);
-@@ -258,6 +331,9 @@
+@@ -258,6 +331,9 @@ int pth_select_ev(int nfd, fd_set *rfds,
pth_implicit_init();
pth_debug2("pth_select_ev: called from thread \"%s\"", pth_current->name);
@@ -136,7 +136,7 @@ $NetBSD: patch-ac,v 1.3 2002/10/23 10:04:16 drochner Exp $
/* 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 @@
+@@ -280,10 +356,11 @@ int pth_select_ev(int nfd, fd_set *rfds,
return_errno(-1, EINTR);
}
}
@@ -151,7 +151,7 @@ $NetBSD: patch-ac,v 1.3 2002/10/23 10:04:16 drochner Exp $
return 0;
}
-@@ -295,36 +372,42 @@
+@@ -295,36 +372,42 @@ int pth_select_ev(int nfd, fd_set *rfds,
delay.tv_sec = 0;
delay.tv_usec = 0;
rtmp = NULL;
@@ -206,7 +206,7 @@ $NetBSD: patch-ac,v 1.3 2002/10/23 10:04:16 drochner Exp $
return 0;
}
}
-@@ -350,10 +433,9 @@
+@@ -350,10 +433,9 @@ int pth_select_ev(int nfd, fd_set *rfds,
pth_event_isolate(ev_timeout);
if (pth_event_occurred(ev_timeout)) {
selected = TRUE;
@@ -220,7 +220,7 @@ $NetBSD: patch-ac,v 1.3 2002/10/23 10:04:16 drochner Exp $
rc = 0;
}
}
-@@ -362,7 +444,7 @@
+@@ -362,7 +444,7 @@ int pth_select_ev(int nfd, fd_set *rfds,
return rc;
}
@@ -229,7 +229,7 @@ $NetBSD: patch-ac,v 1.3 2002/10/23 10:04:16 drochner Exp $
int pth_poll(struct pollfd *pfd, nfds_t nfd, int timeout)
{
return pth_poll_ev(pfd, nfd, timeout, NULL);
-@@ -373,7 +455,7 @@
+@@ -373,7 +455,7 @@ int pth_poll(struct pollfd *pfd, nfds_t
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.3 2002/10/23 10:04:16 drochner Exp $
struct timeval tv, *ptv;
int maxfd, rc, ok;
unsigned int i;
-@@ -410,58 +492,64 @@
+@@ -410,58 +492,64 @@ int pth_poll_ev(struct pollfd *pfd, nfds
FD_ZERO(&rfds);
FD_ZERO(&wfds);
FD_ZERO(&efds);
@@ -348,7 +348,17 @@ $NetBSD: patch-ac,v 1.3 2002/10/23 10:04:16 drochner Exp $
}
return rc;
}
-@@ -498,6 +586,13 @@
+@@ -485,7 +573,8 @@ int pth_connect_ev(int s, const struct s
+ pth_debug2("pth_connect_ev: enter from thread \"%s\"", pth_current->name);
+
+ /* force filedescriptor into non-blocking mode */
+- fdmode = pth_fdmode(s, PTH_FDMODE_NONBLOCK);
++ if ((fdmode = pth_fdmode(s, PTH_FDMODE_NONBLOCK)) == PTH_FDMODE_ERROR)
++ return_errno(-1, EBADF);
+
+ /* try to connect */
+ while ( (rv = pth_sc(connect)(s, (struct sockaddr *)addr, addrlen)) == -1
+@@ -498,6 +587,13 @@ int pth_connect_ev(int s, const struct s
/* 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);
@@ -362,3 +372,109 @@ $NetBSD: patch-ac,v 1.3 2002/10/23 10:04:16 drochner Exp $
if (ev_extra != NULL)
pth_event_concat(ev, ev_extra, NULL);
pth_wait(ev);
+@@ -536,7 +632,8 @@ int pth_accept_ev(int s, struct sockaddr
+ pth_debug2("pth_accept_ev: enter from thread \"%s\"", pth_current->name);
+
+ /* force filedescriptor into non-blocking mode */
+- fdmode = pth_fdmode(s, PTH_FDMODE_NONBLOCK);
++ if ((fdmode = pth_fdmode(s, PTH_FDMODE_NONBLOCK)) == PTH_FDMODE_ERROR)
++ return_errno(-1, EBADF);
+
+ /* poll socket via accept */
+ ev = NULL;
+@@ -585,6 +682,7 @@ ssize_t pth_read_ev(int fd, void *buf, s
+ pth_event_t ev;
+ static pth_key_t ev_key = PTH_KEY_INIT;
+ fd_set fds;
++ int fdmode;
+ int n;
+
+ pth_implicit_init();
+@@ -594,8 +692,12 @@ ssize_t pth_read_ev(int fd, void *buf, s
+ if (nbytes == 0)
+ return 0;
+
++ /* check mode of filedescriptor */
++ if ((fdmode = pth_fdmode(fd, PTH_FDMODE_POLL)) == PTH_FDMODE_ERROR)
++ return_errno(-1, EBADF);
++
+ /* poll filedescriptor if not already in non-blocking operation */
+- if (pth_fdmode(fd, PTH_FDMODE_POLL) == PTH_FDMODE_BLOCK) {
++ if (fdmode == PTH_FDMODE_BLOCK) {
+
+ /* now directly poll filedescriptor for readability
+ to avoid unneccessary (and resource consuming because of context
+@@ -662,7 +764,8 @@ ssize_t pth_write_ev(int fd, const void
+ return 0;
+
+ /* force filedescriptor into non-blocking mode */
+- fdmode = pth_fdmode(fd, PTH_FDMODE_NONBLOCK);
++ if ((fdmode = pth_fdmode(fd, PTH_FDMODE_NONBLOCK)) == PTH_FDMODE_ERROR)
++ return_errno(-1, EBADF);
+
+ /* poll filedescriptor if not already in non-blocking operation */
+ if (fdmode != PTH_FDMODE_NONBLOCK) {
+@@ -749,6 +852,7 @@ ssize_t pth_readv_ev(int fd, const struc
+ pth_event_t ev;
+ static pth_key_t ev_key = PTH_KEY_INIT;
+ fd_set fds;
++ int fdmode;
+ int n;
+
+ pth_implicit_init();
+@@ -758,8 +862,12 @@ ssize_t pth_readv_ev(int fd, const struc
+ if (iovcnt <= 0 || iovcnt > UIO_MAXIOV)
+ return_errno(-1, EINVAL);
+
++ /* check mode of filedescriptor */
++ if ((fdmode = pth_fdmode(fd, PTH_FDMODE_POLL)) == PTH_FDMODE_ERROR)
++ return_errno(-1, EBADF);
++
+ /* poll filedescriptor if not already in non-blocking operation */
+- if (pth_fdmode(fd, PTH_FDMODE_POLL) == PTH_FDMODE_BLOCK) {
++ if (fdmode == PTH_FDMODE_BLOCK) {
+
+ /* first directly poll filedescriptor for readability
+ to avoid unneccessary (and resource consuming because of context
+@@ -881,7 +989,8 @@ ssize_t pth_writev_ev(int fd, const stru
+ return_errno(-1, EINVAL);
+
+ /* force filedescriptor into non-blocking mode */
+- fdmode = pth_fdmode(fd, PTH_FDMODE_NONBLOCK);
++ if ((fdmode = pth_fdmode(fd, PTH_FDMODE_NONBLOCK)) == PTH_FDMODE_ERROR)
++ return_errno(-1, EBADF);
+
+ /* poll filedescriptor if not already in non-blocking operation */
+ if (fdmode != PTH_FDMODE_NONBLOCK) {
+@@ -1176,6 +1285,7 @@ ssize_t pth_recvfrom_ev(int fd, void *bu
+ pth_event_t ev;
+ static pth_key_t ev_key = PTH_KEY_INIT;
+ fd_set fds;
++ int fdmode;
+ int n;
+
+ pth_implicit_init();
+@@ -1185,8 +1295,12 @@ ssize_t pth_recvfrom_ev(int fd, void *bu
+ if (nbytes == 0)
+ return 0;
+
++ /* check mode of filedescriptor */
++ if ((fdmode = pth_fdmode(fd, PTH_FDMODE_POLL)) == PTH_FDMODE_ERROR)
++ return_errno(-1, EBADF);
++
+ /* poll filedescriptor if not already in non-blocking operation */
+- if (pth_fdmode(fd, PTH_FDMODE_POLL) == PTH_FDMODE_BLOCK) {
++ if (fdmode == PTH_FDMODE_BLOCK) {
+
+ /* now directly poll filedescriptor for readability
+ to avoid unneccessary (and resource consuming because of context
+@@ -1265,7 +1379,8 @@ ssize_t pth_sendto_ev(int fd, const void
+ return 0;
+
+ /* force filedescriptor into non-blocking mode */
+- fdmode = pth_fdmode(fd, PTH_FDMODE_NONBLOCK);
++ if ((fdmode = pth_fdmode(fd, PTH_FDMODE_NONBLOCK)) == PTH_FDMODE_ERROR)
++ return_errno(-1, EBADF);
+
+ /* poll filedescriptor if not already in non-blocking operation */
+ if (fdmode != PTH_FDMODE_NONBLOCK) {
diff --git a/devel/pth/patches/patch-ag b/devel/pth/patches/patch-ag
index 8decaa4a498..6ce1e665125 100644
--- a/devel/pth/patches/patch-ag
+++ b/devel/pth/patches/patch-ag
@@ -1,8 +1,8 @@
-$NetBSD: patch-ag,v 1.3 2002/10/14 11:49:56 skrll Exp $
+$NetBSD: patch-ag,v 1.4 2002/11/26 21:42:49 skrll Exp $
--- pth_lib.c.orig Sun Jan 27 11:03:40 2002
+++ pth_lib.c
-@@ -37,25 +37,21 @@ long pth_version(void)
+@@ -37,28 +37,25 @@ long pth_version(void)
/* implicit initialization support */
intern int pth_initialized = FALSE;
@@ -33,8 +33,13 @@ $NetBSD: patch-ag,v 1.3 2002/10/14 11:49:56 skrll Exp $
+ pth_debug1("pth__init: enter");
/* initialize the scheduler */
- pth_scheduler_init();
-@@ -105,10 +101,29 @@ int pth_init(void)
+- pth_scheduler_init();
++ if (!pth_scheduler_init())
++ return_errno(FALSE, EAGAIN);
+
+ /* spawn the scheduler thread */
+ t_attr = pth_attr_new();
+@@ -105,10 +102,29 @@ int pth_init(void)
pth_mctx_switch(&pth_main->mctx, &pth_sched->mctx);
/* came back, so let's go home... */
@@ -65,7 +70,7 @@ $NetBSD: patch-ag,v 1.3 2002/10/14 11:49:56 skrll Exp $
/* kill the package internals */
int pth_kill(void)
{
-@@ -118,6 +133,7 @@ int pth_kill(void)
+@@ -118,6 +134,7 @@ int pth_kill(void)
pth_thread_cleanup(pth_main);
pth_scheduler_kill();
pth_initialized = FALSE;
@@ -73,7 +78,7 @@ $NetBSD: patch-ag,v 1.3 2002/10/14 11:49:56 skrll Exp $
pth_tcb_free(pth_sched);
pth_tcb_free(pth_main);
pth_debug1("pth_kill: leave");
-@@ -182,6 +198,7 @@ static void pth_spawn_trampoline(void)
+@@ -182,6 +199,7 @@ static void pth_spawn_trampoline(void)
/* no return! */
abort();
}
diff --git a/devel/pth/patches/patch-ak b/devel/pth/patches/patch-ak
new file mode 100644
index 00000000000..732253e95c7
--- /dev/null
+++ b/devel/pth/patches/patch-ak
@@ -0,0 +1,38 @@
+$NetBSD: patch-ak,v 1.1 2002/11/26 21:42:49 skrll Exp $
+
+--- pth_sched.c.orig Sun Jan 27 11:03:41 2002
++++ pth_sched.c
+@@ -47,16 +47,15 @@ static pth_time_t pth_loadticknext;
+ static pth_time_t pth_loadtickgap = PTH_TIME(1,0);
+
+ /* initialize the scheduler ingredients */
+-intern void pth_scheduler_init(void)
++intern int pth_scheduler_init(void)
+ {
+ /* create the internal signal pipe */
+- if (pipe(pth_sigpipe) == -1) {
+- fprintf(stderr, "**Pth** INIT: Cannot create internal pipe: %s\n",
+- strerror(errno));
+- abort();
+- }
+- pth_fdmode(pth_sigpipe[0], PTH_FDMODE_NONBLOCK);
+- pth_fdmode(pth_sigpipe[1], PTH_FDMODE_NONBLOCK);
++ if (pipe(pth_sigpipe) == -1)
++ return_errno(FALSE, errno);
++ if (pth_fdmode(pth_sigpipe[0], PTH_FDMODE_NONBLOCK) == PTH_FDMODE_ERROR)
++ return_errno(FALSE, errno);
++ if (pth_fdmode(pth_sigpipe[1], PTH_FDMODE_NONBLOCK) == PTH_FDMODE_ERROR)
++ return_errno(FALSE, errno);
+
+ /* initialize the essential threads */
+ pth_sched = NULL;
+@@ -72,7 +71,8 @@ intern void pth_scheduler_init(void)
+ /* initialize load support */
+ pth_loadval = 1.0;
+ pth_time_set(&pth_loadticknext, PTH_TIME_NOW);
+- return;
++
++ return TRUE;
+ }
+
+ /* drop all threads (except for the currently active one) */