summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ctdb/common/ctdb_io.c28
1 files changed, 6 insertions, 22 deletions
diff --git a/ctdb/common/ctdb_io.c b/ctdb/common/ctdb_io.c
index 1db6f2b7de6..aee8864c179 100644
--- a/ctdb/common/ctdb_io.c
+++ b/ctdb/common/ctdb_io.c
@@ -29,9 +29,6 @@
#include "../include/ctdb_client.h"
#include <stdarg.h>
-#define QUEUE_BUFFER_SIZE (4*1024)
-#define QUEUE_BUFFER_OVERSIZE (64*1024)
-
/* structures for packet queueing - see common/ctdb_io.c */
struct ctdb_buffer {
uint8_t *data;
@@ -125,12 +122,6 @@ static void queue_process(struct ctdb_queue *queue)
/* There is more data to be processed, schedule an event */
tevent_schedule_immediate(queue->im, queue->ctdb->ev,
queue_process_event, queue);
- } else {
- /* Throw away large buffer when done processing requests */
- if (queue->buffer.size > QUEUE_BUFFER_OVERSIZE) {
- TALLOC_FREE(queue->buffer.data);
- queue->buffer.size = 0;
- }
}
/* It is the responsibility of the callback to free 'data' */
@@ -168,29 +159,22 @@ static void queue_io_read(struct ctdb_queue *queue)
}
if (queue->buffer.data == NULL) {
- int n;
-
/* starting fresh, allocate buf to read data */
- n = QUEUE_BUFFER_SIZE * (num_ready/QUEUE_BUFFER_SIZE + 1);
- queue->buffer.data = talloc_size(queue, n);
+ queue->buffer.data = talloc_size(queue, num_ready);
if (queue->buffer.data == NULL) {
- DEBUG(DEBUG_ERR, ("read error alloc failed for %u\n", n));
+ DEBUG(DEBUG_ERR, ("read error alloc failed for %u\n", num_ready));
goto failed;
}
- queue->buffer.size = n;
+ queue->buffer.size = num_ready;
} else if (queue->buffer.length + num_ready > queue->buffer.size) {
- int increment, n;
-
/* extending buffer */
- increment = (queue->buffer.length + num_ready) - queue->buffer.size;
- n = queue->buffer.size + QUEUE_BUFFER_SIZE * (increment/QUEUE_BUFFER_SIZE + 1);
- data = talloc_realloc_size(queue, queue->buffer.data, n);
+ data = talloc_realloc_size(queue, queue->buffer.data, queue->buffer.length + num_ready);
if (data == NULL) {
- DEBUG(DEBUG_ERR, ("read error realloc failed for %u\n", n));
+ DEBUG(DEBUG_ERR, ("read error realloc failed for %u\n", queue->buffer.length + num_ready));
goto failed;
}
queue->buffer.data = data;
- queue->buffer.size = n;
+ queue->buffer.size = queue->buffer.length + num_ready;
}
nread = read(queue->fd, queue->buffer.data + queue->buffer.length, num_ready);