aboutsummaryrefslogtreecommitdiffstats
path: root/src/modules
diff options
context:
space:
mode:
authorGravatar Attila Molnar2015-06-06 14:42:59 +0200
committerGravatar Attila Molnar2015-06-06 14:42:59 +0200
commitd0556a2a598e207ab468b7ea4543e427205ef903 (patch)
treead4bd402d060fdaa384f118891e5da13018afdee /src/modules
parentAdd max outgoing record size option to sslprofile config (diff)
Call OnStreamSocketWrite() once per write event
Do sendq flattening in SSL modules, move code for it into class SSLIOHook from core
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/extra/m_ssl_gnutls.cpp9
-rw-r--r--src/modules/extra/m_ssl_openssl.cpp11
2 files changed, 15 insertions, 5 deletions
diff --git a/src/modules/extra/m_ssl_gnutls.cpp b/src/modules/extra/m_ssl_gnutls.cpp
index f5e52b4e1..935b0ee77 100644
--- a/src/modules/extra/m_ssl_gnutls.cpp
+++ b/src/modules/extra/m_ssl_gnutls.cpp
@@ -987,14 +987,16 @@ info_done_dealloc:
StreamSocket::SendQueue& sendq = user->GetSendQ();
int ret = 0;
+ while (!sendq.empty())
{
+ FlattenSendQueue(sendq, profile->GetOutgoingRecordSize());
const StreamSocket::SendQueue::Element& buffer = sendq.front();
ret = gnutls_record_send(this->sess, buffer.data(), buffer.length());
if (ret == (int)buffer.length())
{
- SocketEngine::ChangeEventMask(user, FD_WANT_NO_WRITE);
- return 1;
+ // Wrote entire record, continue sending
+ sendq.pop_front();
}
else if (ret > 0)
{
@@ -1014,6 +1016,9 @@ info_done_dealloc:
return -1;
}
}
+
+ SocketEngine::ChangeEventMask(user, FD_WANT_NO_WRITE);
+ return 1;
}
void TellCiphersAndFingerprint(LocalUser* user)
diff --git a/src/modules/extra/m_ssl_openssl.cpp b/src/modules/extra/m_ssl_openssl.cpp
index f4a661154..b037347f1 100644
--- a/src/modules/extra/m_ssl_openssl.cpp
+++ b/src/modules/extra/m_ssl_openssl.cpp
@@ -618,8 +618,10 @@ class OpenSSLIOHook : public SSLIOHook
// Session is ready for transferring application data
StreamSocket::SendQueue& sendq = user->GetSendQ();
+ while (!sendq.empty())
{
ERR_clear_error();
+ FlattenSendQueue(sendq, profile->GetOutgoingRecordSize());
const StreamSocket::SendQueue::Element& buffer = sendq.front();
int ret = SSL_write(sess, buffer.data(), buffer.size());
@@ -630,9 +632,8 @@ class OpenSSLIOHook : public SSLIOHook
if (ret == (int)buffer.length())
{
- data_to_write = false;
- SocketEngine::ChangeEventMask(user, FD_WANT_POLL_READ | FD_WANT_NO_WRITE);
- return 1;
+ // Wrote entire record, continue sending
+ sendq.pop_front();
}
else if (ret > 0)
{
@@ -666,6 +667,10 @@ class OpenSSLIOHook : public SSLIOHook
}
}
}
+
+ data_to_write = false;
+ SocketEngine::ChangeEventMask(user, FD_WANT_POLL_READ | FD_WANT_NO_WRITE);
+ return 1;
}
void TellCiphersAndFingerprint(LocalUser* user)