summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2008-04-02 17:08:09 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2008-04-02 17:08:09 +0000
commit2db77cda56947d4ee0f913c8082f6607855ca713 (patch)
treef7f83c80f62adc4e3eb0f9f3b680229466c4352e /src/modules
parentd9d33e7246baf59241d083eb2c253e729390d205 (diff)
Automatic detection and allocation of max fds. No longer needs recompile to change, just adjust it in your kernel or whatever and restart insp.
Please note that select and iocp socket engines do not support detection and are always set to FD_SETSIZE and 10240 descriptors respectively. git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@9263 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/extra/m_ssl_gnutls.cpp18
-rw-r--r--src/modules/extra/m_ssl_openssl.cpp16
-rw-r--r--src/modules/extra/m_ziplink.cpp5
3 files changed, 24 insertions, 15 deletions
diff --git a/src/modules/extra/m_ssl_gnutls.cpp b/src/modules/extra/m_ssl_gnutls.cpp
index 3f9c4ac5d..797019fd4 100644
--- a/src/modules/extra/m_ssl_gnutls.cpp
+++ b/src/modules/extra/m_ssl_gnutls.cpp
@@ -28,8 +28,6 @@
#ifdef WINDOWS
#pragma comment(lib, "libgnutls-13.lib")
-#undef MAX_DESCRIPTORS
-#define MAX_DESCRIPTORS 10000
#endif
/* $ModDesc: Provides SSL support for clients */
@@ -94,7 +92,7 @@ class ModuleSSLGnuTLS : public Module
std::vector<std::string> listenports;
int inbufsize;
- issl_session sessions[MAX_DESCRIPTORS];
+ issl_session* sessions;
gnutls_certificate_credentials x509_cred;
gnutls_dh_params dh_params;
@@ -117,6 +115,8 @@ class ModuleSSLGnuTLS : public Module
{
ServerInstance->Modules->PublishInterface("BufferedSocketHook", this);
+ sessions = new issl_session[ServerInstance->SE->GetMaxFds()];
+
// Not rehashable...because I cba to reduce all the sizes of existing buffers.
inbufsize = ServerInstance->Config->NetBufferSize;
@@ -270,6 +270,8 @@ class ModuleSSLGnuTLS : public Module
gnutls_dh_params_deinit(dh_params);
gnutls_certificate_free_credentials(x509_cred);
gnutls_global_deinit();
+ ServerInstance->Modules->UnpublishInterface("BufferedSocketHook", this);
+ delete[] sessions;
}
virtual void OnCleanup(int target_type, void* item)
@@ -383,7 +385,7 @@ class ModuleSSLGnuTLS : public Module
virtual void OnRawSocketAccept(int fd, const std::string &ip, int localport)
{
/* Are there any possibilities of an out of range fd? Hope not, but lets be paranoid */
- if ((fd < 0) || (fd > MAX_DESCRIPTORS))
+ if ((fd < 0) || (fd > ServerInstance->SE->GetMaxFds() - 1))
return;
issl_session* session = &sessions[fd];
@@ -416,7 +418,7 @@ class ModuleSSLGnuTLS : public Module
virtual void OnRawSocketConnect(int fd)
{
/* Are there any possibilities of an out of range fd? Hope not, but lets be paranoid */
- if ((fd < 0) || (fd > MAX_DESCRIPTORS))
+ if ((fd < 0) || (fd > ServerInstance->SE->GetMaxFds() - 1))
return;
issl_session* session = &sessions[fd];
@@ -438,7 +440,7 @@ class ModuleSSLGnuTLS : public Module
virtual void OnRawSocketClose(int fd)
{
/* Are there any possibilities of an out of range fd? Hope not, but lets be paranoid */
- if ((fd < 0) || (fd > MAX_DESCRIPTORS))
+ if ((fd < 0) || (fd > ServerInstance->SE->GetMaxFds()))
return;
CloseSession(&sessions[fd]);
@@ -457,7 +459,7 @@ class ModuleSSLGnuTLS : public Module
virtual int OnRawSocketRead(int fd, char* buffer, unsigned int count, int &readresult)
{
/* Are there any possibilities of an out of range fd? Hope not, but lets be paranoid */
- if ((fd < 0) || (fd > MAX_DESCRIPTORS))
+ if ((fd < 0) || (fd > ServerInstance->SE->GetMaxFds() - 1))
return 0;
issl_session* session = &sessions[fd];
@@ -552,7 +554,7 @@ class ModuleSSLGnuTLS : public Module
virtual int OnRawSocketWrite(int fd, const char* buffer, int count)
{
/* Are there any possibilities of an out of range fd? Hope not, but lets be paranoid */
- if ((fd < 0) || (fd > MAX_DESCRIPTORS))
+ if ((fd < 0) || (fd > ServerInstance->SE->GetMaxFds() - 1))
return 0;
issl_session* session = &sessions[fd];
diff --git a/src/modules/extra/m_ssl_openssl.cpp b/src/modules/extra/m_ssl_openssl.cpp
index de7101db1..83fa94e96 100644
--- a/src/modules/extra/m_ssl_openssl.cpp
+++ b/src/modules/extra/m_ssl_openssl.cpp
@@ -107,7 +107,7 @@ class ModuleSSLOpenSSL : public Module
std::vector<std::string> listenports;
int inbufsize;
- issl_session sessions[MAX_DESCRIPTORS];
+ issl_session* sessions;
SSL_CTX* ctx;
SSL_CTX* clictx;
@@ -133,6 +133,8 @@ class ModuleSSLOpenSSL : public Module
{
ServerInstance->Modules->PublishInterface("BufferedSocketHook", this);
+ sessions = new issl_session[ServerInstance->SE->GetMaxFds()];
+
// Not rehashable...because I cba to reduce all the sizes of existing buffers.
inbufsize = ServerInstance->Config->NetBufferSize;
@@ -302,6 +304,8 @@ class ModuleSSLOpenSSL : public Module
{
SSL_CTX_free(ctx);
SSL_CTX_free(clictx);
+ ServerInstance->Modules->UnpublishInterface("BufferedSocketHook", this);
+ delete[] sessions;
}
virtual void OnCleanup(int target_type, void* item)
@@ -396,7 +400,7 @@ class ModuleSSLOpenSSL : public Module
virtual void OnRawSocketAccept(int fd, const std::string &ip, int localport)
{
/* Are there any possibilities of an out of range fd? Hope not, but lets be paranoid */
- if ((fd < 0) || (fd > MAX_DESCRIPTORS))
+ if ((fd < 0) || (fd > ServerInstance->SE->GetMaxFds() - 1))
return;
issl_session* session = &sessions[fd];
@@ -423,7 +427,7 @@ class ModuleSSLOpenSSL : public Module
virtual void OnRawSocketConnect(int fd)
{
/* Are there any possibilities of an out of range fd? Hope not, but lets be paranoid */
- if ((fd < 0) || (fd > MAX_DESCRIPTORS))
+ if ((fd < 0) || (fd > ServerInstance->SE->GetMaxFds() -1))
return;
issl_session* session = &sessions[fd];
@@ -450,7 +454,7 @@ class ModuleSSLOpenSSL : public Module
virtual void OnRawSocketClose(int fd)
{
/* Are there any possibilities of an out of range fd? Hope not, but lets be paranoid */
- if ((fd < 0) || (fd > MAX_DESCRIPTORS))
+ if ((fd < 0) || (fd > ServerInstance->SE->GetMaxFds() - 1))
return;
CloseSession(&sessions[fd]);
@@ -469,7 +473,7 @@ class ModuleSSLOpenSSL : public Module
virtual int OnRawSocketRead(int fd, char* buffer, unsigned int count, int &readresult)
{
/* Are there any possibilities of an out of range fd? Hope not, but lets be paranoid */
- if ((fd < 0) || (fd > MAX_DESCRIPTORS))
+ if ((fd < 0) || (fd > ServerInstance->SE->GetMaxFds() - 1))
return 0;
issl_session* session = &sessions[fd];
@@ -546,7 +550,7 @@ class ModuleSSLOpenSSL : public Module
virtual int OnRawSocketWrite(int fd, const char* buffer, int count)
{
/* Are there any possibilities of an out of range fd? Hope not, but lets be paranoid */
- if ((fd < 0) || (fd > MAX_DESCRIPTORS))
+ if ((fd < 0) || (fd > ServerInstance->SE->GetMaxFds() - 1))
return 0;
issl_session* session = &sessions[fd];
diff --git a/src/modules/extra/m_ziplink.cpp b/src/modules/extra/m_ziplink.cpp
index 5202287fa..7b1cb281c 100644
--- a/src/modules/extra/m_ziplink.cpp
+++ b/src/modules/extra/m_ziplink.cpp
@@ -137,7 +137,7 @@ class izip_session : public classbase
class ModuleZLib : public Module
{
- izip_session sessions[MAX_DESCRIPTORS];
+ izip_session* sessions;
/* Used for stats z extensions */
float total_out_compressed;
@@ -152,6 +152,8 @@ class ModuleZLib : public Module
{
ServerInstance->Modules->PublishInterface("BufferedSocketHook", this);
+ sessions = new izip_session[ServerInstance->SE->GetMaxFds()];
+
total_out_compressed = total_in_compressed = 0;
total_out_uncompressed = total_out_uncompressed = 0;
Implementation eventlist[] = { I_OnRawSocketConnect, I_OnRawSocketAccept, I_OnRawSocketClose, I_OnRawSocketRead, I_OnRawSocketWrite, I_OnStats, I_OnRequest };
@@ -161,6 +163,7 @@ class ModuleZLib : public Module
virtual ~ModuleZLib()
{
ServerInstance->Modules->UnpublishInterface("BufferedSocketHook", this);
+ delete[] sessions;
}
virtual Version GetVersion()