1
/* Copyright (C) 2003 MySQL AB
3
This program is free software; you can redistribute it and/or modify
4
it under the terms of the GNU General Public License as published by
5
the Free Software Foundation; version 2 of the License.
7
This program is distributed in the hope that it will be useful,
8
but WITHOUT ANY WARRANTY; without even the implied warranty of
9
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
GNU General Public License for more details.
12
You should have received a copy of the GNU General Public License
13
along with this program; if not, write to the Free Software
14
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
16
#include "SendBuffer.hpp"
17
#include "TransporterInternalDefinitions.hpp"
19
SendBuffer::SendBuffer(Uint32 bufSize) {
21
sizeOfBuffer = bufSize;
22
if(sizeOfBuffer < MAX_MESSAGE_SIZE)
23
sizeOfBuffer = 2 * MAX_MESSAGE_SIZE;
35
SendBuffer::initBuffer(Uint32 aRemoteNodeId) {
37
// Allocate memory for the buffer
38
#ifdef DEBUG_TRANSPORTER
39
ndbout << "Allocating " << sizeOfBuffer << " bytes for send buffer" << endl;
42
startOfBuffer = new Uint32[(sizeOfBuffer >> 2) + 1];
43
endOfBuffer = startOfBuffer + (sizeOfBuffer >> 2);
46
theRemoteNodeId = aRemoteNodeId;
50
SendBuffer::~SendBuffer() {
51
// Deallocate the buffer memory
52
if(startOfBuffer != NULL)
53
delete[] startOfBuffer;
57
SendBuffer::bufferSize() {
62
SendBuffer::bufferSizeRemaining() const {
63
return (sizeOfBuffer - dataSize);
67
SendBuffer::emptyBuffer() {
68
insertPtr = startOfBuffer;
69
sendPtr = (char*)startOfBuffer;
74
#ifdef DEBUG_TRANSPORTER
78
printf("SendBuffer status printouts\n");
80
printf( "sizeOfBuffer: %d\n", sizeOfBuffer);
81
printf( "startOfBuffer: %.8x\n", startOfBuffer);
82
printf( "endOfBuffer: %.8x\n", endOfBuffer);
83
printf( "insertPtr: %.8x\n", insertPtr);
84
printf( "sendPtr: %.8x\n", sendPtr);
85
printf( "sendDataSize: %d\n", sendDataSize);
86
printf( "dataSize: %d\n", dataSize);