From owner-cvs-usrsbin Wed May 10 16:02:48 1995 Return-Path: cvs-usrsbin-owner Received: (from majordom@localhost) by freefall.cdrom.com (8.6.10/8.6.6) id QAA08456 for cvs-usrsbin-outgoing; Wed, 10 May 1995 16:02:48 -0700 Received: (from wpaul@localhost) by freefall.cdrom.com (8.6.10/8.6.6) id QAA08441 ; Wed, 10 May 1995 16:02:45 -0700 Date: Wed, 10 May 1995 16:02:45 -0700 From: Bill Paul Message-Id: <199505102302.QAA08441@freefall.cdrom.com> To: CVS-commiters, cvs-usrsbin Subject: cvs commit: src/usr.sbin/ypbind ypbind.c Sender: cvs-usrsbin-owner@freebsd.org Precedence: bulk wpaul 95/05/10 16:02:44 Modified: usr.sbin/ypbind ypbind.c Log: Performace improvements/simplifications/cleanups: - Make the child process reaper signal-driven. (Previously, we called reaper() once a second each time we went through the select() loop. This was convenient, but inefficient.) - Increase main select() timeout from 1 second to 60 seconds and use this as the ping timer instead of using timestamps in the _dom_binding structure. This nd the reaper() change noted above makes ypbind a little less CPU-intensive. - Don't flag EINTR's from select() as errors since they will happen as a result of incoming SIGCHLD's interrupting select(). - Prevent possible resource hogging. Currently we malloc() memory each time a user process asks us to establish a binding for a domain, but we never free it. This could lead to serious memory leakage if a 'clever' user did something like ask ypwhich to check the bindings for domains 0.0.0.0.0.0.0.0.0.0 through 9.9.9.9.9.9.9.9.9.9 inclusive. (This would also make a mess out of the /var/yp/binding directory.) We now avoid this silliness by a) limiting the maximum number of simultaneous bindings we can manage to 200, and b) free()ing _dom_binding structures of secondary domains whose servers have stopped responding. We unlink the /var/yp/binding/domain.vers files for the free()ed domains too. (This is safe to do since a client can prod us into reestablishing the binding, at which time we'll simply allocate a new _dom_binding structure for it.) We keep count of the total number of domains. If asked to allocate more than the maximum, we return an error. I have yet to hear of anybody needing 200 simultaneous NIS bindings, so this should be enough. (I chose the number 200 arbitrarily. It can be increased if need be.) - Changed "server not responding"/"server OK" messages to display server IP addresses again since it looks spiffier. - Use daemon() to daemonify ourselves, - Added a SIGTERM handler that removes all binding files and unregisters the ypbind service from the portmapper when a SIGTERM in received. - The comment 'blow away everything in BINDINGDIR' has no associated code. Give it some: clean out /var/yp/binding at startup (if it exists). This completes my ypbind wishlist. Barring bug fixes, I shouldn't need to go poking around in here anymore. (Of course, this means I can start working on my ypserv whishlist now... :)