The branch, master has been updated
       via  32d867c ctdb-common: Optimize sock_queue's memory managament
       via  eae2d35 ctdb-common: Remove sock_queue_destructor
       via  f9150c5 ctdb-common: Return if packet size is zero
      from  0766f06 libcli: Remove finddcs_nbt.c

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 32d867cf09a15626b991be414ab6440f68953f35
Author: Swen Schillig <s...@vnet.ibm.com>
Date:   Mon Jan 8 14:55:31 2018 +0100

    ctdb-common: Optimize sock_queue's memory managament
    
    Make use of talloc pools for the sock_queue's memory requirements.
    
    Signed-off-by: Swen Schillig <s...@vnet.ibm.com>
    Reviewed-by: Amitay Isaacs <ami...@gmail.com>
    Reviewed-by: Martin Schwenke <mar...@meltin.net>
    
    Autobuild-User(master): Martin Schwenke <mart...@samba.org>
    Autobuild-Date(master): Tue Jan 30 18:12:32 CET 2018 on sn-devel-144

commit eae2d35fec071b020f420ba74ac6551c84140a4d
Author: Swen Schillig <s...@vnet.ibm.com>
Date:   Mon Jan 8 14:13:46 2018 +0100

    ctdb-common: Remove sock_queue_destructor
    
    The sock_queue_destructor is not needed.
    The performed tasks will be performed automatically.
    
    Signed-off-by: Swen Schillig <s...@vnet.ibm.com>
    Reviewed-by: Amitay Isaacs <ami...@gmail.com>
    Reviewed-by: Martin Schwenke <mar...@meltin.net>

commit f9150c5fa0ac81a848dbb6978a73c10170648d5b
Author: Swen Schillig <s...@vnet.ibm.com>
Date:   Mon Jan 8 14:10:40 2018 +0100

    ctdb-common: Return if packet size is zero
    
    Prevent further processing of sock_queue_process
    if the received packet size is zero.
    
    Signed-off-by: Swen Schillig <s...@vnet.ibm.com>
    Reviewed-by: Amitay Isaacs <ami...@gmail.com>
    Reviewed-by: Martin Schwenke <mar...@meltin.net>

-----------------------------------------------------------------------

Summary of changes:
 ctdb/common/sock_io.c | 27 +++++++++++++++------------
 1 file changed, 15 insertions(+), 12 deletions(-)


Changeset truncated at 500 lines:

diff --git a/ctdb/common/sock_io.c b/ctdb/common/sock_io.c
index 3f7138f..51341ce 100644
--- a/ctdb/common/sock_io.c
+++ b/ctdb/common/sock_io.c
@@ -94,8 +94,18 @@ struct sock_queue {
        size_t buflen, begin, end;
 };
 
+/*
+ * The reserved talloc headers, SOCK_QUEUE_OBJ_COUNT,
+ * and the pre-allocated pool-memory SOCK_QUEUE_POOL_SIZE,
+ * are used for the sub-objects queue->im, queue->queue, queue->fde
+ * and queue->buf.
+ * If the memory allocating sub-objects of struct sock_queue change,
+ * those values need to be adjusted.
+ */
+#define SOCK_QUEUE_OBJ_COUNT 4
+#define SOCK_QUEUE_POOL_SIZE 2048
+
 static bool sock_queue_set_fd(struct sock_queue *queue, int fd);
-static int sock_queue_destructor(struct sock_queue *queue);
 static void sock_queue_handler(struct tevent_context *ev,
                               struct tevent_fd *fde, uint16_t flags,
                               void *private_data);
@@ -112,10 +122,12 @@ struct sock_queue *sock_queue_setup(TALLOC_CTX *mem_ctx,
 {
        struct sock_queue *queue;
 
-       queue = talloc_zero(mem_ctx, struct sock_queue);
+       queue = talloc_pooled_object(mem_ctx, struct sock_queue,
+                                    SOCK_QUEUE_OBJ_COUNT, 
SOCK_QUEUE_POOL_SIZE);
        if (queue == NULL) {
                return NULL;
        }
+       memset(queue, 0, sizeof(struct sock_queue));
 
        queue->ev = ev;
        queue->callback = callback;
@@ -138,8 +150,6 @@ struct sock_queue *sock_queue_setup(TALLOC_CTX *mem_ctx,
                return NULL;
        }
 
-       talloc_set_destructor(queue, sock_queue_destructor);
-
        return queue;
 }
 
@@ -168,14 +178,6 @@ static bool sock_queue_set_fd(struct sock_queue *queue, 
int fd)
        return true;
 }
 
-static int sock_queue_destructor(struct sock_queue *queue)
-{
-       TALLOC_FREE(queue->fde);
-       queue->fd = -1;
-
-       return 0;
-}
-
 static void sock_queue_handler(struct tevent_context *ev,
                               struct tevent_fd *fde, uint16_t flags,
                               void *private_data)
@@ -231,6 +233,7 @@ static void sock_queue_process(struct sock_queue *queue)
        if (pkt_size == 0) {
                D_ERR("Invalid packet of length 0\n");
                queue->callback(NULL, 0, queue->private_data);
+               return;
        }
 
        if ((queue->end - queue->begin) < pkt_size) {


-- 
Samba Shared Repository

Reply via email to