diff options
author | Attila Molnar <attilamolnar@hush.com> | 2015-06-06 14:31:05 +0200 |
---|---|---|
committer | Attila Molnar <attilamolnar@hush.com> | 2015-06-06 14:31:05 +0200 |
commit | 1f0485039a276ad1c2fa3d53d284e3a87940ec77 (patch) | |
tree | 5689bf7bbcd023956ab67d4730428b1c746decce /src/modules | |
parent | 0858cdd53cd1ec01c4539e9c36ef7dd9fab4aa16 (diff) |
Convert all code to use StreamSocket::SendQueue
Let OnStreamSocketWrite see the entire sendq instead of one element at a time
Diffstat (limited to 'src/modules')
-rw-r--r-- | src/modules/extra/m_ssl_gnutls.cpp | 10 | ||||
-rw-r--r-- | src/modules/extra/m_ssl_openssl.cpp | 6 |
2 files changed, 10 insertions, 6 deletions
diff --git a/src/modules/extra/m_ssl_gnutls.cpp b/src/modules/extra/m_ssl_gnutls.cpp index d33403aba..e142ead11 100644 --- a/src/modules/extra/m_ssl_gnutls.cpp +++ b/src/modules/extra/m_ssl_gnutls.cpp @@ -968,7 +968,7 @@ info_done_dealloc: } } - int OnStreamSocketWrite(StreamSocket* user, std::string& sendq) CXX11_OVERRIDE + int OnStreamSocketWrite(StreamSocket* user) CXX11_OVERRIDE { // Finish handshake if needed int prepret = PrepareIO(user); @@ -976,19 +976,21 @@ info_done_dealloc: return prepret; // Session is ready for transferring application data + StreamSocket::SendQueue& sendq = user->GetSendQ(); int ret = 0; { - ret = gnutls_record_send(this->sess, sendq.data(), sendq.length()); + const StreamSocket::SendQueue::Element& buffer = sendq.front(); + ret = gnutls_record_send(this->sess, buffer.data(), buffer.length()); - if (ret == (int)sendq.length()) + if (ret == (int)buffer.length()) { SocketEngine::ChangeEventMask(user, FD_WANT_NO_WRITE); return 1; } else if (ret > 0) { - sendq.erase(0, ret); + sendq.erase_front(ret); SocketEngine::ChangeEventMask(user, FD_WANT_SINGLE_WRITE); return 0; } diff --git a/src/modules/extra/m_ssl_openssl.cpp b/src/modules/extra/m_ssl_openssl.cpp index c8a035fac..c2a71eeca 100644 --- a/src/modules/extra/m_ssl_openssl.cpp +++ b/src/modules/extra/m_ssl_openssl.cpp @@ -601,7 +601,7 @@ class OpenSSLIOHook : public SSLIOHook } } - int OnStreamSocketWrite(StreamSocket* user, std::string& buffer) CXX11_OVERRIDE + int OnStreamSocketWrite(StreamSocket* user) CXX11_OVERRIDE { // Finish handshake if needed int prepret = PrepareIO(user); @@ -611,8 +611,10 @@ class OpenSSLIOHook : public SSLIOHook data_to_write = true; // Session is ready for transferring application data + StreamSocket::SendQueue& sendq = user->GetSendQ(); { ERR_clear_error(); + const StreamSocket::SendQueue::Element& buffer = sendq.front(); int ret = SSL_write(sess, buffer.data(), buffer.size()); #ifdef INSPIRCD_OPENSSL_ENABLE_RENEGO_DETECTION @@ -628,7 +630,7 @@ class OpenSSLIOHook : public SSLIOHook } else if (ret > 0) { - buffer.erase(0, ret); + sendq.erase_front(ret); SocketEngine::ChangeEventMask(user, FD_WANT_SINGLE_WRITE); return 0; } |