The branch, master has been updated
       via  0045f3b messaging: Fix a memleak (master only..)
       via  b2c85ee messaging: Use talloc_pooled_object
       via  0c2f85a messaging: Move the self-send logic out of messaging_tdb
       via  46afd9b messaging: Fix a memleak with clustering
      from  bff3ac2 s3-passdb: Fix string duplication to pointers.

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


- Log -----------------------------------------------------------------
commit 0045f3b0a3d232103a059f9cec3743486f402452
Author: Volker Lendecke <[email protected]>
Date:   Wed Jan 8 16:32:39 2014 +0100

    messaging: Fix a memleak (master only..)
    
    Immediate tevents don't free themselves as timed events do :-)
    
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>
    
    Autobuild-User(master): Jeremy Allison <[email protected]>
    Autobuild-Date(master): Fri Jan 10 01:20:04 CET 2014 on sn-devel-104

commit b2c85ee90e201bc95e09c90f712f69d7413bc4b4
Author: Volker Lendecke <[email protected]>
Date:   Wed Jan 8 16:15:27 2014 +0100

    messaging: Use talloc_pooled_object
    
    ... not as a speed improvement, it saves the second NULL check
    
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>

commit 0c2f85a66ca0d971c6008a62c4fa732112638934
Author: Volker Lendecke <[email protected]>
Date:   Wed Jan 8 16:13:11 2014 +0100

    messaging: Move the self-send logic out of messaging_tdb
    
    This is not specific to tdb
    
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>

commit 46afd9b28df46301703ed4166dd8ba0e41767f5b
Author: Volker Lendecke <[email protected]>
Date:   Wed Jan 8 09:32:37 2014 +0000

    messaging: Fix a memleak with clustering
    
    We have to properly throw away unexpected messages that came in via ctdb
    
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>

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

Summary of changes:
 source3/lib/messages.c       |   51 +++++++++++++++++++++++++++++++++++++++
 source3/lib/messages_local.c |   54 ------------------------------------------
 source3/lib/msg_channel.c    |    3 ++
 3 files changed, 54 insertions(+), 54 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/lib/messages.c b/source3/lib/messages.c
index f4d6227..ba473ae 100644
--- a/source3/lib/messages.c
+++ b/source3/lib/messages.c
@@ -344,6 +344,15 @@ void messaging_deregister(struct messaging_context *ctx, 
uint32_t msg_type,
        }
 }
 
+struct messaging_selfsend_state {
+       struct messaging_context *msg;
+       struct messaging_rec rec;
+};
+
+static void messaging_trigger_self(struct tevent_context *ev,
+                                  struct tevent_immediate *im,
+                                  void *private_data);
+
 /*
   Send a message to a particular server
 */
@@ -362,10 +371,52 @@ NTSTATUS messaging_send(struct messaging_context *msg_ctx,
                                                msg_ctx->remote);
        }
 #endif
+
+       if (server_id_equal(&msg_ctx->id, &server)) {
+               struct messaging_selfsend_state *state;
+               struct tevent_immediate *im;
+
+               state = talloc_pooled_object(
+                       msg_ctx, struct messaging_selfsend_state,
+                       1, data->length);
+               if (state == NULL) {
+                       return NT_STATUS_NO_MEMORY;
+               }
+               state->msg = msg_ctx;
+               state->rec.msg_version = MESSAGE_VERSION;
+               state->rec.msg_type = msg_type & MSG_TYPE_MASK;
+               state->rec.dest = server;
+               state->rec.src = msg_ctx->id;
+
+               /* Can't fail, it's a pooled_object */
+               state->rec.buf = data_blob_talloc(
+                       state, data->data, data->length);
+
+               im = tevent_create_immediate(state);
+               if (im == NULL) {
+                       TALLOC_FREE(state);
+                       return NT_STATUS_NO_MEMORY;
+               }
+
+               tevent_schedule_immediate(im, msg_ctx->event_ctx,
+                                         messaging_trigger_self, state);
+               return NT_STATUS_OK;
+       }
+
        return msg_ctx->local->send_fn(msg_ctx, server, msg_type, data,
                                       msg_ctx->local);
 }
 
+static void messaging_trigger_self(struct tevent_context *ev,
+                                  struct tevent_immediate *im,
+                                  void *private_data)
+{
+       struct messaging_selfsend_state *state = talloc_get_type_abort(
+               private_data, struct messaging_selfsend_state);
+       messaging_dispatch_rec(state->msg, &state->rec);
+       TALLOC_FREE(state);
+}
+
 NTSTATUS messaging_send_buf(struct messaging_context *msg_ctx,
                            struct server_id server, uint32_t msg_type,
                            const uint8_t *buf, size_t len)
diff --git a/source3/lib/messages_local.c b/source3/lib/messages_local.c
index 36a267a..c74c0aa 100644
--- a/source3/lib/messages_local.c
+++ b/source3/lib/messages_local.c
@@ -354,15 +354,6 @@ static NTSTATUS message_notify(struct server_id procid)
  Send a message to a particular pid.
 ****************************************************************************/
 
-struct messaging_tdb_self_state {
-       struct messaging_context *msg;
-       struct messaging_rec rec;
-};
-
-static void messaging_tdb_trigger_self(struct tevent_context *ev,
-                                      struct tevent_immediate *im,
-                                      void *private_data);
-
 static NTSTATUS messaging_tdb_send(struct messaging_context *msg_ctx,
                                   struct server_id pid, int msg_type,
                                   const DATA_BLOB *data,
@@ -389,41 +380,6 @@ static NTSTATUS messaging_tdb_send(struct 
messaging_context *msg_ctx,
 
        SMB_ASSERT(procid_to_pid(&pid) > 0);
 
-       if (server_id_equal(&msg_ctx->id, &pid)) {
-               struct messaging_tdb_self_state *state;
-               struct tevent_immediate *im;
-
-               TALLOC_FREE(frame);
-
-               im = tevent_create_immediate(msg_ctx);
-               if (im == NULL) {
-                       return NT_STATUS_NO_MEMORY;
-               }
-
-               state = talloc(im, struct messaging_tdb_self_state);
-               if (state == NULL) {
-                       TALLOC_FREE(im);
-                       return NT_STATUS_NO_MEMORY;
-               }
-               state->msg = msg_ctx;
-               state->rec.msg_version = MESSAGE_VERSION;
-               state->rec.msg_type = msg_type & MSG_TYPE_MASK;
-               state->rec.dest = pid;
-               state->rec.src = msg_ctx->id;
-
-               state->rec.buf = data_blob_talloc(
-                       state, data->data, data->length);
-               if ((state->rec.buf.length != 0) &&
-                   (state->rec.buf.data == NULL)) {
-                       TALLOC_FREE(im);
-                       return NT_STATUS_NO_MEMORY;
-               }
-
-               tevent_schedule_immediate(im, msg_ctx->event_ctx,
-                                         messaging_tdb_trigger_self, state);
-               return NT_STATUS_OK;
-       }
-
        key = message_key_pid(frame, pid);
 
        if (tdb_chainlock(tdb->tdb, key) != 0) {
@@ -481,16 +437,6 @@ static NTSTATUS messaging_tdb_send(struct 
messaging_context *msg_ctx,
        return status;
 }
 
-static void messaging_tdb_trigger_self(struct tevent_context *ev,
-                                      struct tevent_immediate *im,
-                                      void *private_data)
-{
-       struct messaging_tdb_self_state *state = talloc_get_type_abort(
-               private_data, struct messaging_tdb_self_state);
-       messaging_dispatch_rec(state->msg, &state->rec);
-}
-
-
 /****************************************************************************
  Retrieve all messages for a process.
 ****************************************************************************/
diff --git a/source3/lib/msg_channel.c b/source3/lib/msg_channel.c
index 8e23fd4..6be5e2e 100644
--- a/source3/lib/msg_channel.c
+++ b/source3/lib/msg_channel.c
@@ -310,6 +310,9 @@ static void msg_read_got_ctdb(struct tevent_req *subreq)
        /*
         * Got some unexpected msg type, wait for the next one
         */
+
+       TALLOC_FREE(state->rec);
+
        subreq = ctdb_msg_read_send(state, state->ev,
                                    state->channel->ctdb_channel);
        if (tevent_req_nomem(subreq, req)) {


-- 
Samba Shared Repository

Reply via email to