Avoid event_find_context() when the event context is already available
authorJelmer Vernooij <jelmer@samba.org>
Wed, 16 Apr 2008 20:30:15 +0000 (22:30 +0200)
committerJelmer Vernooij <jelmer@samba.org>
Wed, 16 Apr 2008 20:30:15 +0000 (22:30 +0200)
in the net utility.
(This used to be commit d40804777edf41889bd461f63f7a07cc1cc60e27)

source4/utils/net/net.c
source4/utils/net/net.h
source4/utils/net/net_join.c
source4/utils/net/net_password.c
source4/utils/net/net_time.c
source4/utils/net/net_user.c
source4/utils/net/net_vampire.c

index 6086a4ce32d98836d31aae821453dc7a378aab57..ab81f07225a88bcc7dc00ffafaaacae8651358c7 100644 (file)
@@ -199,6 +199,7 @@ static int binary_net(int argc, const char **argv)
        ZERO_STRUCTP(ctx);
        ctx->lp_ctx = cmdline_lp_ctx;
        ctx->credentials = cmdline_credentials;
+       ctx->event_ctx = ev;
        cli_credentials_set_event_context(ctx->credentials, ev);
 
        rc = net_run_function(ctx, argc_new-1, argv_new+1, net_functable, net_usage);
index 17388079dd999489f281cda23265a15b2c175f7a..309bee277c3e5214d85ac69164b3bd4f821ae85c 100644 (file)
@@ -24,6 +24,7 @@
 struct net_context {
        struct cli_credentials *credentials;
        struct loadparm_context *lp_ctx;
+       struct event_context *event_ctx;
 };
 
 struct net_functable {
index 37b3c21fcf98d975c1cc5e4d1941ccc313339094..ad63340089907b550122218fdd5bb8e2ef440113 100644 (file)
@@ -58,7 +58,7 @@ int net_join(struct net_context *ctx, int argc, const char **argv)
 
        domain_name = tmp;
 
-       libnetctx = libnet_context_init(event_context_find(ctx), ctx->lp_ctx);
+       libnetctx = libnet_context_init(ctx->event_ctx, ctx->lp_ctx);
        if (!libnetctx) {
                return -1;      
        }
index 97bb467facde7c434fcbc0143778f12b47bd6c90..55f7c3c31d610898eb6b86cf5945fcc907006a15 100644 (file)
@@ -53,7 +53,7 @@ static int net_password_change(struct net_context *ctx, int argc, const char **a
                new_password = getpass(password_prompt);
        }
 
-       libnetctx = libnet_context_init(event_context_find(ctx), ctx->lp_ctx);
+       libnetctx = libnet_context_init(ctx->event_ctx, ctx->lp_ctx);
        if (!libnetctx) {
                return -1;      
        }
@@ -128,7 +128,7 @@ static int net_password_set(struct net_context *ctx, int argc, const char **argv
                new_password = getpass(password_prompt);
        }
 
-       libnetctx = libnet_context_init(event_context_find(ctx), ctx->lp_ctx);
+       libnetctx = libnet_context_init(ctx->event_ctx, ctx->lp_ctx);
        if (!libnetctx) {
                return -1;      
        }
index 12a8132ceaae294384850fbee1c90716832b0f72..92e6e7748192bd47a3430366697365bdf6fd0c73 100644 (file)
@@ -43,7 +43,7 @@ int net_time(struct net_context *ctx, int argc, const char **argv)
                return net_time_usage(ctx, argc, argv);
        }
 
-       libnetctx = libnet_context_init(event_context_find(ctx), ctx->lp_ctx);
+       libnetctx = libnet_context_init(ctx->event_ctx, ctx->lp_ctx);
        if (!libnetctx) {
                return -1;      
        }
index 57cef6b383a9620d3ce282ae5371723b1a775573..c4b8ecb0c2b3714baadf871cad0468e2eaeca25a 100644 (file)
@@ -44,7 +44,7 @@ static int net_user_add(struct net_context *ctx, int argc, const char **argv)
        }
 
        /* libnet context init and its params */
-       lnet_ctx = libnet_context_init(event_context_find(ctx), ctx->lp_ctx);
+       lnet_ctx = libnet_context_init(ctx->event_ctx, ctx->lp_ctx);
        if (!lnet_ctx) return -1;
 
        lnet_ctx->cred = ctx->credentials;
@@ -84,7 +84,7 @@ static int net_user_delete(struct net_context *ctx, int argc, const char **argv)
        }
 
        /* libnet context init and its params */
-       lnet_ctx = libnet_context_init(event_context_find(ctx), ctx->lp_ctx);
+       lnet_ctx = libnet_context_init(ctx->event_ctx, ctx->lp_ctx);
        if (!lnet_ctx) return -1;
 
        lnet_ctx->cred = ctx->credentials;
index 38f05353ed639a306ae50e943eda0af0b56ec197..14f6a07e4bbe92ffbe5cc4939c5fa3b33c61cef8 100644 (file)
@@ -54,7 +54,7 @@ static int net_samdump_keytab(struct net_context *ctx, int argc, const char **ar
                break;
        }
 
-       libnetctx = libnet_context_init(event_context_find(ctx), ctx->lp_ctx);
+       libnetctx = libnet_context_init(ctx->event_ctx, ctx->lp_ctx);
        if (!libnetctx) {
                return -1;      
        }
@@ -100,7 +100,7 @@ int net_samdump(struct net_context *ctx, int argc, const char **argv)
                return rc;
        }
 
-       libnetctx = libnet_context_init(event_context_find(ctx), ctx->lp_ctx);
+       libnetctx = libnet_context_init(ctx->event_ctx, ctx->lp_ctx);
        if (!libnetctx) {
                return -1;      
        }
@@ -142,7 +142,7 @@ int net_samsync_ldb(struct net_context *ctx, int argc, const char **argv)
        struct libnet_context *libnetctx;
        struct libnet_samsync_ldb r;
 
-       libnetctx = libnet_context_init(event_context_find(ctx), ctx->lp_ctx);
+       libnetctx = libnet_context_init(ctx->event_ctx, ctx->lp_ctx);
        if (!libnetctx) {
                return -1;      
        }