From ab7e75e74d47527a785f00c88c1d11be24c2de84 Mon Sep 17 00:00:00 2001 From: Hugo Santos Date: Fri, 13 Apr 2007 03:45:28 +0000 Subject: [PATCH] don't do MSS segmentation in TCP's SendData(), _SendQueue() already does the appropriate work. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20674 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../network/protocols/tcp/TCPEndpoint.cpp | 51 +++---------------- 1 file changed, 7 insertions(+), 44 deletions(-) diff --git a/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.cpp b/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.cpp index 223b072efe..445bc9f745 100644 --- a/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.cpp +++ b/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.cpp @@ -480,57 +480,20 @@ TCPEndpoint::SendData(net_buffer *buffer) return EPIPE; } - size_t bytesLeft = buffer->size; + if (buffer->size > 0) { + bigtime_t timeout = absolute_timeout(socket->send.timeout); - bigtime_t timeout = absolute_timeout(socket->send.timeout); - - do { - // TODO we should not segment here, but on TX. - - net_buffer *chunk; - if (bytesLeft > socket->send.buffer_size) { - // divide the buffer in multiple of the maximum segment size - size_t chunkSize = ((socket->send.buffer_size >> 1) / fSendMaxSegmentSize) - * fSendMaxSegmentSize; - - chunk = gBufferModule->split(buffer, chunkSize); - TRACE(" Send() split buffer at %lu (buffer size %lu, mss %lu) -> %p", - chunkSize, socket->send.buffer_size, fSendMaxSegmentSize, chunk); - if (chunk == NULL) - return B_NO_MEMORY; - } else - chunk = buffer; - - while (fSendQueue.Free() < chunk->size) { + while (fSendQueue.Free() < buffer->size) { status_t status = fSendList.Wait(lock, timeout); if (status < B_OK) return posix_error(status); } - // TODO: check state! + fSendQueue.Add(buffer); + } - if (chunk->size == 0) { - gBufferModule->free(chunk); - return B_OK; - } - - size_t chunkSize = chunk->size; - fSendQueue.Add(chunk); - - status_t status = B_OK; - - if (fState == ESTABLISHED || fState == FINISH_RECEIVED) - status = _SendQueued(); - - if (buffer != chunk) { - // as long as we didn't eat the buffer, we can still return an error code - // (we don't own the buffer if we return an error code) - if (status < B_OK) - return status; - } - - bytesLeft -= chunkSize; - } while (bytesLeft > 0); + if (fState == ESTABLISHED || fState == FINISH_RECEIVED) + _SendQueued(); return B_OK; }