/[LeafOK_CVS]/pvpgn-1.7.4/src/common/rlimit.c
ViewVC logotype

Annotation of /pvpgn-1.7.4/src/common/rlimit.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1.1.1 - (hide annotations) (vendor branch)
Tue Jun 6 03:41:38 2006 UTC (19 years, 9 months ago) by sysadm
Branch: GNU, MAIN
CVS Tags: arelease, HEAD
Changes since 1.1: +0 -0 lines
Content type: text/x-csrc
no message

1 sysadm 1.1 /*
2     * This program is free software; you can redistribute it and/or
3     * modify it under the terms of the GNU General Public License
4     * as published by the Free Software Foundation; either version 2
5     * of the License, or (at your option) any later version.
6     *
7     * This program is distributed in the hope that it will be useful,
8     * but WITHOUT ANY WARRANTY; without even the implied warranty of
9     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10     * GNU General Public License for more details.
11     *
12     * You should have received a copy of the GNU General Public License
13     * along with this program; if not, write to the Free Software
14     * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
15     */
16    
17     #include "common/setup_before.h"
18     #include <stdio.h>
19     #ifdef HAVE_UNISTD_H
20     # include <unistd.h>
21     #endif
22     #include <errno.h>
23     #include "compat/strerror.h"
24     #ifdef TIME_WITH_SYS_TIME
25     # include <sys/time.h>
26     # include <time.h>
27     #else
28     # ifdef HAVE_SYS_TIME_H
29     # include <sys/time.h>
30     # else
31     # include <time.h>
32     # endif
33     #endif
34     #ifdef HAVE_STRING_H
35     # include <string.h>
36     #endif
37     #ifdef HAVE_SYS_RESOURCE_H
38     # include <sys/resource.h>
39     #endif
40     #include "common/eventlog.h"
41     #include "common/bn_type.h"
42     #include "common/setup_after.h"
43    
44    
45     /* file descriptor limit has different name on BSD and Linux */
46     #ifdef RLIMIT_NOFILE
47     # define RLIM_NUMFILES RLIMIT_NOFILE
48     #else
49     # ifdef RLIMIT_OFILE
50     # define RLIM_NUMFILES RLIMIT_OFILE
51     # endif
52     #endif
53    
54     extern int get_socket_limit(void)
55     {
56     int socklimit = 0;
57     #ifdef HAVE_GETRLIMIT
58     struct rlimit rlim;
59     if(getrlimit(RLIM_NUMFILES, &rlim) < 0)
60     eventlog(eventlog_level_error, __FUNCTION__, "getrlimit returned error: %s", pstrerror(errno));
61     socklimit = rlim.rlim_cur;
62     #else
63     /* FIXME: WIN32: somehow get WSAData win32 socket limit here */
64     #endif
65    
66     #if !(defined HAVE_POLL || defined HAVE_KQUEUE || defined HAVE_EPOLL)
67     if(!socklimit || FD_SETSIZE < socklimit)
68     socklimit = FD_SETSIZE;
69     #endif
70    
71     /* make socket limit smaller than file limit to make sure log files,
72     db connections and save files will still work */
73     socklimit -= 64;
74    
75     return socklimit;
76     }

webmaster@leafok.com
ViewVC Help
Powered by ViewVC 1.3.0-beta1