fdsetsize.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2017 The Squid Software Foundation and contributors
3  *
4  * Squid software is distributed under GPLv2+ license and includes
5  * contributions from numerous individuals and organizations.
6  * Please see the COPYING and CONTRIBUTORS files for details.
7  */
8 
9 #ifndef SQUID_FDSETSIZE_H
10 #define SQUID_FDSETSIZE_H
11 
12 /****************************************************************************
13  *--------------------------------------------------------------------------*
14  * DO *NOT* MAKE ANY CHANGES below here unless you know what you're doing...*
15  *--------------------------------------------------------------------------*
16  ****************************************************************************/
17 
18 /* FD_SETSIZE must be redefined before including sys/types.h */
19 #if 0
20 /* AYJ: would dearly like to use this to enforce include order
21  but at present some helpers don't follow the squid include methodology.
22  that will need fixing later.
23 */
24 #ifdef _SYS_TYPES_H
25 #error squid_fdsetsize.h for FDSETSIZE must be included before sys/types.h
26 #error Make sure that squid.h is the first file included by your .cc
27 #endif
28 #endif /* 0 */
29 /*
30  * On some systems, FD_SETSIZE is set to something lower than the
31  * actual number of files which can be opened. IRIX is one case,
32  * NetBSD is another. So here we increase FD_SETSIZE to our
33  * configure-discovered maximum *before* any system includes.
34  */
35 #define CHANGE_FD_SETSIZE 1
36 
37 /*
38  * Cannot increase FD_SETSIZE on Linux, but we can increase __FD_SETSIZE
39  * with glibc 2.2 (or later? remains to be seen). We do this by including
40  * bits/types.h which defines __FD_SETSIZE first, then we redefine
41  * __FD_SETSIZE. Ofcourse a user program may NEVER include bits/whatever.h
42  * directly, so this is a dirty hack!
43  */
44 #if _SQUID_LINUX_ || _SQUID_KFREEBSD_
45 #undef CHANGE_FD_SETSIZE
46 #define CHANGE_FD_SETSIZE 0
47 #include <features.h>
48 #if (__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2)
49 #if SQUID_MAXFD > DEFAULT_FD_SETSIZE
50 #include <bits/types.h>
51 #if HAVE_LINUX_POSIX_TYPES_H
52 #include <linux/posix_types.h>
53 #endif
54 #undef __FD_SETSIZE
55 #define __FD_SETSIZE SQUID_MAXFD
56 #endif
57 #endif
58 #endif
59 
60 /*
61  * Cannot increase FD_SETSIZE on FreeBSD before 2.2.0, causes select(2)
62  * to return EINVAL.
63  * --Marian Durkovic <marian@svf.stuba.sk>
64  * --Peter Wemm <peter@spinner.DIALix.COM>
65  */
66 #if _SQUID_FREEBSD_
67 #include <osreldate.h>
68 #if __FreeBSD_version < 220000
69 #undef CHANGE_FD_SETSIZE
70 #define CHANGE_FD_SETSIZE 0
71 #endif
72 #endif
73 
74 /*
75  * Trying to redefine CHANGE_FD_SETSIZE causes a slew of warnings
76  * on Mac OS X Server.
77  */
78 #if _SQUID_APPLE_
79 #undef CHANGE_FD_SETSIZE
80 #define CHANGE_FD_SETSIZE 0
81 #endif
82 
83 /* Increase FD_SETSIZE if SQUID_MAXFD is bigger */
84 #if CHANGE_FD_SETSIZE && SQUID_MAXFD > DEFAULT_FD_SETSIZE
85 #define FD_SETSIZE SQUID_MAXFD
86 #endif
87 
88 /*
89  * Trap unintentional use of fd_set. Must not be used outside the
90  * select code as it only supports FD_SETSIZE number of filedescriptors
91  * and Squid may be running with a lot more..
92  * But only for code linked into Squid, not the helpers.. (unlinkd, pinger)
93  */
94 #ifdef SQUID_FDSET_NOUSE
95 # ifndef SQUID_HELPER
96 # define fd_set ERROR_FD_SET_USED
97 # endif
98 #endif
99 
100 #endif /* SQUID_FDSETSIZE_H */
101 

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors