update buffer size when prepending buffers.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20642 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
914c48cad7
commit
1c96882baa
@ -796,7 +796,7 @@ TCPEndpoint::ListenReceive(tcp_segment_header &segment, net_buffer *buffer)
|
||||
int32
|
||||
TCPEndpoint::SynchronizeSentReceive(tcp_segment_header &segment, net_buffer *buffer)
|
||||
{
|
||||
TRACE("SynchronizeReceive(): packet %p (%lu bytes) with flags 0x%x, seq %lu, ack %lu!",
|
||||
TRACE("SynchronizeSentReceive(): packet %p (%lu bytes) with flags 0x%x, seq %lu, ack %lu!",
|
||||
buffer, buffer->size, segment.flags, segment.sequence, segment.acknowledge);
|
||||
|
||||
if ((segment.flags & TCP_FLAG_ACKNOWLEDGE) != 0
|
||||
@ -1306,10 +1306,6 @@ TCPEndpoint::_SendQueued(bool force)
|
||||
|
||||
gAddressModule->set_to((sockaddr *)&buffer->source, (sockaddr *)&socket->address);
|
||||
gAddressModule->set_to((sockaddr *)&buffer->destination, (sockaddr *)&socket->peer);
|
||||
TRACE("SendQueued() flags %x, buffer %p, size %lu, from address %s to %s",
|
||||
segment.flags, buffer, buffer->size,
|
||||
AddressString(gDomain, (sockaddr *)&buffer->source, true).Data(),
|
||||
AddressString(gDomain, (sockaddr *)&buffer->destination, true).Data());
|
||||
|
||||
uint32 size = buffer->size;
|
||||
if (length > 0 && fSendNext + segmentLength == fSendQueue.LastSequence()) {
|
||||
@ -1329,6 +1325,11 @@ TCPEndpoint::_SendQueued(bool force)
|
||||
}
|
||||
}
|
||||
|
||||
TRACE("SendQueued() flags %x, buffer %p, size %lu, from address %s to %s",
|
||||
segment.flags, buffer, buffer->size,
|
||||
AddressString(gDomain, (sockaddr *)&buffer->source, true).Data(),
|
||||
AddressString(gDomain, (sockaddr *)&buffer->destination, true).Data());
|
||||
|
||||
status = add_tcp_header(segment, buffer);
|
||||
if (status != B_OK) {
|
||||
gBufferModule->free(buffer);
|
||||
|
@ -626,17 +626,17 @@ prepend_size(net_buffer *_buffer, size_t size, void **_contiguousBuffer)
|
||||
net_buffer_private *buffer = (net_buffer_private *)_buffer;
|
||||
data_node *node = (data_node *)list_get_first_item(&buffer->buffers);
|
||||
|
||||
TRACE(("prepend_size(buffer %p, size %ld)\n", buffer, size));
|
||||
TRACE(("prepend_size(buffer %p, size %ld) [has %ld]\n", buffer, size,
|
||||
node->header_space));
|
||||
//dump_buffer(buffer);
|
||||
|
||||
if (node->header_space < size) {
|
||||
// we need to prepend a new buffer
|
||||
// we need to prepend new buffers
|
||||
|
||||
size_t bytesLeft = size;
|
||||
do {
|
||||
if (node->header_space == 0) {
|
||||
size_t headerSpace = BUFFER_SIZE - sizeof(data_header);
|
||||
// no more space, need another data node
|
||||
data_header *header = create_data_header(headerSpace);
|
||||
if (header == NULL) {
|
||||
// TODO: free up headers we already allocated!
|
||||
@ -671,21 +671,19 @@ prepend_size(net_buffer *_buffer, size_t size, void **_contiguousBuffer)
|
||||
|
||||
if (_contiguousBuffer)
|
||||
*_contiguousBuffer = NULL;
|
||||
} else {
|
||||
// the data fits into this buffer
|
||||
node->header_space -= size;
|
||||
node->start -= size;
|
||||
node->used += size;
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
if (_contiguousBuffer)
|
||||
*_contiguousBuffer = node->start;
|
||||
|
||||
// the data fits into this buffer
|
||||
node->header_space -= size;
|
||||
node->start -= size;
|
||||
node->used += size;
|
||||
|
||||
if (_contiguousBuffer)
|
||||
*_contiguousBuffer = node->start;
|
||||
|
||||
// adjust offset of following nodes
|
||||
while ((node = (data_node *)list_get_next_item(&buffer->buffers, node)) != NULL) {
|
||||
node->offset += size;
|
||||
// adjust offset of following nodes
|
||||
while ((node = (data_node *)list_get_next_item(&buffer->buffers, node)) != NULL) {
|
||||
node->offset += size;
|
||||
}
|
||||
}
|
||||
|
||||
buffer->size += size;
|
||||
|
Loading…
Reference in New Issue
Block a user