mirror of
https://github.com/nmap/nmap.git
synced 2026-10-20 19:01:56 +00:00
This commit is contained in:
parent
3421d01d2e
commit
05763b620d
3 changed files with 22 additions and 12 deletions
|
|
@ -93,13 +93,14 @@ static int netutils_debugging = 0;
|
|||
* process and return that maximum value (note -- you better not actually open
|
||||
* this many -- stdin, stdout, other files opened by libraries you use, etc. all
|
||||
* count toward this limit. Leave a little slack */
|
||||
int maximize_fdlimit(void) {
|
||||
rlim_t maximize_fdlimit(void) {
|
||||
|
||||
#ifndef WIN32
|
||||
struct rlimit r;
|
||||
static int maxfds = -1;
|
||||
static int maxfds_set = 0;
|
||||
static rlim_t maxfds = 0;
|
||||
|
||||
if (maxfds > 0)
|
||||
if (maxfds_set)
|
||||
return maxfds;
|
||||
|
||||
#ifndef RLIMIT_NOFILE
|
||||
|
|
@ -110,17 +111,17 @@ int maximize_fdlimit(void) {
|
|||
#endif
|
||||
#endif
|
||||
if (!getrlimit(RLIMIT_NOFILE, &r)) {
|
||||
maxfds = r.rlim_cur;
|
||||
r.rlim_cur = r.rlim_max;
|
||||
if (setrlimit(RLIMIT_NOFILE, &r))
|
||||
if (!setrlimit(RLIMIT_NOFILE, &r))
|
||||
if (netutils_debugging)
|
||||
perror("setrlimit RLIMIT_NOFILE failed");
|
||||
|
||||
if (!getrlimit(RLIMIT_NOFILE, &r)) {
|
||||
maxfds = r.rlim_cur;
|
||||
return maxfds;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
maxfds_set = 1;
|
||||
return maxfds;
|
||||
}
|
||||
#endif /* !WIN32 */
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -79,11 +79,18 @@
|
|||
#include <sys/un.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_SYS_RESOURCE_H
|
||||
#include <sys/resource.h>
|
||||
#else
|
||||
#ifndef rlim_t
|
||||
#define rlim_t int
|
||||
#endif
|
||||
#endif
|
||||
/* Maximize the number of file descriptors (including sockets) allowed for this
|
||||
* process and return that maximum value (note -- you better not actually open
|
||||
* this many -- stdin, stdout, other files opened by libraries you use, etc. all
|
||||
* count toward this limit. Leave a little slack */
|
||||
int maximize_fdlimit(void);
|
||||
rlim_t maximize_fdlimit(void);
|
||||
|
||||
/* Get the UNIX domain socket path or empty string if the address family != AF_UNIX. */
|
||||
const char *get_unixsock_path(const struct sockaddr_storage *addr);
|
||||
|
|
|
|||
|
|
@ -71,6 +71,9 @@
|
|||
#endif
|
||||
#include <signal.h>
|
||||
|
||||
#if HAVE_SYS_RESOURCE_H
|
||||
#include <sys/resource.h>
|
||||
#endif
|
||||
|
||||
extern struct timeval nsock_tod;
|
||||
|
||||
|
|
@ -294,17 +297,16 @@ void nsock_pool_delete(nsock_pool ms_pool) {
|
|||
}
|
||||
|
||||
void nsock_library_initialize(void) {
|
||||
int res;
|
||||
#ifndef WIN32
|
||||
rlim_t res;
|
||||
|
||||
/* We want to make darn sure the evil SIGPIPE is ignored */
|
||||
#ifndef WIN32
|
||||
signal(SIGPIPE, SIG_IGN);
|
||||
#endif
|
||||
|
||||
/* And we're gonna need sockets -- LOTS of sockets ... */
|
||||
res = maximize_fdlimit();
|
||||
#ifndef WIN32
|
||||
assert(res > 7);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue