fix extraneous FinalizeLazyPut in NetworkSink::Put2 in case of exceptions

pull/2/head
weidai 2004-04-08 01:31:06 +00:00
parent 3b1e3952c9
commit ea453ec4c6
1 changed files with 4 additions and 1 deletions

View File

@ -195,7 +195,7 @@ unsigned int NetworkSink::Put2(const byte *inString, unsigned int length, int me
inString += m_skipBytes; inString += m_skipBytes;
length -= m_skipBytes; length -= m_skipBytes;
} }
LazyPutter lp(m_buffer, inString, length); m_buffer.LazyPut(inString, length);
if (!blocking || m_buffer.CurrentSize() > m_autoFlushBound) if (!blocking || m_buffer.CurrentSize() > m_autoFlushBound)
TimedFlush(0, 0); TimedFlush(0, 0);
@ -209,10 +209,13 @@ unsigned int NetworkSink::Put2(const byte *inString, unsigned int length, int me
assert(!blocking); assert(!blocking);
unsigned int blockedBytes = STDMIN(m_buffer.CurrentSize() - targetSize, (unsigned long)length); unsigned int blockedBytes = STDMIN(m_buffer.CurrentSize() - targetSize, (unsigned long)length);
m_buffer.UndoLazyPut(blockedBytes); m_buffer.UndoLazyPut(blockedBytes);
m_buffer.FinalizeLazyPut();
m_wasBlocked = true; m_wasBlocked = true;
m_skipBytes += length - blockedBytes; m_skipBytes += length - blockedBytes;
return STDMAX(blockedBytes, 1U); return STDMAX(blockedBytes, 1U);
} }
m_buffer.FinalizeLazyPut();
m_wasBlocked = false; m_wasBlocked = false;
m_skipBytes = 0; m_skipBytes = 0;