[SCM] Samba Shared Repository - branch master updated
Jeremy Allison
jra at samba.org
Sat Aug 18 02:59:01 UTC 2018
The branch, master has been updated
via d0ed4a5 ctdb: calculate queue input buffer size correctly
via 8262efb ctdb: Replace calculation of bytes to read from socket by MIN() macro
from 41aa55f s3: util: Do not take over stderr when there is no log file
https://git.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit d0ed4a536ee0ddce2e27dffe301304b8fa55ccce
Author: Swen Schillig <swen at vnet.ibm.com>
Date: Wed Mar 7 13:54:45 2018 +0100
ctdb: calculate queue input buffer size correctly
The queue's input buffer is calculated in an iterative way.
This can result in a few back and forth jumping and
a few memory allocations and mem-free cycles.
This is very time consuming and not required, because the required
memory size can be calculated right away.
Signed-off-by: Swen Schillig <swen at vnet.ibm.com>
Reviewed-by: Martin Schwenke <martin at meltin.net>
Reviewed-by: Jeremy Allison <jra at samba.org>
Autobuild-User(master): Jeremy Allison <jra at samba.org>
Autobuild-Date(master): Sat Aug 18 04:58:05 CEST 2018 on sn-devel-144
commit 8262efbc96b06535b5d29395c71d5fa4e0d8bc63
Author: Swen Schillig <swen at vnet.ibm.com>
Date: Thu Aug 9 09:15:36 2018 +0200
ctdb: Replace calculation of bytes to read from socket by MIN() macro
The calculation of the bytes to read from the socket can be done easier
by the usage of the common MIN() macro.
Signed-off-by: Swen Schillig <swen at vnet.ibm.com>
Reviewed-by: Martin Schwenke <martin at meltin.net>
Reviewed-by: Jeremy Allison <jra at samba.org>
-----------------------------------------------------------------------
Summary of changes:
ctdb/common/ctdb_io.c | 35 ++++++++++++++++++++---------------
1 file changed, 20 insertions(+), 15 deletions(-)
Changeset truncated at 500 lines:
diff --git a/ctdb/common/ctdb_io.c b/ctdb/common/ctdb_io.c
index da444ac..32d8fc7 100644
--- a/ctdb/common/ctdb_io.c
+++ b/ctdb/common/ctdb_io.c
@@ -43,7 +43,6 @@ struct ctdb_buffer {
uint8_t *data;
uint32_t length;
uint32_t size;
- uint32_t extend;
};
struct ctdb_queue_pkt {
@@ -102,16 +101,15 @@ static void queue_process(struct ctdb_queue *queue)
return;
}
+ /* Did we at least read the size into the buffer */
pkt_size = *(uint32_t *)queue->buffer.data;
if (pkt_size == 0) {
DEBUG(DEBUG_CRIT, ("Invalid packet of length 0\n"));
goto failed;
}
+ /* the buffer doesn't contain the full packet, return to get the rest */
if (queue->buffer.length < pkt_size) {
- if (pkt_size > queue->buffer_size) {
- queue->buffer.extend = pkt_size;
- }
return;
}
@@ -158,9 +156,9 @@ failed:
static void queue_io_read(struct ctdb_queue *queue)
{
int num_ready = 0;
+ uint32_t pkt_size;
ssize_t nread;
uint8_t *data;
- int navail;
/* check how much data is available on the socket for immediately
guaranteed nonblocking access.
@@ -184,22 +182,29 @@ static void queue_io_read(struct ctdb_queue *queue)
goto failed;
}
queue->buffer.size = queue->buffer_size;
- } else if (queue->buffer.extend > 0) {
- /* extending buffer */
- data = talloc_realloc_size(queue, queue->buffer.data, queue->buffer.extend);
+ goto data_read;
+ }
+
+ if (queue->buffer.length < sizeof(pkt_size)) {
+ /* data read is not sufficient to gather message size */
+ goto data_read;
+ }
+
+ pkt_size = *(uint32_t *)queue->buffer.data;
+ if (pkt_size > queue->buffer.size) {
+ data = talloc_realloc_size(queue,
+ queue->buffer.data,
+ pkt_size);
if (data == NULL) {
- DEBUG(DEBUG_ERR, ("read error realloc failed for %u\n", queue->buffer.extend));
+ DBG_ERR("read error realloc failed for %u\n", pkt_size);
goto failed;
}
queue->buffer.data = data;
- queue->buffer.size = queue->buffer.extend;
- queue->buffer.extend = 0;
+ queue->buffer.size = pkt_size;
}
- navail = queue->buffer.size - queue->buffer.length;
- if (num_ready > navail) {
- num_ready = navail;
- }
+data_read:
+ num_ready = MIN(num_ready, queue->buffer.size - queue->buffer.length);
if (num_ready > 0) {
nread = sys_read(queue->fd,
--
Samba Shared Repository
More information about the samba-cvs
mailing list