summaryrefslogtreecommitdiffstats
path: root/usr.sbin/lpr/common_source/lp.cdefs.h
diff options
context:
space:
mode:
authorgad <gad@FreeBSD.org>2013-05-27 22:19:01 +0000
committergad <gad@FreeBSD.org>2013-05-27 22:19:01 +0000
commit92ccb9a78d6194c4e65cdc15633b6750a5fefc67 (patch)
treee548d6fdbfc2fc87d1666b5be84b079204ac1817 /usr.sbin/lpr/common_source/lp.cdefs.h
parentfa9e5ab43dccec826b1477c944db129ef3a76902 (diff)
downloadFreeBSD-src-92ccb9a78d6194c4e65cdc15633b6750a5fefc67.zip
FreeBSD-src-92ccb9a78d6194c4e65cdc15633b6750a5fefc67.tar.gz
Change the closeallfds() routine to use closefrom() when it is
available (closefrom() was added to FreeBSD in 8.0-release). The selection is made at compile-time, as I still compile a FreeBSD-based version of lpr&friends on other platforms. While testing I out that (at least on my system) lpd has been closing 11095 fd's, when there are only 6 fd's open. The old code took 120 times more clocktime than calling closefrom(). (although that was still less than 2/1000-ths of a second!) Reviewed by: jilles MFC after: 2 weeks
Diffstat (limited to 'usr.sbin/lpr/common_source/lp.cdefs.h')
-rw-r--r--usr.sbin/lpr/common_source/lp.cdefs.h17
1 files changed, 16 insertions, 1 deletions
diff --git a/usr.sbin/lpr/common_source/lp.cdefs.h b/usr.sbin/lpr/common_source/lp.cdefs.h
index 19b1331..5806f39 100644
--- a/usr.sbin/lpr/common_source/lp.cdefs.h
+++ b/usr.sbin/lpr/common_source/lp.cdefs.h
@@ -1,6 +1,6 @@
/*-
* ------+---------+---------+---------+---------+---------+---------+---------*
- * Copyright (c) 2003 - Garance Alistair Drosehn <gad@FreeBSD.org>.
+ * Copyright (c) 2003,2013 - Garance Alistair Drosehn <gad@FreeBSD.org>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -56,6 +56,21 @@
#endif
/*
+ * FreeBSD added a closefrom() routine in release 8.0. When compiling
+ * `lpr' on other platforms you might want to include bsd-closefrom.c
+ * from the portable-openssh project.
+ */
+#ifndef USE_CLOSEFROM
+# if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
+# define USE_CLOSEFROM 1
+# endif
+#endif
+/* The macro USE_CLOSEFROM must be defined with a value of 0 or 1. */
+#ifndef USE_CLOSEFROM
+# define USE_CLOSEFROM 0
+#endif
+
+/*
* __unused is a compiler-specific trick which can be used to avoid
* warnings about a variable which is defined but never referenced.
* Some lpr files use this, so define a null version if it was not
OpenPOWER on IntegriCloud