fixed several places that unnecessarily take a reference to the event context
authorAndrew Tridgell <tridge@samba.org>
Fri, 7 Aug 2009 07:14:13 +0000 (17:14 +1000)
committerAndrew Tridgell <tridge@samba.org>
Fri, 7 Aug 2009 07:24:48 +0000 (17:24 +1000)
These references were triggering the ambiguous talloc_free errors from
the recent talloc changes when the server is run using the 'standard'
process model instead of the 'single' process model. I am aiming to
move the build farm to use the 'standard' process model soon, as part
of an effort to make our test environment better match the real
deployment of Samba4.

The references are not needed as the way that the event context is
used is as the 'top parent', so when the event context is freed then
all of the structures that were taking a reference to the event
context were actually freed as well, thus making the references
redundent.

source4/dsdb/samdb/ldb_modules/samldb.c
source4/lib/messaging/messaging.c
source4/libcli/composite/composite.c
source4/libcli/dgram/dgramsocket.c
source4/libcli/raw/clisocket.c
source4/libcli/smb_composite/connect.c
source4/libcli/wrepl/winsrepl.c
source4/librpc/rpc/dcerpc.c
source4/nbt_server/wins/winswack.c

index 544249cbe39990db5c09e728bd131b8bb7b14150..037d5c9e678ec9637aa3a864f196294df044fd17 100644 (file)
@@ -244,10 +244,6 @@ static int samldb_search_template(struct samldb_ctx *ac)
                        return LDB_ERR_OPERATIONS_ERROR;
                }
 
-               if (!talloc_reference(templates_ldb, ev)) {
-                       return LDB_ERR_OPERATIONS_ERROR;
-               }
-
                ret = ldb_set_opaque(ldb,
                                        "templates_ldb", templates_ldb);
                if (ret != LDB_SUCCESS) {
index cfceeffac71424c2a5169c42c75a64229c552ace..277688e8b6aae96576d67e0229f3da7d158687fa 100644 (file)
@@ -596,7 +596,7 @@ struct messaging_context *messaging_init(TALLOC_CTX *mem_ctx,
        /* it needs to be non blocking for sends */
        set_blocking(socket_get_fd(msg->sock), false);
 
-       msg->event.ev   = talloc_reference(msg, ev);
+       msg->event.ev   = ev;
        msg->event.fde  = event_add_fd(ev, msg, socket_get_fd(msg->sock), 
                                       EVENT_FD_READ, messaging_handler, msg);
 
index ab32175d00e7801ce78775985f419effc9ec0f80..7262ebce54da70d2645a010ef7fc24ded748bd59 100644 (file)
@@ -42,11 +42,7 @@ _PUBLIC_ struct composite_context *composite_create(TALLOC_CTX *mem_ctx,
        c = talloc_zero(mem_ctx, struct composite_context);
        if (!c) return NULL;
        c->state = COMPOSITE_STATE_IN_PROGRESS;
-       c->event_ctx = talloc_reference(c, ev);
-       if (!c->event_ctx) {
-               talloc_free(c);
-               return NULL;
-       }
+       c->event_ctx = ev;
 
        return c;
 }
index 751706d2c5551d4e086673e8215f90ab49b55db1..365960edb6d084bf7bfb22d6172447776ecffdd3 100644 (file)
@@ -166,7 +166,7 @@ struct nbt_dgram_socket *nbt_dgram_socket_init(TALLOC_CTX *mem_ctx,
        dgmsock = talloc(mem_ctx, struct nbt_dgram_socket);
        if (dgmsock == NULL) goto failed;
 
-       dgmsock->event_ctx = talloc_reference(dgmsock, event_ctx);
+       dgmsock->event_ctx = event_ctx;
        if (dgmsock->event_ctx == NULL) goto failed;
 
        status = socket_create("ip", SOCKET_TYPE_DGRAM, &dgmsock->sock, 0);
index b9e83218ddd2572d101bf43269570441626c4d1c..02da4917e31b0836ea4b15c27ef551b2d7ed2134 100644 (file)
@@ -61,7 +61,7 @@ struct composite_context *smbcli_sock_connect_send(TALLOC_CTX *mem_ctx,
        if (result == NULL) goto failed;
        result->state = COMPOSITE_STATE_IN_PROGRESS;
 
-       result->event_ctx = talloc_reference(result, event_ctx);
+       result->event_ctx = event_ctx;
        if (result->event_ctx == NULL) goto failed;
 
        state = talloc(result, struct sock_connect_state);
@@ -118,8 +118,7 @@ static void smbcli_sock_connect_recv_conn(struct composite_context *ctx)
        state->result->port = port;
        state->result->hostname = talloc_steal(sock, state->host_name);
 
-       state->result->event.ctx =
-               talloc_reference(state->result, state->ctx->event_ctx);
+       state->result->event.ctx = state->ctx->event_ctx;
        if (composite_nomem(state->result->event.ctx, state->ctx)) return;
 
        composite_done(state->ctx);
index a5d05b7af147da121c9e92b1cb3dc39afb3a3dae..9a19771bc0f6edb4eed2552255be16407c19d2f5 100644 (file)
@@ -466,7 +466,7 @@ struct composite_context *smb_composite_connect_send(struct smb_composite_connec
        c = talloc_zero(mem_ctx, struct composite_context);
        if (c == NULL) goto failed;
 
-       c->event_ctx = talloc_reference(c, event_ctx);
+       c->event_ctx = event_ctx;
        if (c->event_ctx == NULL) goto failed;
 
        state = talloc_zero(c, struct connect_state);
index 48a6abba9d03d77d69a28d3e20963aea3ca12bb2..849511b606560868e106bd26e064eb2a88deaec8 100644 (file)
@@ -171,7 +171,7 @@ struct wrepl_socket *wrepl_socket_init(TALLOC_CTX *mem_ctx,
        wrepl_socket = talloc_zero(mem_ctx, struct wrepl_socket);
        if (!wrepl_socket) return NULL;
 
-       wrepl_socket->event.ctx = talloc_reference(wrepl_socket, event_ctx);
+       wrepl_socket->event.ctx = event_ctx;
        if (!wrepl_socket->event.ctx) goto failed;
 
        wrepl_socket->iconv_convenience = iconv_convenience;
@@ -205,7 +205,7 @@ struct wrepl_socket *wrepl_socket_merge(TALLOC_CTX *mem_ctx,
        wrepl_socket = talloc_zero(mem_ctx, struct wrepl_socket);
        if (wrepl_socket == NULL) goto failed;
 
-       wrepl_socket->event.ctx = talloc_reference(wrepl_socket, event_ctx);
+       wrepl_socket->event.ctx = event_ctx;
        if (wrepl_socket->event.ctx == NULL) goto failed;
 
        wrepl_socket->sock = sock;
index 0ae56a470e500c6f8e7db82d8b8bec4208113278..cc1331984d2d64ada7874352957ec263c38c4686 100644 (file)
@@ -67,7 +67,7 @@ static struct dcerpc_connection *dcerpc_connection_init(TALLOC_CTX *mem_ctx,
 
        c->iconv_convenience = talloc_reference(c, ic);
 
-       c->event_ctx = talloc_reference(c, ev);
+       c->event_ctx = ev;
 
        if (c->event_ctx == NULL) {
                talloc_free(c);
index c53fa1d069adce675ac92fe8aa19f673a88b476b..a58362830acb94e2749898fa8e11b2b5a1bdfd26 100644 (file)
@@ -94,7 +94,7 @@ struct composite_context *wins_challenge_send(TALLOC_CTX *mem_ctx, struct wins_c
        result = talloc_zero(mem_ctx, struct composite_context);
        if (result == NULL) return NULL;
        result->state = COMPOSITE_STATE_IN_PROGRESS;
-       result->event_ctx = talloc_reference(result, io->in.event_ctx);
+       result->event_ctx = io->in.event_ctx;
 
        state = talloc_zero(result, struct wins_challenge_state);
        if (state == NULL) goto failed;
@@ -204,7 +204,7 @@ static struct composite_context *wins_release_demand_send(TALLOC_CTX *mem_ctx, s
        result = talloc_zero(mem_ctx, struct composite_context);
        if (result == NULL) return NULL;
        result->state = COMPOSITE_STATE_IN_PROGRESS;
-       result->event_ctx = talloc_reference(result, io->in.event_ctx);
+       result->event_ctx = io->in.event_ctx;
 
        state = talloc_zero(result, struct wins_release_demand_state);
        if (state == NULL) goto failed;