Remember that socket optimization? This is what I meant to commit, then. Move along, nothing to see here.

This commit is contained in:
Thulinma 2013-10-24 10:49:12 +02:00
parent a7fa0eedcb
commit e61eba35da

View file

@ -403,12 +403,9 @@ std::string Socket::Connection::getStats(std::string C){
/// Updates the downbuffer and upbuffer internal variables. /// Updates the downbuffer and upbuffer internal variables.
/// Returns true if new data was received, false otherwise. /// Returns true if new data was received, false otherwise.
bool Socket::Connection::spool(){ bool Socket::Connection::spool(){
bool bing = isBlocking();
if (!bing){setBlocking(true);}
if (upbuffer.size() > 0){ if (upbuffer.size() > 0){
iwrite(upbuffer.get()); iwrite(upbuffer.get());
} }
if (!bing){setBlocking(false);}
/// \todo Provide better mechanism to prevent overbuffering. /// \todo Provide better mechanism to prevent overbuffering.
if (downbuffer.size() > 10000){ if (downbuffer.size() > 10000){
return true; return true;
@ -443,6 +440,8 @@ Socket::Buffer & Socket::Connection::Received(){
/// This will send the upbuffer (if non-empty) first, then the data. /// This will send the upbuffer (if non-empty) first, then the data.
/// Any data that could not be send will block until it can be send or the connection is severed. /// Any data that could not be send will block until it can be send or the connection is severed.
void Socket::Connection::SendNow(const char * data, size_t len){ void Socket::Connection::SendNow(const char * data, size_t len){
bool bing = isBlocking();
if (!bing){setBlocking(true);}
while (upbuffer.size() > 0 && connected()){ while (upbuffer.size() > 0 && connected()){
iwrite(upbuffer.get()); iwrite(upbuffer.get());
} }
@ -453,6 +452,7 @@ void Socket::Connection::SendNow(const char * data, size_t len){
i += j; i += j;
} }
} }
if (!bing){setBlocking(false);}
} }
/// Appends data to the upbuffer. /// Appends data to the upbuffer.