summaryrefslogtreecommitdiffstats
path: root/usr.sbin
diff options
context:
space:
mode:
authorwpaul <wpaul@FreeBSD.org>1999-02-10 16:16:14 +0000
committerwpaul <wpaul@FreeBSD.org>1999-02-10 16:16:14 +0000
commitfdde373153fe0ee29cd1819aa4d38e1b20bb3565 (patch)
treefa910f03011a54963bd70e48fc4f3a86a11038ff /usr.sbin
parent8d9b8047a3f4381cb28d8751cef0c3d36b4db86c (diff)
downloadFreeBSD-src-fdde373153fe0ee29cd1819aa4d38e1b20bb3565.zip
FreeBSD-src-fdde373153fe0ee29cd1819aa4d38e1b20bb3565.tar.gz
Add some tweaks to hopefully fix a problem I've started to notice recently.
Under certain conditions (possibly associated with heavy load), ypserv will fork() child processes that don't exit like they're supposed to. I think this is because of some suspect logic in the ypproc_all procedure. I updated it to use what I hope is a more bulletproof approach. Also tweaked yp_svc_run() a little so that the 'are we a child?' test happens at every pass through the for(;;) loop, not just immediately after returning from svc_getreqset2().
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/ypserv/yp_main.c6
-rw-r--r--usr.sbin/ypserv/yp_server.c24
2 files changed, 20 insertions, 10 deletions
diff --git a/usr.sbin/ypserv/yp_main.c b/usr.sbin/ypserv/yp_main.c
index 59974ad..f20ccb3 100644
--- a/usr.sbin/ypserv/yp_main.c
+++ b/usr.sbin/ypserv/yp_main.c
@@ -32,7 +32,7 @@
#ifndef lint
static const char rcsid[] =
- "$Id: yp_main.c,v 1.17 1998/02/11 19:15:32 wpaul Exp $";
+ "$Id: yp_main.c,v 1.18 1998/06/04 15:11:14 wpaul Exp $";
#endif /* not lint */
/*
@@ -143,9 +143,9 @@ yp_svc_run()
FD_CLR(resfd, &readfds);
}
svc_getreqset(&readfds);
- if (forked && pid != getpid())
- exit(0);
}
+ if (forked && pid != getpid())
+ _exit(0);
}
}
diff --git a/usr.sbin/ypserv/yp_server.c b/usr.sbin/ypserv/yp_server.c
index 3b645a8..76cb5ea 100644
--- a/usr.sbin/ypserv/yp_server.c
+++ b/usr.sbin/ypserv/yp_server.c
@@ -33,7 +33,7 @@
#ifndef lint
static const char rcsid[] =
- "$Id: yp_server.c,v 1.1 1997/11/09 20:54:38 wpaul Exp wpaul $";
+ "$Id: yp_server.c,v 1.26 1998/02/11 19:15:32 wpaul Exp $";
#endif /* not lint */
#include "yp.h"
@@ -506,12 +506,22 @@ ypproc_all_2_svc(ypreq_nokey *argp, struct svc_req *rqstp)
* block. (Is there a better way to do this? Maybe with
* async socket I/O?)
*/
- if (!debug && children < MAX_CHILDREN && fork()) {
- children++;
- forked = 0;
- return (NULL);
- } else {
- forked++;
+ if (!debug) {
+ switch(fork()) {
+ case 0:
+ forked++;
+ break;
+ case -1:
+ yp_error("ypall fork(): %s", strerror(errno));
+ result.ypresp_all_u.val.stat = YP_YPERR;
+ return(&result);
+ break;
+ default:
+ children++;
+ forked = 0;
+ return (NULL);
+ break;
+ }
}
if (yp_select_map(argp->map, argp->domain,
OpenPOWER on IntegriCloud