Added call functionality to figure out the maximum number of sockets (file descriptors) available on system.
This commit is contained in:
parent
077bffd74f
commit
4931dc5dcb
@ -61,6 +61,21 @@ int net_initialize()
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t net_get_max_sockets()
|
||||||
|
{
|
||||||
|
#ifdef HAVE_GETRLIMIT
|
||||||
|
struct rlimit limits;
|
||||||
|
if (getrlimit(RLIMIT_NOFILE, &limits) == 0)
|
||||||
|
{
|
||||||
|
return limits.rlim_max;
|
||||||
|
}
|
||||||
|
LOG_ERROR("getrlimit() failed");
|
||||||
|
#else
|
||||||
|
LOG_ERROR("System does not have getrlimit(): constrained to 1024 sockets");
|
||||||
|
#endif /* HAVE_GETRLIMIT */
|
||||||
|
return 1024;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int net_destroy()
|
int net_destroy()
|
||||||
{
|
{
|
||||||
|
@ -87,6 +87,11 @@ extern const char* net_error_string(int code);
|
|||||||
*/
|
*/
|
||||||
extern int net_socket_create(int af, int type, int protocol);
|
extern int net_socket_create(int af, int type, int protocol);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the maximum number of file/socket descriptors.
|
||||||
|
*/
|
||||||
|
extern size_t net_get_max_sockets();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A wrapper for the close() function call.
|
* A wrapper for the close() function call.
|
||||||
*/
|
*/
|
||||||
|
@ -83,8 +83,10 @@
|
|||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
#include <grp.h>
|
#include <grp.h>
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
|
#include <sys/resource.h>
|
||||||
#define HAVE_STRNDUP
|
#define HAVE_STRNDUP
|
||||||
#define HAVE_MEMMEM
|
#define HAVE_MEMMEM
|
||||||
|
#define HAVE_GETRLIMIT
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef SSL_SUPPORT
|
#ifdef SSL_SUPPORT
|
||||||
|
Loading…
Reference in New Issue
Block a user