summaryrefslogtreecommitdiffstats
path: root/ctdb/common
diff options
context:
space:
mode:
authorAmitay Isaacs <amitay@gmail.com>2013-08-20 14:20:09 +1000
committerAmitay Isaacs <amitay@gmail.com>2013-08-22 14:08:52 +1000
commitcfb7f74fa2d95c0d5ff4b4fd01bb06b15baf3b4c (patch)
treeb57b0c68a07e1ea65950fa85c6c03948a241a783 /ctdb/common
parent1467b666f219586a0612bd32804b0dff7a84082c (diff)
downloadsamba-cfb7f74fa2d95c0d5ff4b4fd01bb06b15baf3b4c.tar.gz
samba-cfb7f74fa2d95c0d5ff4b4fd01bb06b15baf3b4c.tar.xz
samba-cfb7f74fa2d95c0d5ff4b4fd01bb06b15baf3b4c.zip
Revert "common/io: Keep queue buffer size multiple of 4K"
This reverts commit 5e9b1a7e24d058ff88aaa0563db36a804e866fa9. This is not the best approach. Allowing queue buffer size to grow indefinitely causes large number of CTDB packets to be queued up very quickly which when processed via immediate events will block CTDB from processing events from other FDs. If there are immediate events queued up, tevent will never process any of the FDs till all immediate events are processed. Signed-off-by: Amitay Isaacs <amitay@gmail.com> (This used to be ctdb commit d8b094e804efc53fae9f44c6ef961b7b5797d290)
Diffstat (limited to 'ctdb/common')
-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);