You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2010/11/17 22:13:34 UTC
svn commit: r1036228 - in /trafficserver/traffic/trunk/iocore:
eventsystem/P_IOBuffer.h net/SSLNetVConnection.cc
Author: zwoop
Date: Wed Nov 17 21:13:33 2010
New Revision: 1036228
URL: http://svn.apache.org/viewvc?rev=1036228&view=rev
Log:
TS-540 Fixes for SSL and chunked responses
I believe this fixes at least the problems I could reproduce
related to SSL and chunked responses.
Modified:
trafficserver/traffic/trunk/iocore/eventsystem/P_IOBuffer.h
trafficserver/traffic/trunk/iocore/net/SSLNetVConnection.cc
Modified: trafficserver/traffic/trunk/iocore/eventsystem/P_IOBuffer.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/iocore/eventsystem/P_IOBuffer.h?rev=1036228&r1=1036227&r2=1036228&view=diff
==============================================================================
--- trafficserver/traffic/trunk/iocore/eventsystem/P_IOBuffer.h (original)
+++ trafficserver/traffic/trunk/iocore/eventsystem/P_IOBuffer.h Wed Nov 17 21:13:33 2010
@@ -27,6 +27,9 @@
#define _P_IOBuffer_h
#include "inktomi++.h"
+// TODO: I think we're overly aggressive here on making MIOBuffer 64-bit
+// but not sure it's worthwhile changing anything to 32-bit honestly.
+
//////////////////////////////////////////////////////////////
//
// returns 0 for DEFAULT_BUFFER_BASE_SIZE,
Modified: trafficserver/traffic/trunk/iocore/net/SSLNetVConnection.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/iocore/net/SSLNetVConnection.cc?rev=1036228&r1=1036227&r2=1036228&view=diff
==============================================================================
--- trafficserver/traffic/trunk/iocore/net/SSLNetVConnection.cc (original)
+++ trafficserver/traffic/trunk/iocore/net/SSLNetVConnection.cc Wed Nov 17 21:13:33 2010
@@ -53,12 +53,13 @@ do_SSL_write(SSL * ssl, void *buf, int s
else
r = -errno;
} while (r == -EINTR || r == -ENOBUFS || r == -ENOMEM);
+
return r;
}
static int
-ssl_read_from_net(NetHandler * nh, UnixNetVConnection * vc, EThread * lthread, int &ret)
+ssl_read_from_net(NetHandler * nh, UnixNetVConnection * vc, EThread * lthread, int64 &ret)
{
NOWARN_UNUSED(nh);
NetState *s = &vc->read;
@@ -66,8 +67,8 @@ ssl_read_from_net(NetHandler * nh, UnixN
MIOBufferAccessor & buf = s->vio.buffer;
IOBufferBlock *b = buf.mbuf->_writer;
int event = SSL_READ_ERROR_NONE;
- int bytes_read;
- int block_write_avail;
+ int64 bytes_read;
+ int64 block_write_avail;
int sslErr = SSL_ERROR_NONE;
for (bytes_read = 0; (b != 0) && (sslErr == SSL_ERROR_NONE); b = b->next) {
@@ -75,11 +76,11 @@ ssl_read_from_net(NetHandler * nh, UnixN
Debug("ssl", "[SSL_NetVConnection::ssl_read_from_net] b->write_avail()=%d", block_write_avail);
- int offset = 0;
+ int64 offset = 0;
// while can be replaced with if - need to test what works faster with openssl
while (block_write_avail > 0) {
sslvc->read_calls++;
- int rres = SSL_read(sslvc->ssl, b->end() + offset, block_write_avail);
+ int rres = SSL_read(sslvc->ssl, b->end() + offset, (int)block_write_avail);
Debug("ssl", "[SSL_NetVConnection::ssl_read_from_net] rres=%d", rres);
@@ -164,8 +165,8 @@ void
SSLNetVConnection::net_read_io(NetHandler * nh, EThread * lthread)
{
int ret;
- int r = 0;
- int bytes = 0;
+ int64 r = 0;
+ int64 bytes = 0;
NetState *s = &this->read;
MIOBufferAccessor & buf = s->vio.buffer;
MUTEX_TRY_LOCK_FOR(lock, s->vio.mutex, lthread, s->vio._cont);
@@ -186,6 +187,7 @@ SSLNetVConnection::net_read_io(NetHandle
// vc is an SSLNetVConnection.
if (!getSSLHandShakeComplete()) {
int err;
+
if (getSSLClientConnection()) {
ret = sslStartHandShake(SSL_EVENT_CLIENT, err);
} else {
@@ -210,7 +212,7 @@ SSLNetVConnection::net_read_io(NetHandle
return;
}
// If there is nothing to do, disable connection
- int ntodo = s->vio.ntodo();
+ int64 ntodo = s->vio.ntodo();
if (ntodo <= 0) {
read_disable(nh, this);
return;
@@ -281,11 +283,12 @@ SSLNetVConnection::net_read_io(NetHandle
}
-int64 SSLNetVConnection::load_buffer_and_write(int64 towrite, int64 &wattempted, int64 &total_wrote, MIOBufferAccessor & buf) {
+int64
+SSLNetVConnection::load_buffer_and_write(int64 towrite, int64 &wattempted, int64 &total_wrote, MIOBufferAccessor & buf) {
ProxyMutex *mutex = this_ethread()->mutex;
- int r = 0;
+ int64 r = 0;
int64 l = 0;
- int offset = buf.entry->start_offset;
+ int64 offset = buf.entry->start_offset;
IOBufferBlock *b = buf.entry->block;
do {
@@ -299,6 +302,7 @@ int64 SSLNetVConnection::load_buffer_and
}
// check if to amount to write exceeds that in this buffer
int64 wavail = towrite - total_wrote;
+
if (l > wavail)
l = wavail;
if (!l)
@@ -308,7 +312,7 @@ int64 SSLNetVConnection::load_buffer_and
Debug("ssl", "SSLNetVConnection::loadBufferAndCallWrite, before do_SSL_write, l = %d, towrite = %d, b = %x", l,
towrite, b);
write_calls++;
- r = do_SSL_write(ssl, b->start() + offset, l);
+ r = do_SSL_write(ssl, b->start() + offset, (int)l);
if (r == l) {
wattempted = total_wrote;
}
@@ -328,6 +332,7 @@ int64 SSLNetVConnection::load_buffer_and
}
} else {
int err = SSL_get_error(ssl, r);
+
switch (err) {
case SSL_ERROR_NONE:
Debug("ssl", "SSL_write-SSL_ERROR_NONE");
@@ -482,8 +487,8 @@ SSLNetVConnection::sslStartHandShake(int
int
SSLNetVConnection::sslServerHandShakeEvent(int &err)
{
-
int ret;
+
accept_calls++;
//printf("calling SSL_accept for fd %d\n",con.fd);
ret = SSL_accept(ssl);
@@ -551,6 +556,7 @@ int
SSLNetVConnection::sslClientHandShakeEvent(int &err)
{
int ret;
+
connect_calls++;
//printf("calling connect for fd %d\n",con.fd);
ret = SSL_connect(ssl);