From 3cd839708562f9313a91a012d26465380793dcbc Mon Sep 17 00:00:00 2001 From: ehouse Date: Fri, 2 Sep 2005 07:18:39 +0000 Subject: [PATCH] fix failure to record bytes forwarded --- relay/cref.cpp | 9 +++++---- relay/cref.h | 3 +-- relay/crefmgr.cpp | 5 +++-- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/relay/cref.cpp b/relay/cref.cpp index b54d391d0..3c2ae077e 100644 --- a/relay/cref.cpp +++ b/relay/cref.cpp @@ -402,12 +402,14 @@ CookieRef::handleEvents() } } /* handleEvents */ -static void -send_with_length( int socket, unsigned char* buf, int bufLen ) +void +CookieRef::send_with_length( int socket, unsigned char* buf, int bufLen ) { SocketWriteLock slock( socket ); - if ( !send_with_length_unsafe( socket, buf, bufLen ) ) { + if ( send_with_length_unsafe( socket, buf, bufLen ) ) { + RecordSent( bufLen, socket ); + } else { /* ok that the slock above is still in scope */ killSocket( socket, "couldn't send" ); } @@ -466,7 +468,6 @@ CookieRef::sendResponse( const CRefEvent* evt ) putNetLong( &bufp, GetCookieID() ); send_with_length( socket, buf, sizeof(buf) ); - RecordSent( sizeof(buf), socket ); logf( "sent XWRELAY_CONNECTRESP" ); } /* sendResponse */ diff --git a/relay/cref.h b/relay/cref.h index 013ee8274..5ac05a061 100644 --- a/relay/cref.h +++ b/relay/cref.h @@ -123,8 +123,8 @@ class CookieRef { int SocketForHost( HostID dest ); + void send_with_length( int socket, unsigned char* buf, int bufLen ); void RecordSent( int nBytes, int socket ) { - /* This really needs a lock.... */ m_totalSent += nBytes; } @@ -143,7 +143,6 @@ class CookieRef { void pushCanLockEvent( const CRefEvent* evt ); void pushCantLockEvent( const CRefEvent* evt ); - void handleEvents(); void sendResponse( const CRefEvent* evt ); diff --git a/relay/crefmgr.cpp b/relay/crefmgr.cpp index c1843cd07..b999f7daf 100644 --- a/relay/crefmgr.cpp +++ b/relay/crefmgr.cpp @@ -18,12 +18,13 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include +#include + #include "crefmgr.h" #include "cref.h" #include "mlock.h" -#include - class SocketStuff { public: SocketStuff( CookieRef* cref )