summaryrefslogtreecommitdiff
path: root/src/modules/extra/m_ssl_openssl.cpp
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/extra/m_ssl_openssl.cpp
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/extra/m_ssl_openssl.cpp')
-rw-r--r--src/modules/extra/m_ssl_openssl.cpp16
1 files changed, 10 insertions, 6 deletions
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];