Remove more event_context_init() uses from function calls within deep down the code.
authorSimo Sorce <idra@samba.org>
Mon, 21 Apr 2008 21:58:23 +0000 (17:58 -0400)
committerSimo Sorce <idra@samba.org>
Mon, 21 Apr 2008 22:12:33 +0000 (18:12 -0400)
Make sure we pass around the event_context where we need it instead.
All test but a few python ones fail. Jelmer promised to fix them.
(This used to be commit 3045d391626fba169aa26be52174883e18d323e9)

60 files changed:
source4/auth/gensec/gensec.c
source4/client/cifsdd.c
source4/client/cifsdd.h
source4/client/cifsddio.c
source4/client/client.c
source4/lib/events/events.c
source4/lib/ldb/ldb_ildap/ldb_ildap.c
source4/lib/ldb_wrap.c
source4/lib/messaging/messaging.c
source4/lib/socket/testsuite.c
source4/libcli/cldap/cldap.c
source4/libcli/cliconnect.c
source4/libcli/composite/composite.c
source4/libcli/dgram/dgramsocket.c
source4/libcli/ldap/ldap_bind.c
source4/libcli/ldap/ldap_client.c
source4/libcli/nbt/nbtsocket.c
source4/libcli/raw/clisocket.c
source4/libcli/resolve/host.c
source4/libcli/resolve/nbtlist.c
source4/libcli/resolve/resolve.c
source4/libcli/smb_composite/connect.c
source4/libcli/smb_composite/fetchfile.c
source4/libcli/smb_composite/fsinfo.c
source4/libcli/wrepl/winsrepl.c
source4/libnet/libnet_site.c
source4/librpc/rpc/dcerpc.c
source4/librpc/rpc/dcerpc_connect.c
source4/rpc_server/spoolss/dcesrv_spoolss.c
source4/torture/auth/ntlmssp.c
source4/torture/basic/base.c
source4/torture/gentest.c
source4/torture/ldap/cldap.c
source4/torture/ldap/cldapbench.c
source4/torture/ldap/common.c
source4/torture/libnet/libnet_domain.c
source4/torture/locktest.c
source4/torture/locktest2.c
source4/torture/masktest.c
source4/torture/nbt/browse.c
source4/torture/nbt/dgram.c
source4/torture/nbt/nbt.c
source4/torture/nbt/query.c
source4/torture/nbt/register.c
source4/torture/nbt/wins.c
source4/torture/nbt/winsbench.c
source4/torture/nbt/winsreplication.c
source4/torture/raw/composite.c
source4/torture/rpc/dssync.c
source4/torture/rpc/join.c
source4/torture/rpc/rpc.c
source4/torture/rpc/samba3rpc.c
source4/torture/rpc/samlogon.c
source4/torture/rpc/samsync.c
source4/torture/rpc/schannel.c
source4/torture/rpc/session_key.c
source4/torture/unix/unix_info2.c
source4/torture/unix/whoami.c
source4/utils/nmblookup.c
source4/utils/ntlm_auth.c

index 59ad15740eba809adce8eb0f0a3a91ac43819551..c82b719dfd87e1ca8d68f9daffa7a55ab43b15fa 100644 (file)
@@ -482,6 +482,11 @@ static NTSTATUS gensec_start(TALLOC_CTX *mem_ctx,
                             struct messaging_context *msg,
                             struct gensec_security **gensec_security)
 {
                             struct messaging_context *msg,
                             struct gensec_security **gensec_security)
 {
+       if (ev == NULL) {
+               DEBUG(0, ("No event context available!\n"));
+               return NT_STATUS_INTERNAL_ERROR;
+       }
+
        (*gensec_security) = talloc(mem_ctx, struct gensec_security);
        NT_STATUS_HAVE_NO_MEMORY(*gensec_security);
 
        (*gensec_security) = talloc(mem_ctx, struct gensec_security);
        NT_STATUS_HAVE_NO_MEMORY(*gensec_security);
 
@@ -493,14 +498,6 @@ static NTSTATUS gensec_start(TALLOC_CTX *mem_ctx,
 
        (*gensec_security)->subcontext = false;
        (*gensec_security)->want_features = 0;
 
        (*gensec_security)->subcontext = false;
        (*gensec_security)->want_features = 0;
-       
-       if (ev == NULL) {
-               ev = event_context_init(*gensec_security);
-               if (ev == NULL) {
-                       talloc_free(*gensec_security);
-                       return NT_STATUS_NO_MEMORY;
-               }
-       }
 
        (*gensec_security)->event_ctx = ev;
        (*gensec_security)->msg_ctx = msg;
 
        (*gensec_security)->event_ctx = ev;
        (*gensec_security)->msg_ctx = msg;
@@ -548,20 +545,11 @@ _PUBLIC_ NTSTATUS gensec_client_start(TALLOC_CTX *mem_ctx,
                             struct loadparm_context *lp_ctx)
 {
        NTSTATUS status;
                             struct loadparm_context *lp_ctx)
 {
        NTSTATUS status;
-       struct event_context *new_ev = NULL;
-
-       if (ev == NULL) {
-               new_ev = event_context_init(mem_ctx);
-               NT_STATUS_HAVE_NO_MEMORY(new_ev);
-               ev = new_ev;
-       }
 
        status = gensec_start(mem_ctx, ev, lp_ctx, NULL, gensec_security);
        if (!NT_STATUS_IS_OK(status)) {
 
        status = gensec_start(mem_ctx, ev, lp_ctx, NULL, gensec_security);
        if (!NT_STATUS_IS_OK(status)) {
-               talloc_free(new_ev);
                return status;
        }
                return status;
        }
-       talloc_steal((*gensec_security), new_ev);
        (*gensec_security)->gensec_role = GENSEC_CLIENT;
 
        return status;
        (*gensec_security)->gensec_role = GENSEC_CLIENT;
 
        return status;
index 8e25dab92756969622859717438e297b4bf502ba..ce48c7bad1f7f73422b6bbb8038bdf7a6e6e22b4 100644 (file)
@@ -24,6 +24,7 @@
 #include "lib/cmdline/popt_common.h"
 #include "libcli/resolve/resolve.h"
 #include "libcli/raw/libcliraw.h"
 #include "lib/cmdline/popt_common.h"
 #include "libcli/resolve/resolve.h"
 #include "libcli/raw/libcliraw.h"
+#include "lib/events/events.h"
 
 #include "cifsdd.h"
 #include "param/param.h"
 
 #include "cifsdd.h"
 #include "param/param.h"
@@ -354,6 +355,7 @@ static void print_transfer_stats(void)
 }
 
 static struct dd_iohandle * open_file(struct resolve_context *resolve_ctx, 
 }
 
 static struct dd_iohandle * open_file(struct resolve_context *resolve_ctx, 
+                                     struct event_context *ev,
                                      const char * which, const char **ports,
                                      struct smbcli_options *smb_options)
 {
                                      const char * which, const char **ports,
                                      struct smbcli_options *smb_options)
 {
@@ -375,13 +377,13 @@ static struct dd_iohandle * open_file(struct resolve_context *resolve_ctx,
 
        if (strcmp(which, "if") == 0) {
                path = check_arg_pathname("if");
 
        if (strcmp(which, "if") == 0) {
                path = check_arg_pathname("if");
-               handle = dd_open_path(resolve_ctx, path, ports, 
+               handle = dd_open_path(resolve_ctx, ev, path, ports,
                                      check_arg_numeric("ibs"), options,
                                      smb_options);
        } else if (strcmp(which, "of") == 0) {
                options |= DD_WRITE;
                path = check_arg_pathname("of");
                                      check_arg_numeric("ibs"), options,
                                      smb_options);
        } else if (strcmp(which, "of") == 0) {
                options |= DD_WRITE;
                path = check_arg_pathname("of");
-               handle = dd_open_path(resolve_ctx, path, ports, 
+               handle = dd_open_path(resolve_ctx, ev, path, ports,
                                      check_arg_numeric("obs"), options,
                                      smb_options);
        } else {
                                      check_arg_numeric("obs"), options,
                                      smb_options);
        } else {
@@ -396,7 +398,7 @@ static struct dd_iohandle * open_file(struct resolve_context *resolve_ctx,
        return(handle);
 }
 
        return(handle);
 }
 
-static int copy_files(struct loadparm_context *lp_ctx)
+static int copy_files(struct event_context *ev, struct loadparm_context *lp_ctx)
 {
        uint8_t *       iobuf;  /* IO buffer. */
        uint64_t        iomax;  /* Size of the IO buffer. */
 {
        uint8_t *       iobuf;  /* IO buffer. */
        uint64_t        iomax;  /* Size of the IO buffer. */
@@ -433,12 +435,12 @@ static int copy_files(struct loadparm_context *lp_ctx)
        DEBUG(4, ("IO buffer size is %llu, max xmit is %d\n",
                        (unsigned long long)iomax, options.max_xmit));
 
        DEBUG(4, ("IO buffer size is %llu, max xmit is %d\n",
                        (unsigned long long)iomax, options.max_xmit));
 
-       if (!(ifile = open_file(lp_resolve_context(lp_ctx), "if", 
+       if (!(ifile = open_file(lp_resolve_context(lp_ctx), ev, "if",
                                lp_smb_ports(lp_ctx), &options))) {
                return(FILESYS_EXIT_CODE);
        }
 
                                lp_smb_ports(lp_ctx), &options))) {
                return(FILESYS_EXIT_CODE);
        }
 
-       if (!(ofile = open_file(lp_resolve_context(lp_ctx), "of", 
+       if (!(ofile = open_file(lp_resolve_context(lp_ctx), ev, "of",
                                lp_smb_ports(lp_ctx), &options))) {
                return(FILESYS_EXIT_CODE);
        }
                                lp_smb_ports(lp_ctx), &options))) {
                return(FILESYS_EXIT_CODE);
        }
@@ -528,6 +530,7 @@ int main(int argc, const char ** argv)
 {
        int i;
        const char ** dd_args;
 {
        int i;
        const char ** dd_args;
+       struct event_context *ev;
 
        poptContext pctx;
        struct poptOption poptions[] = {
 
        poptContext pctx;
        struct poptOption poptions[] = {
@@ -578,6 +581,8 @@ int main(int argc, const char ** argv)
                }
        }
 
                }
        }
 
+       ev = event_context_init(talloc_autofree_context());
+
        gensec_init(cmdline_lp_ctx);
        dump_args();
 
        gensec_init(cmdline_lp_ctx);
        dump_args();
 
@@ -599,7 +604,7 @@ int main(int argc, const char ** argv)
 
        CatchSignal(SIGINT, dd_handle_signal);
        CatchSignal(SIGUSR1, dd_handle_signal);
 
        CatchSignal(SIGINT, dd_handle_signal);
        CatchSignal(SIGUSR1, dd_handle_signal);
-       return(copy_files(cmdline_lp_ctx));
+       return(copy_files(ev, cmdline_lp_ctx));
 }
 
 /* vim: set sw=8 sts=8 ts=8 tw=79 : */
 }
 
 /* vim: set sw=8 sts=8 ts=8 tw=79 : */
index 810c882ea9afb4502378c0eb2d5c386050fcb13c..21a4ad488222048da96c650a219b3ab6533fb7e1 100644 (file)
@@ -89,8 +89,10 @@ struct dd_iohandle
 #define DD_OPLOCK              0x00000008
 
 struct smbcli_options;
 #define DD_OPLOCK              0x00000008
 
 struct smbcli_options;
+struct event_context;
 
 struct dd_iohandle * dd_open_path(struct resolve_context *resolve_ctx, 
 
 struct dd_iohandle * dd_open_path(struct resolve_context *resolve_ctx, 
+                                 struct event_context *ev,
                                  const char * path,
                                  const char **ports,
                                uint64_t io_size, int options, 
                                  const char * path,
                                  const char **ports,
                                uint64_t io_size, int options, 
index 7028e8507887e8a97d57a04fd9f74cbe528d579f..4297c300121ef6c4f57b379caa9005975619efb8 100644 (file)
@@ -221,6 +221,7 @@ static bool smb_write_func(void * handle, uint8_t * buf, uint64_t wanted,
 }
 
 static struct smbcli_state * init_smb_session(struct resolve_context *resolve_ctx,
 }
 
 static struct smbcli_state * init_smb_session(struct resolve_context *resolve_ctx,
+                                             struct event_context *ev,
                                              const char * host,
                                              const char **ports,
                                              const char * share,
                                              const char * host,
                                              const char **ports,
                                              const char * share,
@@ -233,8 +234,9 @@ static struct smbcli_state * init_smb_session(struct resolve_context *resolve_ct
         * each connection, but for now, we just use the same one for both.
         */
        ret = smbcli_full_connection(NULL, &cli, host, ports, share,
         * each connection, but for now, we just use the same one for both.
         */
        ret = smbcli_full_connection(NULL, &cli, host, ports, share,
-                        NULL /* devtype */, cmdline_credentials, resolve_ctx, 
-                        NULL /* events */, options);
+                                    NULL /* devtype */,
+                                    cmdline_credentials, resolve_ctx,
+                                    ev, options);
 
        if (!NT_STATUS_IS_OK(ret)) {
                fprintf(stderr, "%s: connecting to //%s/%s: %s\n",
 
        if (!NT_STATUS_IS_OK(ret)) {
                fprintf(stderr, "%s: connecting to //%s/%s: %s\n",
@@ -293,6 +295,7 @@ static int open_smb_file(struct smbcli_state * cli,
 }
 
 static struct dd_iohandle * open_cifs_handle(struct resolve_context *resolve_ctx,
 }
 
 static struct dd_iohandle * open_cifs_handle(struct resolve_context *resolve_ctx,
+                                            struct event_context *ev,
                                             const char * host,
                                        const char **ports,
                                        const char * share,
                                             const char * host,
                                        const char **ports,
                                        const char * share,
@@ -319,7 +322,7 @@ static struct dd_iohandle * open_cifs_handle(struct resolve_context *resolve_ctx
        smbh->h.io_write = smb_write_func;
        smbh->h.io_seek = smb_seek_func;
 
        smbh->h.io_write = smb_write_func;
        smbh->h.io_seek = smb_seek_func;
 
-       if ((smbh->cli = init_smb_session(resolve_ctx, host, ports, share,
+       if ((smbh->cli = init_smb_session(resolve_ctx, ev, host, ports, share,
                                          smb_options)) == NULL) {
                return(NULL);
        }
                                          smb_options)) == NULL) {
                return(NULL);
        }
@@ -336,6 +339,7 @@ static struct dd_iohandle * open_cifs_handle(struct resolve_context *resolve_ctx
 /* ------------------------------------------------------------------------- */
 
 struct dd_iohandle * dd_open_path(struct resolve_context *resolve_ctx, 
 /* ------------------------------------------------------------------------- */
 
 struct dd_iohandle * dd_open_path(struct resolve_context *resolve_ctx, 
+                                 struct event_context *ev,
                                  const char * path,
                                  const char **ports,
                                uint64_t io_size,
                                  const char * path,
                                  const char **ports,
                                uint64_t io_size,
@@ -355,7 +359,7 @@ struct dd_iohandle * dd_open_path(struct resolve_context *resolve_ctx,
                        /* Skip over leading directory separators. */
                        while (*remain == '/' || *remain == '\\') { remain++; }
 
                        /* Skip over leading directory separators. */
                        while (*remain == '/' || *remain == '\\') { remain++; }
 
-                       return(open_cifs_handle(resolve_ctx, host, ports, 
+                       return(open_cifs_handle(resolve_ctx, ev, host, ports,
                                                share, remain,
                                                io_size, options, smb_options));
                }
                                                share, remain,
                                                io_size, options, smb_options));
                }
index ef88913c4d27c68a470b4dcf14760135b17fd153..79cc1b53820a4512f37147a15de5fbd78f217d88 100644 (file)
@@ -2546,7 +2546,9 @@ static void display_share_result(struct srvsvc_NetShareCtr1 *ctr1)
 /****************************************************************************
 try and browse available shares on a host
 ****************************************************************************/
 /****************************************************************************
 try and browse available shares on a host
 ****************************************************************************/
-static bool browse_host(struct loadparm_context *lp_ctx, const char *query_host)
+static bool browse_host(struct loadparm_context *lp_ctx,
+                       struct event_context *ev_ctx,
+                       const char *query_host)
 {
        struct dcerpc_pipe *p;
        char *binding;
 {
        struct dcerpc_pipe *p;
        char *binding;
@@ -2560,7 +2562,7 @@ static bool browse_host(struct loadparm_context *lp_ctx, const char *query_host)
 
        status = dcerpc_pipe_connect(mem_ctx, &p, binding, 
                                         &ndr_table_srvsvc,
 
        status = dcerpc_pipe_connect(mem_ctx, &p, binding, 
                                         &ndr_table_srvsvc,
-                                    cmdline_credentials, NULL,
+                                    cmdline_credentials, ev_ctx,
                                     lp_ctx);
        if (!NT_STATUS_IS_OK(status)) {
                d_printf("Failed to connect to %s - %s\n", 
                                     lp_ctx);
        if (!NT_STATUS_IS_OK(status)) {
                d_printf("Failed to connect to %s - %s\n", 
@@ -3022,6 +3024,7 @@ static int process_stdin(struct smbclient_context *ctx)
 return a connection to a server
 *******************************************************/
 static bool do_connect(struct smbclient_context *ctx, 
 return a connection to a server
 *******************************************************/
 static bool do_connect(struct smbclient_context *ctx, 
+                      struct event_context *ev_ctx,
                       struct resolve_context *resolve_ctx,
                       const char *specified_server, const char **ports, 
                       const char *specified_share, 
                       struct resolve_context *resolve_ctx,
                       const char *specified_server, const char **ports, 
                       const char *specified_share, 
@@ -3045,8 +3048,7 @@ static bool do_connect(struct smbclient_context *ctx,
        
        status = smbcli_full_connection(ctx, &ctx->cli, server, ports,
                                        share, NULL, cred, resolve_ctx, 
        
        status = smbcli_full_connection(ctx, &ctx->cli, server, ports,
                                        share, NULL, cred, resolve_ctx, 
-                                       event_context_init(NULL),
-                                       options);
+                                       ev_ctx, options);
        if (!NT_STATUS_IS_OK(status)) {
                d_printf("Connection to \\\\%s\\%s failed - %s\n", 
                         server, share, nt_errstr(status));
        if (!NT_STATUS_IS_OK(status)) {
                d_printf("Connection to \\\\%s\\%s failed - %s\n", 
                         server, share, nt_errstr(status));
@@ -3060,9 +3062,12 @@ static bool do_connect(struct smbclient_context *ctx,
 /****************************************************************************
 handle a -L query
 ****************************************************************************/
 /****************************************************************************
 handle a -L query
 ****************************************************************************/
-static int do_host_query(struct loadparm_context *lp_ctx, const char *query_host, const char *workgroup)
+static int do_host_query(struct loadparm_context *lp_ctx,
+                        struct event_context *ev_ctx,
+                        const char *query_host,
+                        const char *workgroup)
 {
 {
-       browse_host(lp_ctx, query_host);
+       browse_host(lp_ctx, ev_ctx, query_host);
        list_servers(workgroup);
        return(0);
 }
        list_servers(workgroup);
        return(0);
 }
@@ -3071,7 +3076,12 @@ static int do_host_query(struct loadparm_context *lp_ctx, const char *query_host
 /****************************************************************************
 handle a message operation
 ****************************************************************************/
 /****************************************************************************
 handle a message operation
 ****************************************************************************/
-static int do_message_op(const char *netbios_name, const char *desthost, const char **destports, const char *destip, int name_type, struct resolve_context *resolve_ctx, struct smbcli_options *options)
+static int do_message_op(const char *netbios_name, const char *desthost,
+                        const char **destports, const char *destip,
+                        int name_type,
+                        struct event_context *ev_ctx,
+                        struct resolve_context *resolve_ctx,
+                        struct smbcli_options *options)
 {
        struct nbt_name called, calling;
        const char *server_name;
 {
        struct nbt_name called, calling;
        const char *server_name;
@@ -3083,7 +3093,9 @@ static int do_message_op(const char *netbios_name, const char *desthost, const c
 
        server_name = destip ? destip : desthost;
 
 
        server_name = destip ? destip : desthost;
 
-       if (!(cli=smbcli_state_init(NULL)) || !smbcli_socket_connect(cli, server_name, destports, resolve_ctx, options)) {
+       if (!(cli = smbcli_state_init(NULL)) ||
+           !smbcli_socket_connect(cli, server_name, destports,
+                                  ev_ctx, resolve_ctx, options)) {
                d_printf("Connection to %s failed\n", server_name);
                return 1;
        }
                d_printf("Connection to %s failed\n", server_name);
                return 1;
        }
@@ -3124,6 +3136,7 @@ static int do_message_op(const char *netbios_name, const char *desthost, const c
        int rc = 0;
        int name_type = 0x20;
        TALLOC_CTX *mem_ctx;
        int rc = 0;
        int name_type = 0x20;
        TALLOC_CTX *mem_ctx;
+       struct event_context *ev_ctx;
        struct smbclient_context *ctx;
        const char *cmdstr = NULL;
        struct smbcli_options smb_options;
        struct smbclient_context *ctx;
        const char *cmdstr = NULL;
        struct smbcli_options smb_options;
@@ -3221,6 +3234,8 @@ static int do_message_op(const char *netbios_name, const char *desthost, const c
 
        lp_smbcli_options(cmdline_lp_ctx, &smb_options);
 
 
        lp_smbcli_options(cmdline_lp_ctx, &smb_options);
 
+       ev_ctx = event_context_init(talloc_autofree_context());
+
        DEBUG( 3, ( "Client started (version %s).\n", SAMBA_VERSION_STRING ) );
 
        if (query_host && (p=strchr_m(query_host,'#'))) {
        DEBUG( 3, ( "Client started (version %s).\n", SAMBA_VERSION_STRING ) );
 
        if (query_host && (p=strchr_m(query_host,'#'))) {
@@ -3230,14 +3245,23 @@ static int do_message_op(const char *netbios_name, const char *desthost, const c
        }
   
        if (query_host) {
        }
   
        if (query_host) {
-               return do_host_query(cmdline_lp_ctx, query_host, lp_workgroup(cmdline_lp_ctx));
+               rc = do_host_query(cmdline_lp_ctx, ev_ctx, query_host,
+                                  lp_workgroup(cmdline_lp_ctx));
+               return rc;
        }
 
        if (message) {
        }
 
        if (message) {
-               return do_message_op(lp_netbios_name(cmdline_lp_ctx), desthost, lp_smb_ports(cmdline_lp_ctx), dest_ip, name_type, lp_resolve_context(cmdline_lp_ctx), &smb_options);
+               rc = do_message_op(lp_netbios_name(cmdline_lp_ctx), desthost,
+                                  lp_smb_ports(cmdline_lp_ctx), dest_ip,
+                                  name_type, ev_ctx,
+                                  lp_resolve_context(cmdline_lp_ctx),
+                                  &smb_options);
+               return rc;
        }
        
        }
        
-       if (!do_connect(ctx, lp_resolve_context(cmdline_lp_ctx), desthost, lp_smb_ports(cmdline_lp_ctx), service, cmdline_credentials, &smb_options))
+       if (!do_connect(ctx, ev_ctx, lp_resolve_context(cmdline_lp_ctx),
+                       desthost, lp_smb_ports(cmdline_lp_ctx), service,
+                       cmdline_credentials, &smb_options))
                return 1;
 
        if (base_directory) 
                return 1;
 
        if (base_directory) 
index 568aadc31e1f1e6c3c2398cd8216860b950e2c07..252af4443d0a1d0d4f45a21296d2072e6c25e16e 100644 (file)
@@ -207,6 +207,8 @@ struct event_context *event_context_init_byname(TALLOC_CTX *mem_ctx, const char
 */
 struct event_context *event_context_init(TALLOC_CTX *mem_ctx)
 {
 */
 struct event_context *event_context_init(TALLOC_CTX *mem_ctx)
 {
+       DEBUG(0, ("New event context requested. Parent: [%s:%p]\n",
+                 mem_ctx?talloc_get_name(mem_ctx):"NULL", mem_ctx));
        return event_context_init_byname(mem_ctx, NULL);
 }
 
        return event_context_init_byname(mem_ctx, NULL);
 }
 
index 79958a86eba121d6f7dc5dc9bfde6ea806757c18..6b50b2f5eba73a050f243d6d745c078a66a7cfb1 100644 (file)
@@ -737,6 +737,7 @@ static int ildb_connect(struct ldb_context *ldb, const char *url,
        struct ildb_private *ildb;
        NTSTATUS status;
        struct cli_credentials *creds;
        struct ildb_private *ildb;
        NTSTATUS status;
        struct cli_credentials *creds;
+       struct event_context *event_ctx;
 
        module = talloc(ldb, struct ldb_module);
        if (!module) {
 
        module = talloc(ldb, struct ldb_module);
        if (!module) {
@@ -756,8 +757,19 @@ static int ildb_connect(struct ldb_context *ldb, const char *url,
        }
        module->private_data    = ildb;
        ildb->module            = module;
        }
        module->private_data    = ildb;
        ildb->module            = module;
-       ildb->ldap = ldap4_new_connection(ildb, ldb_get_opaque(ldb, "loadparm"), 
-                                         ldb_get_opaque(ldb, "EventContext"));
+
+       event_ctx = ldb_get_opaque(ldb, "EventContext");
+
+       /* FIXME: We must make the event context an explicit parameter, but we
+        * need to build the events library separately first. Hack a new event
+        * context so that CMD line utilities work until we have libevents for
+        * standalone builds ready */
+       if (event_ctx == NULL) {
+               event_ctx = event_context_init(NULL);
+       }
+
+       ildb->ldap = ldap4_new_connection(ildb, ldb_get_opaque(ldb, "loadparm"),
+                                         event_ctx);
        if (!ildb->ldap) {
                ldb_oom(ldb);
                goto failed;
        if (!ildb->ldap) {
                ldb_oom(ldb);
                goto failed;
index b71adcbca27dbb7cc0ecc25f04ae3b1174ec4f0f..b564976524f940870c2cec58c10e493885cf498e 100644 (file)
@@ -116,7 +116,7 @@ struct ldb_context *ldb_wrap_connect(TALLOC_CTX *mem_ctx,
                            talloc_asprintf(ldb, "%s/ldb", lp_modulesdir(lp_ctx)));
 
        if (ev == NULL) {
                            talloc_asprintf(ldb, "%s/ldb", lp_modulesdir(lp_ctx)));
 
        if (ev == NULL) {
-               ev = event_context_find(mem_ctx);
+               return NULL;
        }
 
        if (ldb_set_opaque(ldb, "EventContext", ev)) {
        }
 
        if (ldb_set_opaque(ldb, "EventContext", ev)) {
index 29d6e002477bc1376e5b1d004f88a765a4cb8bbe..19284461ee4d11649ca2d6cbd57e0773cbbbab8e 100644 (file)
@@ -544,6 +544,10 @@ struct messaging_context *messaging_init(TALLOC_CTX *mem_ctx,
        NTSTATUS status;
        struct socket_address *path;
 
        NTSTATUS status;
        struct socket_address *path;
 
+       if (ev == NULL) {
+               return NULL;
+       }
+
        msg = talloc_zero(mem_ctx, struct messaging_context);
        if (msg == NULL) {
                return NULL;
        msg = talloc_zero(mem_ctx, struct messaging_context);
        if (msg == NULL) {
                return NULL;
@@ -556,10 +560,6 @@ struct messaging_context *messaging_init(TALLOC_CTX *mem_ctx,
                return NULL;
        }
 
                return NULL;
        }
 
-       if (ev == NULL) {
-               ev = event_context_init(msg);
-       }
-
        /* create the messaging directory if needed */
        mkdir(dir, 0700);
 
        /* create the messaging directory if needed */
        mkdir(dir, 0700);
 
index 813412c7bc83bb8eddc23859dbea17f7019dc5c0..2c25d8f491191f9533bb907b72cfe2c157bbd5b2 100644 (file)
@@ -124,7 +124,7 @@ static bool test_tcp(struct torture_context *tctx)
        DATA_BLOB blob, blob2;
        size_t sent, nread;
        TALLOC_CTX *mem_ctx = tctx;
        DATA_BLOB blob, blob2;
        size_t sent, nread;
        TALLOC_CTX *mem_ctx = tctx;
-       struct event_context *ev = event_context_init(mem_ctx);
+       struct event_context *ev = tctx->ev;
        struct interface *ifaces;
 
        status = socket_create("ip", SOCKET_TYPE_STREAM, &sock1, 0);
        struct interface *ifaces;
 
        status = socket_create("ip", SOCKET_TYPE_STREAM, &sock1, 0);
index d9910285d941058a70b3058477981d284371e184..614bd51d2af928085d7505402c0b4a77efb56fdd 100644 (file)
@@ -250,11 +250,7 @@ struct cldap_socket *cldap_socket_init(TALLOC_CTX *mem_ctx,
        cldap = talloc(mem_ctx, struct cldap_socket);
        if (cldap == NULL) goto failed;
 
        cldap = talloc(mem_ctx, struct cldap_socket);
        if (cldap == NULL) goto failed;
 
-       if (event_ctx == NULL) {
-               cldap->event_ctx = event_context_init(cldap);
-       } else {
-               cldap->event_ctx = talloc_reference(cldap, event_ctx);
-       }
+       cldap->event_ctx = talloc_reference(cldap, event_ctx);
        if (cldap->event_ctx == NULL) goto failed;
 
        cldap->idr = idr_init(cldap);
        if (cldap->event_ctx == NULL) goto failed;
 
        cldap->idr = idr_init(cldap);
index 4858a96110b7a46df9b3e99e88edeacdbcad7560..c20a7fd9353f9572f804c394463bbe939aaebbb9 100644 (file)
 */
 bool smbcli_socket_connect(struct smbcli_state *cli, const char *server, 
                           const char **ports, 
 */
 bool smbcli_socket_connect(struct smbcli_state *cli, const char *server, 
                           const char **ports, 
+                          struct event_context *ev_ctx,
                           struct resolve_context *resolve_ctx,
                           struct smbcli_options *options)
 {
        struct smbcli_socket *sock;
 
                           struct resolve_context *resolve_ctx,
                           struct smbcli_options *options)
 {
        struct smbcli_socket *sock;
 
-       sock = smbcli_sock_connect_byname(server, ports, NULL, resolve_ctx, 
-                                         NULL);
+       sock = smbcli_sock_connect_byname(server, ports, NULL,
+                                         resolve_ctx, ev_ctx);
 
        if (sock == NULL) return false;
        
 
        if (sock == NULL) return false;
        
index 26169e7838949aae14c88472cc9d86539d914c39..966f56cba8235b41a41826b78556a7778cab8ce8 100644 (file)
@@ -42,7 +42,11 @@ _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 = talloc_zero(mem_ctx, struct composite_context);
        if (!c) return NULL;
        c->state = COMPOSITE_STATE_IN_PROGRESS;
-       c->event_ctx = ev;
+       c->event_ctx = talloc_reference(c, ev);
+       if (!c->event_ctx) {
+               talloc_free(c);
+               return NULL;
+       }
 
        return c;
 }
 
        return c;
 }
index 130d8ae870949df276fca6d4a419ac32ed0bc1f8..06b7bd57714bab1415dd379121a3f4b6d03a6021 100644 (file)
@@ -167,11 +167,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 = talloc(mem_ctx, struct nbt_dgram_socket);
        if (dgmsock == NULL) goto failed;
 
-       if (event_ctx == NULL) {
-               dgmsock->event_ctx = event_context_init(dgmsock);
-       } else {
-               dgmsock->event_ctx = talloc_reference(dgmsock, event_ctx);
-       }
+       dgmsock->event_ctx = talloc_reference(dgmsock, event_ctx);
        if (dgmsock->event_ctx == NULL) goto failed;
 
        status = socket_create("ip", SOCKET_TYPE_DGRAM, &dgmsock->sock, 0);
        if (dgmsock->event_ctx == NULL) goto failed;
 
        status = socket_create("ip", SOCKET_TYPE_DGRAM, &dgmsock->sock, 0);
index 2c04edf9505ba5150de6bf3ebb5b49c075493ca0..e1569e72963b0a869294bca2a1e9fccba05039c1 100644 (file)
@@ -200,7 +200,7 @@ static struct ldap_message *new_ldap_sasl_bind_msg(struct ldap_connection *conn,
 /*
   perform a sasl bind using the given credentials
 */
 /*
   perform a sasl bind using the given credentials
 */
-_PUBLIC_ NTSTATUS ldap_bind_sasl(struct ldap_connection *conn, 
+_PUBLIC_ NTSTATUS ldap_bind_sasl(struct ldap_connection *conn,
                        struct cli_credentials *creds,
                        struct loadparm_context *lp_ctx)
 {
                        struct cli_credentials *creds,
                        struct loadparm_context *lp_ctx)
 {
@@ -223,7 +223,8 @@ _PUBLIC_ NTSTATUS ldap_bind_sasl(struct ldap_connection *conn,
 
        gensec_init(lp_ctx);
 
 
        gensec_init(lp_ctx);
 
-       status = gensec_client_start(conn, &conn->gensec, NULL, lp_ctx);
+       status = gensec_client_start(conn, &conn->gensec,
+                                    conn->event.event_ctx, lp_ctx);
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(0, ("Failed to start GENSEC engine (%s)\n", nt_errstr(status)));
                goto failed;
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(0, ("Failed to start GENSEC engine (%s)\n", nt_errstr(status)));
                goto failed;
index 296a7b11f26905672a612454857e0fba4195e886..bca867b0332694db9720297a14a8afccd9cb5dd9 100644 (file)
@@ -48,17 +48,13 @@ _PUBLIC_ struct ldap_connection *ldap4_new_connection(TALLOC_CTX *mem_ctx,
 {
        struct ldap_connection *conn;
 
 {
        struct ldap_connection *conn;
 
-       conn = talloc_zero(mem_ctx, struct ldap_connection);
-       if (conn == NULL) {
+       if (ev == NULL) {
                return NULL;
        }
 
                return NULL;
        }
 
-       if (ev == NULL) {
-               ev = event_context_init(conn);
-               if (ev == NULL) {
-                       talloc_free(conn);
-                       return NULL;
-               }
+       conn = talloc_zero(mem_ctx, struct ldap_connection);
+       if (conn == NULL) {
+               return NULL;
        }
 
        conn->next_messageid  = 1;
        }
 
        conn->next_messageid  = 1;
index 747127980ab14ead0336bfc0e5323e03c7a9a978..5d4611e2d95a32c508d3dd0b676889ec6f667906 100644 (file)
@@ -318,11 +318,7 @@ _PUBLIC_ struct nbt_name_socket *nbt_name_socket_init(TALLOC_CTX *mem_ctx,
        nbtsock = talloc(mem_ctx, struct nbt_name_socket);
        if (nbtsock == NULL) goto failed;
 
        nbtsock = talloc(mem_ctx, struct nbt_name_socket);
        if (nbtsock == NULL) goto failed;
 
-       if (event_ctx == NULL) {
-               nbtsock->event_ctx = event_context_init(nbtsock);
-       } else {
-               nbtsock->event_ctx = talloc_reference(nbtsock, event_ctx);
-       }
+       nbtsock->event_ctx = talloc_reference(nbtsock, event_ctx);
        if (nbtsock->event_ctx == NULL) goto failed;
 
        status = socket_create("ip", SOCKET_TYPE_DGRAM, &nbtsock->sock, 0);
        if (nbtsock->event_ctx == NULL) goto failed;
 
        status = socket_create("ip", SOCKET_TYPE_DGRAM, &nbtsock->sock, 0);
index 1dcf2d1c539151a302e7ea0d5de80549ecfd2d77..49838e8a1c1f1e41743f4ee11daf3ea7ceb6bf7f 100644 (file)
@@ -59,12 +59,7 @@ struct composite_context *smbcli_sock_connect_send(TALLOC_CTX *mem_ctx,
        if (result == NULL) goto failed;
        result->state = COMPOSITE_STATE_IN_PROGRESS;
 
        if (result == NULL) goto failed;
        result->state = COMPOSITE_STATE_IN_PROGRESS;
 
-       if (event_ctx != NULL) {
-               result->event_ctx = talloc_reference(result, event_ctx);
-       } else {
-               result->event_ctx = event_context_init(result);
-       }
-
+       result->event_ctx = talloc_reference(result, event_ctx);
        if (result->event_ctx == NULL) goto failed;
 
        state = talloc(result, struct sock_connect_state);
        if (result->event_ctx == NULL) goto failed;
 
        state = talloc(result, struct sock_connect_state);
@@ -202,6 +197,11 @@ _PUBLIC_ struct smbcli_socket *smbcli_sock_connect_byname(const char *host, cons
        TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx);
        struct smbcli_socket *result;
 
        TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx);
        struct smbcli_socket *result;
 
+       if (event_ctx == NULL) {
+               DEBUG(0, ("Invalid NULL event context passed in as parameter\n"));
+               return NULL;
+       }
+
        if (tmp_ctx == NULL) {
                DEBUG(0, ("talloc_new failed\n"));
                return NULL;
        if (tmp_ctx == NULL) {
                DEBUG(0, ("talloc_new failed\n"));
                return NULL;
@@ -214,16 +214,6 @@ _PUBLIC_ struct smbcli_socket *smbcli_sock_connect_byname(const char *host, cons
                return NULL;
        }
 
                return NULL;
        }
 
-       if (event_ctx == NULL) {
-               event_ctx = event_context_init(mem_ctx);
-       }
-
-       if (event_ctx == NULL) {
-               DEBUG(0, ("event_context_init failed\n"));
-               talloc_free(tmp_ctx);
-               return NULL;
-       }
-
        /* allow hostnames of the form NAME#xx and do a netbios lookup */
        if ((p = strchr(name, '#'))) {
                name_type = strtol(p+1, NULL, 16);
        /* allow hostnames of the form NAME#xx and do a netbios lookup */
        if ((p = strchr(name, '#'))) {
                name_type = strtol(p+1, NULL, 16);
index 4b8f3f955388e83d93b83df6de02915106873add..1a695432eecbd2b3b13932bec3f69d2a700b8bde 100644 (file)
@@ -135,7 +135,6 @@ struct composite_context *resolve_name_host_send(TALLOC_CTX *mem_ctx,
        c = composite_create(mem_ctx, event_ctx);
        if (c == NULL) return NULL;
 
        c = composite_create(mem_ctx, event_ctx);
        if (c == NULL) return NULL;
 
-       c->event_ctx = talloc_reference(c, event_ctx);
        if (composite_nomem(c->event_ctx, c)) return c;
 
        state = talloc(c, struct host_state);
        if (composite_nomem(c->event_ctx, c)) return c;
 
        state = talloc(c, struct host_state);
index 887bdd7ecf7376568c5d32b5e95d453c7fb9164f..8f085c5404078a16ef0c6742d800373b5ef3d864 100644 (file)
@@ -110,10 +110,9 @@ struct composite_context *resolve_name_nbtlist_send(TALLOC_CTX *mem_ctx,
        struct nbtlist_state *state;
        int i;
 
        struct nbtlist_state *state;
        int i;
 
-       c = composite_create(event_ctx, event_ctx);
+       c = composite_create(mem_ctx, event_ctx);
        if (c == NULL) return NULL;
 
        if (c == NULL) return NULL;
 
-       c->event_ctx = talloc_reference(c, event_ctx);
        if (composite_nomem(c->event_ctx, c)) return c;
 
        state = talloc(c, struct nbtlist_state);
        if (composite_nomem(c->event_ctx, c)) return c;
 
        state = talloc(c, struct nbtlist_state);
index 33ace094432a261726926cbaf30fb4c3220d172e..aaf9ff1f8db2ecf108beb8ecb00d3481b51f686a 100644 (file)
@@ -136,19 +136,14 @@ struct composite_context *resolve_name_send(struct resolve_context *ctx,
        struct composite_context *c;
        struct resolve_state *state;
 
        struct composite_context *c;
        struct resolve_state *state;
 
-       c = composite_create(event_ctx, event_ctx);
-       if (c == NULL) return NULL;
-
-       if (ctx == NULL) {
+       if (ctx == NULL || event_ctx == NULL) {
                composite_error(c, NT_STATUS_INVALID_PARAMETER);
                return c;
        }
 
                composite_error(c, NT_STATUS_INVALID_PARAMETER);
                return c;
        }
 
-       if (event_ctx == NULL) {
-               c->event_ctx = event_context_init(c);
-       } else {
-               c->event_ctx = talloc_reference(c, event_ctx);
-       }
+       c = composite_create(ctx, event_ctx);
+       if (c == NULL) return NULL;
+
        if (composite_nomem(c->event_ctx, c)) return c;
 
        state = talloc(c, struct resolve_state);
        if (composite_nomem(c->event_ctx, c)) return c;
 
        state = talloc(c, struct resolve_state);
index c44c62f86899f877db5178b82c60d838c0c3894b..c4abfa5e370133763d8ee3da765417cbb9456c80 100644 (file)
@@ -451,17 +451,15 @@ 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 = talloc_zero(mem_ctx, struct composite_context);
        if (c == NULL) goto failed;
 
+       c->event_ctx = talloc_reference(c, event_ctx);
+       if (c->event_ctx == NULL) goto failed;
+
        state = talloc_zero(c, struct connect_state);
        if (state == NULL) goto failed;
 
        state = talloc_zero(c, struct connect_state);
        if (state == NULL) goto failed;
 
-       if (event_ctx == NULL) {
-               event_ctx = event_context_init(mem_ctx);
-       }
-
        state->io = io;
 
        c->state = COMPOSITE_STATE_IN_PROGRESS;
        state->io = io;
 
        c->state = COMPOSITE_STATE_IN_PROGRESS;
-       c->event_ctx = talloc_reference(c, event_ctx);
        c->private_data = state;
 
        state->stage = CONNECT_RESOLVE;
        c->private_data = state;
 
        state->stage = CONNECT_RESOLVE;
index d8d7481270fbb573367e2fc8c49a171dc2c76fde..9cd02a51f457b5f45299b2147418b0e52ac428fd 100644 (file)
@@ -62,7 +62,6 @@ static NTSTATUS fetchfile_connect(struct composite_context *c,
        state->creq->async.fn = fetchfile_composite_handler;
 
        state->stage = FETCHFILE_READ;
        state->creq->async.fn = fetchfile_composite_handler;
 
        state->stage = FETCHFILE_READ;
-       c->event_ctx = talloc_reference(c, state->creq->event_ctx);
 
        return NT_STATUS_OK;
 }
 
        return NT_STATUS_OK;
 }
@@ -158,7 +157,6 @@ struct composite_context *smb_composite_fetchfile_send(struct smb_composite_fetc
 
        c->state = COMPOSITE_STATE_IN_PROGRESS;
        state->stage = FETCHFILE_CONNECT;
 
        c->state = COMPOSITE_STATE_IN_PROGRESS;
        state->stage = FETCHFILE_CONNECT;
-       c->event_ctx = talloc_reference(c, state->creq->event_ctx);
        c->private_data = state;
 
        return c;
        c->private_data = state;
 
        return c;
index 2ec13df9b6bf79edf87e363fa8675d83fcdcd647..270d71f5185be629951f6e1ca588010e6971a054 100644 (file)
@@ -52,7 +52,6 @@ static NTSTATUS fsinfo_connect(struct composite_context *c,
        state->req->async.fn = fsinfo_raw_handler;
 
        state->stage = FSINFO_QUERY;
        state->req->async.fn = fsinfo_raw_handler;
 
        state->stage = FSINFO_QUERY;
-       c->event_ctx = talloc_reference(c, state->req->session->transport->socket->event.ctx);
 
        return NT_STATUS_OK;
 }
 
        return NT_STATUS_OK;
 }
@@ -158,7 +157,6 @@ struct composite_context *smb_composite_fsinfo_send(struct smbcli_tree *tree,
 
        c->state = COMPOSITE_STATE_IN_PROGRESS;
        state->stage = FSINFO_CONNECT;
 
        c->state = COMPOSITE_STATE_IN_PROGRESS;
        state->stage = FSINFO_CONNECT;
-       c->event_ctx = talloc_reference(c, tree->session->transport->socket->event.ctx);
        c->private_data = state;
 
        state->creq = smb_composite_connect_send(state->connect, state,
        c->private_data = state;
 
        state->creq = smb_composite_connect_send(state->connect, state,
index 3e7793c0c7113750ad31765e518aed8d878b548e..0a4e52bd7baff71c912d89262516cb6458cf8e2e 100644 (file)
@@ -172,11 +172,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 = talloc_zero(mem_ctx, struct wrepl_socket);
        if (!wrepl_socket) return NULL;
 
-       if (event_ctx == NULL) {
-               wrepl_socket->event.ctx = event_context_init(wrepl_socket);
-       } else {
-               wrepl_socket->event.ctx = talloc_reference(wrepl_socket, event_ctx);
-       }
+       wrepl_socket->event.ctx = talloc_reference(wrepl_socket, event_ctx);
        if (!wrepl_socket->event.ctx) goto failed;
 
        wrepl_socket->iconv_convenience = iconv_convenience;
        if (!wrepl_socket->event.ctx) goto failed;
 
        wrepl_socket->iconv_convenience = iconv_convenience;
index dabd23a5bee7594249327f564ec0f4b7e3673fd5..f39d9e039cb5788c95cb94b068d864eff5f5df9d 100644 (file)
@@ -30,7 +30,7 @@
  * 1. Setup a CLDAP socket.
  * 2. Lookup the default Site-Name.
  */
  * 1. Setup a CLDAP socket.
  * 2. Lookup the default Site-Name.
  */
-NTSTATUS libnet_FindSite(TALLOC_CTX *ctx, struct libnet_JoinSite *r)
+NTSTATUS libnet_FindSite(TALLOC_CTX *ctx, struct libnet_context *lctx, struct libnet_JoinSite *r)
 {
        NTSTATUS status;
        TALLOC_CTX *tmp_ctx;
 {
        NTSTATUS status;
        TALLOC_CTX *tmp_ctx;
@@ -55,7 +55,7 @@ NTSTATUS libnet_FindSite(TALLOC_CTX *ctx, struct libnet_JoinSite *r)
        search.in.acct_control = -1;
        search.in.version = 6;
 
        search.in.acct_control = -1;
        search.in.version = 6;
 
-       cldap = cldap_socket_init(tmp_ctx, NULL, lp_iconv_convenience(global_loadparm));
+       cldap = cldap_socket_init(tmp_ctx, lctx->event_ctx, lp_iconv_convenience(global_loadparm));
        status = cldap_netlogon(cldap, tmp_ctx, &search);
        if (!NT_STATUS_IS_OK(status)) {
                /*
        status = cldap_netlogon(cldap, tmp_ctx, &search);
        if (!NT_STATUS_IS_OK(status)) {
                /*
@@ -148,7 +148,7 @@ NTSTATUS libnet_JoinSite(struct libnet_context *ctx,
        }
 
        make_nbt_name_client(&name, libnet_r->out.samr_binding->host);
        }
 
        make_nbt_name_client(&name, libnet_r->out.samr_binding->host);
-       status = resolve_name(lp_resolve_context(ctx->lp_ctx), &name, r, &dest_addr, NULL);
+       status = resolve_name(lp_resolve_context(ctx->lp_ctx), &name, r, &dest_addr, ctx->event_ctx);
        if (!NT_STATUS_IS_OK(status)) {
                libnet_r->out.error_string = NULL;
                talloc_free(tmp_ctx);
        if (!NT_STATUS_IS_OK(status)) {
                libnet_r->out.error_string = NULL;
                talloc_free(tmp_ctx);
@@ -161,7 +161,7 @@ NTSTATUS libnet_JoinSite(struct libnet_context *ctx,
        r->in.domain_dn_str = libnet_r->out.domain_dn_str;
        r->in.cldap_port = lp_cldap_port(ctx->lp_ctx);
 
        r->in.domain_dn_str = libnet_r->out.domain_dn_str;
        r->in.cldap_port = lp_cldap_port(ctx->lp_ctx);
 
-       status = libnet_FindSite(tmp_ctx, r);
+       status = libnet_FindSite(tmp_ctx, ctx, r);
        if (!NT_STATUS_IS_OK(status)) {
                libnet_r->out.error_string =
                        talloc_steal(libnet_r, r->out.error_string);
        if (!NT_STATUS_IS_OK(status)) {
                libnet_r->out.error_string =
                        talloc_steal(libnet_r, r->out.error_string);
index 5e32f6f5bf21ec795cf948e4ca7a3fe9ff7c6a04..4758189d3b38f3cf42d9e1958702ce8d4d2e993b 100644 (file)
@@ -67,22 +67,15 @@ static struct dcerpc_connection *dcerpc_connection_init(TALLOC_CTX *mem_ctx,
                return NULL;
        }
 
                return NULL;
        }
 
-       if (ev == NULL) {
-               ev = event_context_init(c);
-               if (ev == NULL) {
-                       talloc_free(c);
-                       return NULL;
-               }
-       }
-
        c->iconv_convenience = talloc_reference(c, ic);
 
        c->iconv_convenience = talloc_reference(c, ic);
 
-       c->event_ctx = ev;
-       
-       if (!talloc_reference(c, ev)) {
+       c->event_ctx = talloc_reference(c, ev);
+
+       if (c->event_ctx == NULL) {
                talloc_free(c);
                return NULL;
        }
                talloc_free(c);
                return NULL;
        }
+
        c->call_id = 1;
        c->security_state.auth_info = NULL;
        c->security_state.session_key = dcerpc_generic_session_key;
        c->call_id = 1;
        c->security_state.auth_info = NULL;
        c->security_state.session_key = dcerpc_generic_session_key;
index cc7f2ddbaa29b751f00c7667784bc7accbcbce07..a22cad9a4a561bf78687663f6418df96a150e405 100644 (file)
@@ -717,12 +717,6 @@ _PUBLIC_ struct composite_context* dcerpc_pipe_connect_b_send(TALLOC_CTX *parent
        struct pipe_connect_state *s;
        struct event_context *new_ev = NULL;
 
        struct pipe_connect_state *s;
        struct event_context *new_ev = NULL;
 
-       if (ev == NULL) {
-               new_ev = event_context_init(parent_ctx);
-               if (new_ev == NULL) return NULL;
-               ev = new_ev;
-       }
-
        /* composite context allocation and setup */
        c = composite_create(parent_ctx, ev);
        if (c == NULL) {
        /* composite context allocation and setup */
        c = composite_create(parent_ctx, ev);
        if (c == NULL) {
@@ -844,21 +838,12 @@ _PUBLIC_ struct composite_context* dcerpc_pipe_connect_send(TALLOC_CTX *parent_c
        struct pipe_conn_state *s;
        struct dcerpc_binding *b;
        struct composite_context *pipe_conn_req;
        struct pipe_conn_state *s;
        struct dcerpc_binding *b;
        struct composite_context *pipe_conn_req;
-       struct event_context *new_ev = NULL;
-
-       if (ev == NULL) {
-               new_ev = event_context_init(parent_ctx);
-               if (new_ev == NULL) return NULL;
-               ev = new_ev;
-       }
 
        /* composite context allocation and setup */
        c = composite_create(parent_ctx, ev);
        if (c == NULL) {
 
        /* composite context allocation and setup */
        c = composite_create(parent_ctx, ev);
        if (c == NULL) {
-               talloc_free(new_ev);
                return NULL;
        }
                return NULL;
        }
-       talloc_steal(c, new_ev);
 
        s = talloc_zero(c, struct pipe_conn_state);
        if (composite_nomem(s, c)) return c;
 
        s = talloc_zero(c, struct pipe_conn_state);
        if (composite_nomem(s, c)) return c;
index 46270727a4e2797aa90c516e9db53f635b7c0cb3..28e30002e2d5d4461da3fac78abf62f528f3563a 100644 (file)
@@ -1156,7 +1156,8 @@ static WERROR dcesrv_spoolss_RemoteFindFirstPrinterChangeNotifyEx(struct dcesrv_
        creds = cli_credentials_init_anon(mem_ctx); /* FIXME: Use machine credentials instead ? */
 
        status = dcerpc_pipe_connect_b(mem_ctx, &p, binding, &ndr_table_spoolss, 
        creds = cli_credentials_init_anon(mem_ctx); /* FIXME: Use machine credentials instead ? */
 
        status = dcerpc_pipe_connect_b(mem_ctx, &p, binding, &ndr_table_spoolss, 
-                                 creds, NULL, dce_call->conn->dce_ctx->lp_ctx);
+                                      creds, dce_call->event_ctx,
+                                      dce_call->conn->dce_ctx->lp_ctx);
 
        if (NT_STATUS_IS_ERR(status)) {
                DEBUG(0, ("unable to call back to %s\n", r->in.str));
 
        if (NT_STATUS_IS_ERR(status)) {
                DEBUG(0, ("unable to call back to %s\n", r->in.str));
index 917a24ad598b6379c29136918979d3d38109b7b2..739a048d29a790a8ce5c50b6c168e47fba0fd493 100644 (file)
@@ -33,7 +33,8 @@ static bool torture_ntlmssp_self_check(struct torture_context *tctx)
        TALLOC_CTX *mem_ctx = tctx;
 
        torture_assert_ntstatus_ok(tctx, 
        TALLOC_CTX *mem_ctx = tctx;
 
        torture_assert_ntstatus_ok(tctx, 
-               gensec_client_start(mem_ctx, &gensec_security, NULL, tctx->lp_ctx),
+               gensec_client_start(mem_ctx, &gensec_security,
+                                   tctx->ev, tctx->lp_ctx),
                "gensec client start");
 
        gensec_set_credentials(gensec_security, cmdline_credentials);
                "gensec client start");
 
        gensec_set_credentials(gensec_security, cmdline_credentials);
@@ -87,7 +88,8 @@ static bool torture_ntlmssp_self_check(struct torture_context *tctx)
        talloc_free(gensec_security);
 
        torture_assert_ntstatus_ok(tctx, 
        talloc_free(gensec_security);
 
        torture_assert_ntstatus_ok(tctx, 
-               gensec_client_start(mem_ctx, &gensec_security, NULL, tctx->lp_ctx),
+               gensec_client_start(mem_ctx, &gensec_security,
+                                   tctx->ev, tctx->lp_ctx),
                "Failed to start GENSEC for NTLMSSP");
 
        gensec_set_credentials(gensec_security, cmdline_credentials);
                "Failed to start GENSEC for NTLMSSP");
 
        gensec_set_credentials(gensec_security, cmdline_credentials);
index 3a3a7c2fd5998ce028b2bdd92f18ee6a11eb90ca..966d436935ba57fe1ed333cb6b1bc97ff14dc665 100644 (file)
@@ -55,7 +55,8 @@ static struct smbcli_state *open_nbt_connection(struct torture_context *tctx)
 
        lp_smbcli_options(tctx->lp_ctx, &options);
 
 
        lp_smbcli_options(tctx->lp_ctx, &options);
 
-       if (!smbcli_socket_connect(cli, host, lp_smb_ports(tctx->lp_ctx), lp_resolve_context(tctx->lp_ctx), &options)) {
+       if (!smbcli_socket_connect(cli, host, lp_smb_ports(tctx->lp_ctx), tctx->ev,
+                                  lp_resolve_context(tctx->lp_ctx), &options)) {
                torture_comment(tctx, "Failed to connect with %s\n", host);
                goto failed;
        }
                torture_comment(tctx, "Failed to connect with %s\n", host);
                goto failed;
        }
index 6d872c687b8ec4ad04a12e353721046a3f31d1d1..ae18fe809c93e55753b52ad8ac2a34408a3c8609 100644 (file)
@@ -19,6 +19,7 @@
 
 #include "includes.h"
 #include "lib/cmdline/popt_common.h"
 
 #include "includes.h"
 #include "lib/cmdline/popt_common.h"
+#include "lib/events/events.h"
 #include "system/time.h"
 #include "system/filesys.h"
 #include "libcli/raw/request.h"
 #include "system/time.h"
 #include "system/filesys.h"
 #include "libcli/raw/request.h"
@@ -154,7 +155,8 @@ static bool connect_servers_fast(void)
 /***************************************************** 
 connect to the servers
 *******************************************************/
 /***************************************************** 
 connect to the servers
 *******************************************************/
-static bool connect_servers(struct loadparm_context *lp_ctx)
+static bool connect_servers(struct event_context *ev,
+                           struct loadparm_context *lp_ctx)
 {
        int i, j;
 
 {
        int i, j;
 
@@ -193,7 +195,7 @@ static bool connect_servers(struct loadparm_context *lp_ctx)
                                                        servers[i].share_name, NULL, 
                                                        servers[i].credentials, 
                                                        lp_resolve_context(lp_ctx), 
                                                        servers[i].share_name, NULL, 
                                                        servers[i].credentials, 
                                                        lp_resolve_context(lp_ctx), 
-                                                       NULL, &smb_options);
+                                                       ev, &smb_options);
                        if (!NT_STATUS_IS_OK(status)) {
                                printf("Failed to connect to \\\\%s\\%s - %s\n",
                                       servers[i].server_name, servers[i].share_name,
                        if (!NT_STATUS_IS_OK(status)) {
                                printf("Failed to connect to \\\\%s\\%s - %s\n",
                                       servers[i].server_name, servers[i].share_name,
@@ -1937,11 +1939,11 @@ static struct {
   run the test with the current set of op_parms parameters
   return the number of operations that completed successfully
 */
   run the test with the current set of op_parms parameters
   return the number of operations that completed successfully
 */
-static int run_test(struct loadparm_context *lp_ctx)
+static int run_test(struct event_context *ev, struct loadparm_context *lp_ctx)
 {
        int op, i;
 
 {
        int op, i;
 
-       if (!connect_servers(lp_ctx)) {
+       if (!connect_servers(ev, lp_ctx)) {
                printf("Failed to connect to servers\n");
                exit(1);
        }
                printf("Failed to connect to servers\n");
                exit(1);
        }
@@ -2018,7 +2020,8 @@ static int run_test(struct loadparm_context *lp_ctx)
    perform a backtracking analysis of the minimal set of operations
    to generate an error
 */
    perform a backtracking analysis of the minimal set of operations
    to generate an error
 */
-static void backtrack_analyze(struct loadparm_context *lp_ctx)
+static void backtrack_analyze(struct event_context *ev,
+                             struct loadparm_context *lp_ctx)
 {
        int chunk, ret;
 
 {
        int chunk, ret;
 
@@ -2039,7 +2042,7 @@ static void backtrack_analyze(struct loadparm_context *lp_ctx)
                        }
                        printf("Testing %d ops with %d-%d disabled\n", 
                               options.numops, base, max-1);
                        }
                        printf("Testing %d ops with %d-%d disabled\n", 
                               options.numops, base, max-1);
-                       ret = run_test(lp_ctx);
+                       ret = run_test(ev, lp_ctx);
                        printf("Completed %d of %d ops\n", ret, options.numops);
                        for (i=base;i<max; i++) {
                                op_parms[i].disabled = false;
                        printf("Completed %d of %d ops\n", ret, options.numops);
                        for (i=base;i<max; i++) {
                                op_parms[i].disabled = false;
@@ -2071,7 +2074,7 @@ static void backtrack_analyze(struct loadparm_context *lp_ctx)
        } while (chunk > 0);
 
        printf("Reduced to %d ops\n", options.numops);
        } while (chunk > 0);
 
        printf("Reduced to %d ops\n", options.numops);
-       ret = run_test(lp_ctx);
+       ret = run_test(ev, lp_ctx);
        if (ret != options.numops - 1) {
                printf("Inconsistent result? ret=%d numops=%d\n", ret, options.numops);
        }
        if (ret != options.numops - 1) {
                printf("Inconsistent result? ret=%d numops=%d\n", ret, options.numops);
        }
@@ -2080,7 +2083,8 @@ static void backtrack_analyze(struct loadparm_context *lp_ctx)
 /* 
    start the main gentest process
 */
 /* 
    start the main gentest process
 */
-static bool start_gentest(struct loadparm_context *lp_ctx)
+static bool start_gentest(struct event_context *ev,
+                         struct loadparm_context *lp_ctx)
 {
        int op;
        int ret;
 {
        int op;
        int ret;
@@ -2116,15 +2120,15 @@ static bool start_gentest(struct loadparm_context *lp_ctx)
                }
        }
 
                }
        }
 
-       ret = run_test(lp_ctx);
+       ret = run_test(ev, lp_ctx);
 
        if (ret != options.numops && options.analyze) {
                options.numops = ret+1;
 
        if (ret != options.numops && options.analyze) {
                options.numops = ret+1;
-               backtrack_analyze(lp_ctx);
+               backtrack_analyze(ev, lp_ctx);
        } else if (options.analyze_always) {
        } else if (options.analyze_always) {
-               backtrack_analyze(lp_ctx);
+               backtrack_analyze(ev, lp_ctx);
        } else if (options.analyze_continuous) {
        } else if (options.analyze_continuous) {
-               while (run_test(lp_ctx) == options.numops) ;
+               while (run_test(ev, lp_ctx) == options.numops) ;
        }
 
        return ret == options.numops;
        }
 
        return ret == options.numops;
@@ -2171,6 +2175,7 @@ static bool split_unc_name(const char *unc, char **server, char **share)
        int i, username_count=0;
        bool ret;
        char *ignore_file=NULL;
        int i, username_count=0;
        bool ret;
        char *ignore_file=NULL;
+       struct event_context *ev;
        struct loadparm_context *lp_ctx;
        poptContext pc;
        int argc_new;
        struct loadparm_context *lp_ctx;
        poptContext pc;
        int argc_new;
@@ -2278,9 +2283,11 @@ static bool split_unc_name(const char *unc, char **server, char **share)
 
        printf("seed=%u\n", options.seed);
 
 
        printf("seed=%u\n", options.seed);
 
+       ev = event_context_init(talloc_autofree_context());
+
        gensec_init(lp_ctx);
 
        gensec_init(lp_ctx);
 
-       ret = start_gentest(lp_ctx);
+       ret = start_gentest(ev, lp_ctx);
 
        if (ret) {
                printf("gentest completed - no errors\n");
 
        if (ret) {
                printf("gentest completed - no errors\n");
index dbe9d2f9a44a044855b321300b86f442b62e35cc..ca4d9b770540fbda5d777c41b35c5e1c8c6f0c1d 100644 (file)
 */
 static bool test_cldap_netlogon(struct torture_context *tctx, const char *dest)
 {
 */
 static bool test_cldap_netlogon(struct torture_context *tctx, const char *dest)
 {
-       struct cldap_socket *cldap = cldap_socket_init(tctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
+       struct cldap_socket *cldap;
        NTSTATUS status;
        struct cldap_netlogon search, empty_search;
        union nbt_cldap_netlogon n1;
        struct GUID guid;
        int i;
 
        NTSTATUS status;
        struct cldap_netlogon search, empty_search;
        union nbt_cldap_netlogon n1;
        struct GUID guid;
        int i;
 
+       cldap = cldap_socket_init(tctx, tctx->ev, lp_iconv_convenience(tctx->lp_ctx));
+
        ZERO_STRUCT(search);
        search.in.dest_address = dest;
        search.in.dest_port = lp_cldap_port(tctx->lp_ctx);
        ZERO_STRUCT(search);
        search.in.dest_address = dest;
        search.in.dest_port = lp_cldap_port(tctx->lp_ctx);
@@ -244,13 +246,15 @@ static void cldap_dump_results(struct cldap_search *search)
 */
 static bool test_cldap_generic(struct torture_context *tctx, const char *dest)
 {
 */
 static bool test_cldap_generic(struct torture_context *tctx, const char *dest)
 {
-       struct cldap_socket *cldap = cldap_socket_init(tctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
+       struct cldap_socket *cldap;
        NTSTATUS status;
        struct cldap_search search;
        const char *attrs1[] = { "currentTime", "highestCommittedUSN", NULL };
        const char *attrs2[] = { "currentTime", "highestCommittedUSN", "netlogon", NULL };
        const char *attrs3[] = { "netlogon", NULL };
 
        NTSTATUS status;
        struct cldap_search search;
        const char *attrs1[] = { "currentTime", "highestCommittedUSN", NULL };
        const char *attrs2[] = { "currentTime", "highestCommittedUSN", "netlogon", NULL };
        const char *attrs3[] = { "netlogon", NULL };
 
+       cldap = cldap_socket_init(tctx, tctx->ev, lp_iconv_convenience(tctx->lp_ctx));
+
        ZERO_STRUCT(search);
        search.in.dest_address = dest;
        search.in.dest_port = lp_cldap_port(tctx->lp_ctx);
        ZERO_STRUCT(search);
        search.in.dest_address = dest;
        search.in.dest_port = lp_cldap_port(tctx->lp_ctx);
index 51586ac733ce99914e2a672d4940a2a275aaec52..df2a5b0551a47fe07939fba08dd54a3afd3d24d1 100644 (file)
@@ -51,7 +51,7 @@ static void request_handler(struct cldap_request *req)
 */
 static bool bench_cldap(struct torture_context *tctx, const char *address)
 {
 */
 static bool bench_cldap(struct torture_context *tctx, const char *address)
 {
-       struct cldap_socket *cldap = cldap_socket_init(tctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
+       struct cldap_socket *cldap;
        int num_sent=0;
        struct timeval tv = timeval_current();
        bool ret = true;
        int num_sent=0;
        struct timeval tv = timeval_current();
        bool ret = true;
@@ -59,6 +59,8 @@ static bool bench_cldap(struct torture_context *tctx, const char *address)
        struct cldap_netlogon search;
        struct bench_state *state;
 
        struct cldap_netlogon search;
        struct bench_state *state;
 
+       cldap = cldap_socket_init(tctx, tctx->ev, lp_iconv_convenience(tctx->lp_ctx));
+
        state = talloc_zero(tctx, struct bench_state);
 
        ZERO_STRUCT(search);
        state = talloc_zero(tctx, struct bench_state);
 
        ZERO_STRUCT(search);
index 65b02ed5e8e1fea277b73d546fbdc4eee68bac87..5913163822a01fb6409fd7242987ff21e590b757 100644 (file)
@@ -65,7 +65,7 @@ NTSTATUS torture_ldap_connection(struct torture_context *tctx,
                return NT_STATUS_INVALID_PARAMETER;
        }
 
                return NT_STATUS_INVALID_PARAMETER;
        }
 
-       *conn = ldap4_new_connection(tctx, tctx->lp_ctx, NULL);
+       *conn = ldap4_new_connection(tctx, tctx->lp_ctx, tctx->ev);
 
        status = ldap_connect(*conn, url);
        if (!NT_STATUS_IS_OK(status)) {
 
        status = ldap_connect(*conn, url);
        if (!NT_STATUS_IS_OK(status)) {
index eb6abc45d5967fab0ac6db815a85ddb418798af1..7d5be368c2cc9a3c0d339b9c65471b9473f7c12b 100644 (file)
@@ -201,7 +201,7 @@ bool torture_domain_close_lsa(struct torture_context *torture)
 
        mem_ctx = talloc_init("torture_domain_close_lsa");
        status = dcerpc_pipe_connect_b(mem_ctx, &p, binding, &ndr_table_lsarpc,
 
        mem_ctx = talloc_init("torture_domain_close_lsa");
        status = dcerpc_pipe_connect_b(mem_ctx, &p, binding, &ndr_table_lsarpc,
-                                    cmdline_credentials, NULL, torture->lp_ctx);
+                                    cmdline_credentials, torture->ev, torture->lp_ctx);
        if (!NT_STATUS_IS_OK(status)) {
                d_printf("failed to connect to server: %s\n", nt_errstr(status));
                ret = false;
        if (!NT_STATUS_IS_OK(status)) {
                d_printf("failed to connect to server: %s\n", nt_errstr(status));
                ret = false;
@@ -330,7 +330,7 @@ bool torture_domain_close_samr(struct torture_context *torture)
 
        mem_ctx = talloc_init("torture_domain_close_samr");
        status = dcerpc_pipe_connect_b(mem_ctx, &p, binding, &ndr_table_samr,
 
        mem_ctx = talloc_init("torture_domain_close_samr");
        status = dcerpc_pipe_connect_b(mem_ctx, &p, binding, &ndr_table_samr,
-                                    ctx->cred, NULL, torture->lp_ctx);
+                                    ctx->cred, torture->ev, torture->lp_ctx);
        if (!NT_STATUS_IS_OK(status)) {
                d_printf("failed to connect to server: %s\n", nt_errstr(status));
                ret = false;
        if (!NT_STATUS_IS_OK(status)) {
                d_printf("failed to connect to server: %s\n", nt_errstr(status));
                ret = false;
index 618568acf9ff138c618dc774109381b950571bac..8959232edb6149d8c6f033dbeb0a0c3bb83c3853 100644 (file)
@@ -19,6 +19,7 @@
 
 #include "includes.h"
 #include "lib/cmdline/popt_common.h"
 
 #include "includes.h"
 #include "lib/cmdline/popt_common.h"
+#include "lib/events/events.h"
 #include "system/filesys.h"
 #include "system/time.h"
 #include "pstring.h"
 #include "system/filesys.h"
 #include "system/time.h"
 #include "pstring.h"
@@ -107,7 +108,8 @@ static struct record *recorded;
 /***************************************************** 
 return a connection to a server
 *******************************************************/
 /***************************************************** 
 return a connection to a server
 *******************************************************/
-static struct smbcli_state *connect_one(struct loadparm_context *lp_ctx,
+static struct smbcli_state *connect_one(struct event_context *ev,
+                                       struct loadparm_context *lp_ctx,
                                        char *share, int snum, int conn)
 {
        struct smbcli_state *c;
                                        char *share, int snum, int conn)
 {
        struct smbcli_state *c;
@@ -162,7 +164,7 @@ static struct smbcli_state *connect_one(struct loadparm_context *lp_ctx,
                                                share, NULL,
                                                servers[snum], 
                                                lp_resolve_context(lp_ctx),
                                                share, NULL,
                                                servers[snum], 
                                                lp_resolve_context(lp_ctx),
-                                               NULL, &options);
+                                               ev, &options);
                if (!NT_STATUS_IS_OK(status)) {
                        sleep(2);
                }
                if (!NT_STATUS_IS_OK(status)) {
                        sleep(2);
                }
@@ -176,7 +178,8 @@ static struct smbcli_state *connect_one(struct loadparm_context *lp_ctx,
 }
 
 
 }
 
 
-static void reconnect(struct loadparm_context *lp_ctx,
+static void reconnect(struct event_context *ev,
+                     struct loadparm_context *lp_ctx,
                      struct smbcli_state *cli[NSERVERS][NCONNECTIONS], int fnum[NSERVERS][NCONNECTIONS][NFILES],
                      char *share[NSERVERS])
 {
                      struct smbcli_state *cli[NSERVERS][NCONNECTIONS], int fnum[NSERVERS][NCONNECTIONS][NFILES],
                      char *share[NSERVERS])
 {
@@ -193,7 +196,7 @@ static void reconnect(struct loadparm_context *lp_ctx,
                        }
                        talloc_free(cli[server][conn]);
                }
                        }
                        talloc_free(cli[server][conn]);
                }
-               cli[server][conn] = connect_one(lp_ctx, share[server], 
+               cli[server][conn] = connect_one(ev, lp_ctx, share[server], 
                                                server, conn);
                if (!cli[server][conn]) {
                        DEBUG(0,("Failed to connect to %s\n", share[server]));
                                                server, conn);
                if (!cli[server][conn]) {
                        DEBUG(0,("Failed to connect to %s\n", share[server]));
@@ -396,7 +399,9 @@ static int retest(struct smbcli_state *cli[NSERVERS][NCONNECTIONS],
    we then do random locking ops in tamdem on the 4 fnums from each
    server and ensure that the results match
  */
    we then do random locking ops in tamdem on the 4 fnums from each
    server and ensure that the results match
  */
-static int test_locks(struct loadparm_context *lp_ctx, char *share[NSERVERS])
+static int test_locks(struct event_context *ev,
+                     struct loadparm_context *lp_ctx,
+                     char *share[NSERVERS])
 {
        struct smbcli_state *cli[NSERVERS][NCONNECTIONS];
        int fnum[NSERVERS][NCONNECTIONS][NFILES];
 {
        struct smbcli_state *cli[NSERVERS][NCONNECTIONS];
        int fnum[NSERVERS][NCONNECTIONS][NFILES];
@@ -447,7 +452,7 @@ static int test_locks(struct loadparm_context *lp_ctx, char *share[NSERVERS])
 #endif
        }
 
 #endif
        }
 
-       reconnect(lp_ctx, cli, fnum, share);
+       reconnect(ev, lp_ctx, cli, fnum, share);
        open_files(cli, fnum);
        n = retest(cli, fnum, numops);
 
        open_files(cli, fnum);
        n = retest(cli, fnum, numops);
 
@@ -465,7 +470,7 @@ static int test_locks(struct loadparm_context *lp_ctx, char *share[NSERVERS])
                n1 = n;
 
                close_files(cli, fnum);
                n1 = n;
 
                close_files(cli, fnum);
-               reconnect(lp_ctx, cli, fnum, share);
+               reconnect(ev, lp_ctx, cli, fnum, share);
                open_files(cli, fnum);
 
                for (i=0;i<n-skip;i+=skip) {
                open_files(cli, fnum);
 
                for (i=0;i<n-skip;i+=skip) {
@@ -503,7 +508,7 @@ static int test_locks(struct loadparm_context *lp_ctx, char *share[NSERVERS])
        }
 
        close_files(cli, fnum);
        }
 
        close_files(cli, fnum);
-       reconnect(lp_ctx, cli, fnum, share);
+       reconnect(ev, lp_ctx, cli, fnum, share);
        open_files(cli, fnum);
        showall = true;
        n1 = retest(cli, fnum, n);
        open_files(cli, fnum);
        showall = true;
        n1 = retest(cli, fnum, n);
@@ -543,6 +548,7 @@ static void usage(poptContext pc)
        int opt;
        int seed, server;
        int username_count=0;
        int opt;
        int seed, server;
        int username_count=0;
+       struct event_context *ev;
        struct loadparm_context *lp_ctx;
        poptContext pc;
        int argc_new, i;
        struct loadparm_context *lp_ctx;
        poptContext pc;
        int argc_new, i;
@@ -631,12 +637,14 @@ static void usage(poptContext pc)
                servers[1] = servers[0];
        }
 
                servers[1] = servers[0];
        }
 
+       ev = event_context_init(talloc_autofree_context());
+
        gensec_init(lp_ctx);
 
        DEBUG(0,("seed=%u base=%d range=%d min_length=%d\n", 
                 seed, lock_base, lock_range, min_length));
        srandom(seed);
 
        gensec_init(lp_ctx);
 
        DEBUG(0,("seed=%u base=%d range=%d min_length=%d\n", 
                 seed, lock_base, lock_range, min_length));
        srandom(seed);
 
-       return test_locks(lp_ctx, share);
+       return test_locks(ev, lp_ctx, share);
 }
 
 }
 
index 0fe37253859fea62ab9e23471e5d62b1541c5c2a..1784a0a729490c11668b311dd20c845b2379b914 100644 (file)
@@ -19,6 +19,7 @@
 
 #include "includes.h"
 #include "system/passwd.h"
 
 #include "includes.h"
 #include "system/passwd.h"
+#include "lib/events/events.h"
 
 static fstring password;
 static fstring username;
 
 static fstring password;
 static fstring username;
@@ -137,7 +138,8 @@ static bool try_unlock(struct smbcli_state *c, int fstype,
 return a connection to a server
 *******************************************************/
 static struct smbcli_state *connect_one(char *share, const char **ports,
 return a connection to a server
 *******************************************************/
 static struct smbcli_state *connect_one(char *share, const char **ports,
-                                       struct smb_options *options)
+                                       struct smb_options *optionsi,
+                                       struct event_context *ev)
 {
        struct smbcli_state *c;
        char *server_n;
 {
        struct smbcli_state *c;
        char *server_n;
@@ -165,7 +167,7 @@ static struct smbcli_state *connect_one(char *share, const char **ports,
 
        nt_status = smbcli_full_connection(NULL, 
                           &c, myname, server_n, ports, share, NULL,
 
        nt_status = smbcli_full_connection(NULL, 
                           &c, myname, server_n, ports, share, NULL,
-                          username, lp_workgroup(), password, NULL,
+                          username, lp_workgroup(), password, ev,
                           options);
        if (!NT_STATUS_IS_OK(nt_status)) {
                DEBUG(0, ("smbcli_full_connection failed with error %s\n", nt_errstr(nt_status)));
                           options);
        if (!NT_STATUS_IS_OK(nt_status)) {
                DEBUG(0, ("smbcli_full_connection failed with error %s\n", nt_errstr(nt_status)));
@@ -183,6 +185,7 @@ static void reconnect(struct smbcli_state *cli[NSERVERS][NCONNECTIONS],
                      int fnum[NSERVERS][NUMFSTYPES][NCONNECTIONS][NFILES],
                      const char **ports,
                      struct smbcli_options *options,
                      int fnum[NSERVERS][NUMFSTYPES][NCONNECTIONS][NFILES],
                      const char **ports,
                      struct smbcli_options *options,
+                     struct event_context *ev,
                      char *share1, char *share2)
 {
        int server, conn, f, fstype;
                      char *share1, char *share2)
 {
        int server, conn, f, fstype;
@@ -201,7 +204,7 @@ static void reconnect(struct smbcli_state *cli[NSERVERS][NCONNECTIONS],
                        smbcli_ulogoff(cli[server][conn]);
                        talloc_free(cli[server][conn]);
                }
                        smbcli_ulogoff(cli[server][conn]);
                        talloc_free(cli[server][conn]);
                }
-               cli[server][conn] = connect_one(share[server], ports, options);
+               cli[server][conn] = connect_one(share[server], ports, options, ev);
                if (!cli[server][conn]) {
                        DEBUG(0,("Failed to connect to %s\n", share[server]));
                        exit(1);
                if (!cli[server][conn]) {
                        DEBUG(0,("Failed to connect to %s\n", share[server]));
                        exit(1);
@@ -347,7 +350,11 @@ static int retest(struct smbcli_state *cli[NSERVERS][NCONNECTIONS],
    we then do random locking ops in tamdem on the 4 fnums from each
    server and ensure that the results match
  */
    we then do random locking ops in tamdem on the 4 fnums from each
    server and ensure that the results match
  */
-static void test_locks(char *share1, char *share2, char *nfspath1, char *nfspath2, const char **ports, struct smbcli_options *options)
+static void test_locks(char *share1, char *share2,
+                       char *nfspath1, char *nfspath2,
+                       const char **ports,
+                       struct smbcli_options *options,
+                       struct event_context *ev)
 {
        struct smbcli_state *cli[NSERVERS][NCONNECTIONS];
        char *nfs[NSERVERS];
 {
        struct smbcli_state *cli[NSERVERS][NCONNECTIONS];
        char *nfs[NSERVERS];
@@ -376,7 +383,7 @@ static void test_locks(char *share1, char *share2, char *nfspath1, char *nfspath
                recorded[n].needed = true;
        }
 
                recorded[n].needed = true;
        }
 
-       reconnect(cli, nfs, fnum, ports, options, share1, share2);
+       reconnect(cli, nfs, fnum, ports, options, ev, share1, share2);
        open_files(cli, nfs, fnum);
        n = retest(cli, nfs, fnum, numops);
 
        open_files(cli, nfs, fnum);
        n = retest(cli, nfs, fnum, numops);
 
@@ -387,7 +394,7 @@ static void test_locks(char *share1, char *share2, char *nfspath1, char *nfspath
                n1 = n;
 
                close_files(cli, nfs, fnum);
                n1 = n;
 
                close_files(cli, nfs, fnum);
-               reconnect(cli, nfs, fnum, ports, options, share1, share2);
+               reconnect(cli, nfs, fnum, ports, options, ev, share1, share2);
                open_files(cli, nfs, fnum);
 
                for (i=0;i<n-1;i++) {
                open_files(cli, nfs, fnum);
 
                for (i=0;i<n-1;i++) {
@@ -414,7 +421,7 @@ static void test_locks(char *share1, char *share2, char *nfspath1, char *nfspath
        }
 
        close_files(cli, nfs, fnum);
        }
 
        close_files(cli, nfs, fnum);
-       reconnect(cli, nfs, fnum, ports, options, share1, share2);
+       reconnect(cli, nfs, fnum, ports, options, ev, share1, share2);
        open_files(cli, nfs, fnum);
        showall = true;
        n1 = retest(cli, nfs, fnum, n);
        open_files(cli, nfs, fnum);
        showall = true;
        n1 = retest(cli, nfs, fnum, n);
@@ -466,6 +473,7 @@ static void usage(void)
        char *p;
        int seed;
        struct loadparm_context *lp_ctx;
        char *p;
        int seed;
        struct loadparm_context *lp_ctx;
+       struct event_context *ev;
 
        setlinebuf(stdout);
 
 
        setlinebuf(stdout);
 
@@ -542,10 +550,12 @@ static void usage(void)
        DEBUG(0,("seed=%u\n", seed));
        srandom(seed);
 
        DEBUG(0,("seed=%u\n", seed));
        srandom(seed);
 
+       ev = event_context_init(talloc_autofree_context());
+
        locking_init(1);
        lp_smbcli_options(lp_ctx, &options);
        test_locks(share1, share2, nfspath1, nfspath2, lp_smb_ports(lp_ctx),
        locking_init(1);
        lp_smbcli_options(lp_ctx, &options);
        test_locks(share1, share2, nfspath1, nfspath2, lp_smb_ports(lp_ctx),
-                  &options);
+                  &options, ev);
 
        return(0);
 }
 
        return(0);
 }
index ac7029aa50df861391f3956ab368d30567d17f79..39b1296dbe0da573afcc2a3e9e6717a90778e527 100644 (file)
@@ -30,6 +30,7 @@
 #include "param/param.h"
 #include "dynconfig.h"
 #include "libcli/resolve/resolve.h"
 #include "param/param.h"
 #include "dynconfig.h"
 #include "libcli/resolve/resolve.h"
+#include "lib/events/events.h"
 
 static bool showall = false;
 static bool old_list = false;
 
 static bool showall = false;
 static bool old_list = false;
@@ -73,6 +74,7 @@ static char *reg_test(struct smbcli_state *cli, char *pattern, char *long_name,
 return a connection to a server
 *******************************************************/
 static struct smbcli_state *connect_one(struct resolve_context *resolve_ctx, 
 return a connection to a server
 *******************************************************/
 static struct smbcli_state *connect_one(struct resolve_context *resolve_ctx, 
+                                       struct event_context *ev,
                                        char *share, const char **ports,
                                        struct smbcli_options *options)
 {
                                        char *share, const char **ports,
                                        struct smbcli_options *options)
 {
@@ -92,7 +94,7 @@ static struct smbcli_state *connect_one(struct resolve_context *resolve_ctx,
                                        server, 
                                        ports,
                                        share, NULL,
                                        server, 
                                        ports,
                                        share, NULL,
-                                       cmdline_credentials, resolve_ctx, NULL,
+                                       cmdline_credentials, resolve_ctx, ev,
                                        options);
 
        if (!NT_STATUS_IS_OK(status)) {
                                        options);
 
        if (!NT_STATUS_IS_OK(status)) {
@@ -291,6 +293,7 @@ static void usage(poptContext pc)
        struct smbcli_state *cli;       
        int opt;
        int seed;
        struct smbcli_state *cli;       
        int opt;
        int seed;
+       struct event_context *ev;
        struct loadparm_context *lp_ctx;
        struct smbcli_options options;
        poptContext pc;
        struct loadparm_context *lp_ctx;
        struct smbcli_options options;
        poptContext pc;
@@ -352,11 +355,13 @@ static void usage(poptContext pc)
 
        lp_ctx = cmdline_lp_ctx;
 
 
        lp_ctx = cmdline_lp_ctx;
 
+       ev = event_context_init(talloc_autofree_context());
+
        gensec_init(lp_ctx);
 
        lp_smbcli_options(lp_ctx, &options);
 
        gensec_init(lp_ctx);
 
        lp_smbcli_options(lp_ctx, &options);
 
-       cli = connect_one(lp_resolve_context(lp_ctx), share, 
+       cli = connect_one(lp_resolve_context(lp_ctx), ev, share, 
                          lp_smb_ports(lp_ctx), &options);
        if (!cli) {
                DEBUG(0,("Failed to connect to %s\n", share));
                          lp_smb_ports(lp_ctx), &options);
        if (!cli) {
                DEBUG(0,("Failed to connect to %s\n", share));
index e609e7205513d4208a352e79e134def20ddc8818..a0e7b7d9caea75f670a41526dbc2f581ec2e817e 100644 (file)
@@ -40,7 +40,7 @@ bool torture_nbt_browse(struct torture_context *torture)
        name.scope = NULL;
 
        /* do an initial name resolution to find its IP */
        name.scope = NULL;
 
        /* do an initial name resolution to find its IP */
-       status = resolve_name(&name, mem_ctx, &address, NULL);
+       status = resolve_name(&name, mem_ctx, &address, torture->ev);
        if (!NT_STATUS_IS_OK(status)) {
                printf("Failed to resolve %s - %s\n",
                       name.name, nt_errstr(status));
        if (!NT_STATUS_IS_OK(status)) {
                printf("Failed to resolve %s - %s\n",
                       name.name, nt_errstr(status));
index a4c8be888cf7fe90b019e6703518c8beea4cd02c..a3585896eb4802bbcccd4d5f5c1bf2f15e23039f 100644 (file)
@@ -64,7 +64,7 @@ static void netlogon_handler(struct dgram_mailslot_handler *dgmslot,
 static bool nbt_test_netlogon(struct torture_context *tctx)
 {
        struct dgram_mailslot_handler *dgmslot;
 static bool nbt_test_netlogon(struct torture_context *tctx)
 {
        struct dgram_mailslot_handler *dgmslot;
-       struct nbt_dgram_socket *dgmsock = nbt_dgram_socket_init(tctx, NULL
+       struct nbt_dgram_socket *dgmsock = nbt_dgram_socket_init(tctx, tctx->ev
                                                                 lp_iconv_convenience(tctx->lp_ctx));
        struct socket_address *dest;
        const char *myaddress;
                                                                 lp_iconv_convenience(tctx->lp_ctx));
        struct socket_address *dest;
        const char *myaddress;
@@ -147,7 +147,7 @@ static bool nbt_test_netlogon(struct torture_context *tctx)
 static bool nbt_test_netlogon2(struct torture_context *tctx)
 {
        struct dgram_mailslot_handler *dgmslot;
 static bool nbt_test_netlogon2(struct torture_context *tctx)
 {
        struct dgram_mailslot_handler *dgmslot;
-       struct nbt_dgram_socket *dgmsock = nbt_dgram_socket_init(tctx, NULL,
+       struct nbt_dgram_socket *dgmsock = nbt_dgram_socket_init(tctx, tctx->ev,
                                                                 lp_iconv_convenience(tctx->lp_ctx));
        struct socket_address *dest;
        const char *myaddress;
                                                                 lp_iconv_convenience(tctx->lp_ctx));
        struct socket_address *dest;
        const char *myaddress;
@@ -257,7 +257,7 @@ static void ntlogon_handler(struct dgram_mailslot_handler *dgmslot,
 static bool nbt_test_ntlogon(struct torture_context *tctx)
 {
        struct dgram_mailslot_handler *dgmslot;
 static bool nbt_test_ntlogon(struct torture_context *tctx)
 {
        struct dgram_mailslot_handler *dgmslot;
-       struct nbt_dgram_socket *dgmsock = nbt_dgram_socket_init(tctx, NULL,
+       struct nbt_dgram_socket *dgmsock = nbt_dgram_socket_init(tctx, tctx->ev,
                                                                 lp_iconv_convenience(tctx->lp_ctx));
        struct socket_address *dest;
        struct test_join *join_ctx;
                                                                 lp_iconv_convenience(tctx->lp_ctx));
        struct socket_address *dest;
        struct test_join *join_ctx;
index 6cb9507398fc87844a643acde7c1d3b77243922a..d27a26eb30c34170c7f8a9c5f3a415a1b0e5f37d 100644 (file)
@@ -34,7 +34,7 @@ bool torture_nbt_get_name(struct torture_context *tctx,
 
        /* do an initial name resolution to find its IP */
        torture_assert_ntstatus_ok(tctx, 
 
        /* do an initial name resolution to find its IP */
        torture_assert_ntstatus_ok(tctx, 
-                                  resolve_name(lp_resolve_context(tctx->lp_ctx), name, tctx, address, NULL), 
+                                  resolve_name(lp_resolve_context(tctx->lp_ctx), name, tctx, address, tctx->ev), 
                                   talloc_asprintf(tctx, 
                                                   "Failed to resolve %s", name->name));
        
                                   talloc_asprintf(tctx, 
                                                   "Failed to resolve %s", name->name));
        
index 1ba6172e5ce50db04b6fa4007766a00de76de9d8..3f3a15cca542b53d8871b9f0f948c629e1be8e72 100644 (file)
@@ -47,7 +47,7 @@ static void increment_handler(struct nbt_name_request *req)
 */
 static bool bench_namequery(struct torture_context *tctx)
 {
 */
 static bool bench_namequery(struct torture_context *tctx)
 {
-       struct nbt_name_socket *nbtsock = nbt_name_socket_init(tctx, NULL,
+       struct nbt_name_socket *nbtsock = nbt_name_socket_init(tctx, tctx->ev,
                                                               lp_iconv_convenience(tctx->lp_ctx));
        int num_sent=0;
        struct result_struct *result;
                                                               lp_iconv_convenience(tctx->lp_ctx));
        int num_sent=0;
        struct result_struct *result;
index b9f06c479d0d7b6a2840f34623a1313f85b8eaed..a8681f828f7373e10b20fd5ffb642247f8164a7a 100644 (file)
@@ -44,7 +44,7 @@ static bool nbt_register_own(struct torture_context *tctx)
 {
        struct nbt_name_register io;
        NTSTATUS status;
 {
        struct nbt_name_register io;
        NTSTATUS status;
-       struct nbt_name_socket *nbtsock = nbt_name_socket_init(tctx, NULL,
+       struct nbt_name_socket *nbtsock = nbt_name_socket_init(tctx, tctx->ev,
                                                               lp_iconv_convenience(tctx->lp_ctx));
        struct socket_address *socket_address;
        struct nbt_name name;
                                                               lp_iconv_convenience(tctx->lp_ctx));
        struct socket_address *socket_address;
        struct nbt_name name;
@@ -114,7 +114,7 @@ static bool nbt_refresh_own(struct torture_context *tctx)
 {
        struct nbt_name_refresh io;
        NTSTATUS status;
 {
        struct nbt_name_refresh io;
        NTSTATUS status;
-       struct nbt_name_socket *nbtsock = nbt_name_socket_init(tctx, NULL,
+       struct nbt_name_socket *nbtsock = nbt_name_socket_init(tctx, tctx->ev,
                                                               lp_iconv_convenience(tctx->lp_ctx));
        const char *myaddress;
        struct socket_address *socket_address;
                                                               lp_iconv_convenience(tctx->lp_ctx));
        const char *myaddress;
        struct socket_address *socket_address;
index 059b2dc91922daa01da3515ffea7b669aac60609..ae20de6e2f59244ea62f89e880f9627de834169d 100644 (file)
@@ -53,7 +53,7 @@ static bool nbt_test_wins_name(struct torture_context *tctx, const char *address
        struct nbt_name_refresh_wins refresh;
        struct nbt_name_release release;
        NTSTATUS status;
        struct nbt_name_refresh_wins refresh;
        struct nbt_name_release release;
        NTSTATUS status;
-       struct nbt_name_socket *nbtsock = nbt_name_socket_init(tctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
+       struct nbt_name_socket *nbtsock = nbt_name_socket_init(tctx, tctx->ev, lp_iconv_convenience(tctx->lp_ctx));
        const char *myaddress;
        struct socket_address *socket_address;
        struct interface *ifaces;
        const char *myaddress;
        struct socket_address *socket_address;
        struct interface *ifaces;
index ea4abaf21b5a11c773d422825c3f6e14ca0e067e..a0d90fb65333608f823a0cbd27d0c633f1de7c71 100644 (file)
@@ -225,7 +225,7 @@ static void generate_request(struct nbt_name_socket *nbtsock, struct wins_state
 */
 static bool bench_wins(struct torture_context *tctx)
 {
 */
 static bool bench_wins(struct torture_context *tctx)
 {
-       struct nbt_name_socket *nbtsock = nbt_name_socket_init(tctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
+       struct nbt_name_socket *nbtsock = nbt_name_socket_init(tctx, tctx->ev, lp_iconv_convenience(tctx->lp_ctx));
        int num_sent=0;
        struct timeval tv = timeval_current();
        bool ret = true;
        int num_sent=0;
        struct timeval tv = timeval_current();
        bool ret = true;
index 470eee831003d9c20e66070ab2e530882e5d1977..ee7a1510d5b7347630390f517c5bfe5fdf4dc5c2 100644 (file)
@@ -103,8 +103,8 @@ static bool test_assoc_ctx1(struct torture_context *tctx)
 
        torture_comment(tctx, "Test if assoc_ctx is only valid on the conection it was created on\n");
 
 
        torture_comment(tctx, "Test if assoc_ctx is only valid on the conection it was created on\n");
 
-       wrepl_socket1 = wrepl_socket_init(tctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
-       wrepl_socket2 = wrepl_socket_init(tctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
+       wrepl_socket1 = wrepl_socket_init(tctx, tctx->ev, lp_iconv_convenience(tctx->lp_ctx));
+       wrepl_socket2 = wrepl_socket_init(tctx, tctx->ev, lp_iconv_convenience(tctx->lp_ctx));
 
        torture_comment(tctx, "Setup 2 wrepl connections\n");
        status = wrepl_connect(wrepl_socket1, lp_resolve_context(tctx->lp_ctx), wrepl_best_ip(tctx->lp_ctx, address), address);
 
        torture_comment(tctx, "Setup 2 wrepl connections\n");
        status = wrepl_connect(wrepl_socket1, lp_resolve_context(tctx->lp_ctx), wrepl_best_ip(tctx->lp_ctx, address), address);
@@ -186,7 +186,7 @@ static bool test_assoc_ctx2(struct torture_context *tctx)
 
        torture_comment(tctx, "Test if we always get back the same assoc_ctx\n");
 
 
        torture_comment(tctx, "Test if we always get back the same assoc_ctx\n");
 
-       wrepl_socket = wrepl_socket_init(tctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
+       wrepl_socket = wrepl_socket_init(tctx, tctx->ev, lp_iconv_convenience(tctx->lp_ctx));
        
        torture_comment(tctx, "Setup wrepl connections\n");
        status = wrepl_connect(wrepl_socket, lp_resolve_context(tctx->lp_ctx), wrepl_best_ip(tctx->lp_ctx, address), address);
        
        torture_comment(tctx, "Setup wrepl connections\n");
        status = wrepl_connect(wrepl_socket, lp_resolve_context(tctx->lp_ctx), wrepl_best_ip(tctx->lp_ctx, address), address);
@@ -255,7 +255,7 @@ static bool test_wins_replication(struct torture_context *tctx)
 
        torture_comment(tctx, "Test one pull replication cycle\n");
 
 
        torture_comment(tctx, "Test one pull replication cycle\n");
 
-       wrepl_socket = wrepl_socket_init(tctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
+       wrepl_socket = wrepl_socket_init(tctx, tctx->ev, lp_iconv_convenience(tctx->lp_ctx));
        
        torture_comment(tctx, "Setup wrepl connections\n");
        status = wrepl_connect(wrepl_socket, lp_resolve_context(tctx->lp_ctx), wrepl_best_ip(tctx->lp_ctx, address), address);
        
        torture_comment(tctx, "Setup wrepl connections\n");
        status = wrepl_connect(wrepl_socket, lp_resolve_context(tctx->lp_ctx), wrepl_best_ip(tctx->lp_ctx, address), address);
@@ -553,7 +553,7 @@ static struct test_wrepl_conflict_conn *test_create_conflict_ctx(
        if (!ctx) return NULL;
 
        ctx->address    = address;
        if (!ctx) return NULL;
 
        ctx->address    = address;
-       ctx->pull       = wrepl_socket_init(ctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
+       ctx->pull       = wrepl_socket_init(ctx, tctx->ev, lp_iconv_convenience(tctx->lp_ctx));
        if (!ctx->pull) return NULL;
 
        torture_comment(tctx, "Setup wrepl conflict pull connection\n");
        if (!ctx->pull) return NULL;
 
        torture_comment(tctx, "Setup wrepl conflict pull connection\n");
@@ -610,7 +610,7 @@ static struct test_wrepl_conflict_conn *test_create_conflict_ctx(
 
        talloc_free(pull_table.out.partners);
 
 
        talloc_free(pull_table.out.partners);
 
-       ctx->nbtsock = nbt_name_socket_init(ctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
+       ctx->nbtsock = nbt_name_socket_init(ctx, tctx->ev, lp_iconv_convenience(tctx->lp_ctx));
        if (!ctx->nbtsock) return NULL;
 
        load_interfaces(tctx, lp_interfaces(tctx->lp_ctx), &ifaces);
        if (!ctx->nbtsock) return NULL;
 
        load_interfaces(tctx, lp_interfaces(tctx->lp_ctx), &ifaces);
@@ -628,7 +628,7 @@ static struct test_wrepl_conflict_conn *test_create_conflict_ctx(
        status = socket_listen(ctx->nbtsock->sock, ctx->myaddr, 0, 0);
        if (!NT_STATUS_IS_OK(status)) return NULL;
 
        status = socket_listen(ctx->nbtsock->sock, ctx->myaddr, 0, 0);
        if (!NT_STATUS_IS_OK(status)) return NULL;
 
-       ctx->nbtsock_srv = nbt_name_socket_init(ctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
+       ctx->nbtsock_srv = nbt_name_socket_init(ctx, tctx->ev, lp_iconv_convenience(tctx->lp_ctx));
        if (!ctx->nbtsock_srv) return NULL;
 
        /* Make a port 137 version of ctx->myaddr */
        if (!ctx->nbtsock_srv) return NULL;
 
        /* Make a port 137 version of ctx->myaddr */
@@ -645,7 +645,7 @@ static struct test_wrepl_conflict_conn *test_create_conflict_ctx(
        }
 
        if (ctx->myaddr2 && ctx->nbtsock_srv) {
        }
 
        if (ctx->myaddr2 && ctx->nbtsock_srv) {
-               ctx->nbtsock2 = nbt_name_socket_init(ctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
+               ctx->nbtsock2 = nbt_name_socket_init(ctx, tctx->ev, lp_iconv_convenience(tctx->lp_ctx));
                if (!ctx->nbtsock2) return NULL;
 
                status = socket_listen(ctx->nbtsock2->sock, ctx->myaddr2, 0, 0);
                if (!ctx->nbtsock2) return NULL;
 
                status = socket_listen(ctx->nbtsock2->sock, ctx->myaddr2, 0, 0);
@@ -722,7 +722,7 @@ static bool test_wrepl_update_one(struct torture_context *tctx,
        uint32_t assoc_ctx;
        NTSTATUS status;
 
        uint32_t assoc_ctx;
        NTSTATUS status;
 
-       wrepl_socket = wrepl_socket_init(ctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
+       wrepl_socket = wrepl_socket_init(ctx, tctx->ev, lp_iconv_convenience(tctx->lp_ctx));
 
        status = wrepl_connect(wrepl_socket, lp_resolve_context(tctx->lp_ctx), wrepl_best_ip(tctx->lp_ctx, ctx->address), ctx->address);
        CHECK_STATUS(tctx, status, NT_STATUS_OK);
 
        status = wrepl_connect(wrepl_socket, lp_resolve_context(tctx->lp_ctx), wrepl_best_ip(tctx->lp_ctx, ctx->address), ctx->address);
        CHECK_STATUS(tctx, status, NT_STATUS_OK);
index 1f31fbc51528e7530966b48164a6adc69d0a1098..d73ac1327e1b80c6556a7d7613846cb4b41688e5 100644 (file)
@@ -296,7 +296,7 @@ static bool test_appendacl(struct smbcli_state *cli, struct torture_context *tct
                c[i]->async.private_data = count;
        }
 
                c[i]->async.private_data = count;
        }
 
-       event_ctx = talloc_reference(tctx, cli->tree->session->transport->socket->event.ctx);
+       event_ctx = tctx->ev;
        printf("waiting for completion\n");
        while (*count != num_ops) {
                event_loop_once(event_ctx);
        printf("waiting for completion\n");
        while (*count != num_ops) {
                event_loop_once(event_ctx);
@@ -354,7 +354,7 @@ static bool test_fsinfo(struct smbcli_state *cli, struct torture_context *tctx)
 
        printf("testing parallel queryfsinfo [Object ID] with %d ops\n", torture_numops);
 
 
        printf("testing parallel queryfsinfo [Object ID] with %d ops\n", torture_numops);
 
-       event_ctx = talloc_reference(tctx, cli->tree->session->transport->socket->event.ctx);
+       event_ctx = tctx->ev;
        c = talloc_array(tctx, struct composite_context *, torture_numops);
 
        for (i=0; i<torture_numops; i++) {
        c = talloc_array(tctx, struct composite_context *, torture_numops);
 
        for (i=0; i<torture_numops; i++) {
index b28e429a75746c4a0b590c25c127070de3cf532e..00617f407268eac4b64718a12f4814680e04a4df 100644 (file)
@@ -178,12 +178,11 @@ static bool _test_DsBind(struct torture_context *tctx,
 {
        NTSTATUS status;
        bool ret = true;
 {
        NTSTATUS status;
        bool ret = true;
-       struct event_context *event = NULL;
 
        status = dcerpc_pipe_connect_b(ctx,
                                       &b->pipe, ctx->drsuapi_binding, 
                                       &ndr_table_drsuapi,
 
        status = dcerpc_pipe_connect_b(ctx,
                                       &b->pipe, ctx->drsuapi_binding, 
                                       &ndr_table_drsuapi,
-                                      credentials, event, tctx->lp_ctx);
+                                      credentials, tctx->ev, tctx->lp_ctx);
        
        if (!NT_STATUS_IS_OK(status)) {
                printf("Failed to connect to server as a BDC: %s\n", nt_errstr(status));
        
        if (!NT_STATUS_IS_OK(status)) {
                printf("Failed to connect to server as a BDC: %s\n", nt_errstr(status));
@@ -254,10 +253,11 @@ static bool test_GetInfo(struct torture_context *tctx, struct DsSyncTest *ctx)
        struct drsuapi_DsCrackNames r;
        struct drsuapi_DsNameString names[1];
        bool ret = true;
        struct drsuapi_DsCrackNames r;
        struct drsuapi_DsNameString names[1];
        bool ret = true;
-
-       struct cldap_socket *cldap = cldap_socket_init(ctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
+       struct cldap_socket *cldap;
        struct cldap_netlogon search;
        struct cldap_netlogon search;
-       
+
+       cldap = cldap_socket_init(ctx, tctx->ev, lp_iconv_convenience(tctx->lp_ctx));
+
        r.in.bind_handle                = &ctx->admin.drsuapi.bind_handle;
        r.in.level                      = 1;
        r.in.req.req1.codepage          = 1252; /* western european */
        r.in.bind_handle                = &ctx->admin.drsuapi.bind_handle;
        r.in.level                      = 1;
        r.in.req.req1.codepage          = 1252; /* western european */
index 849b9fd1e99904c243a74b2ddee693901f8c10e5..cd5eb32fa8196b6442df46a70709a5eb73f10553 100644 (file)
@@ -39,7 +39,7 @@ bool torture_rpc_join(struct torture_context *torture)
                                        "IPC$", NULL,
                                        machine_account,
                                        lp_resolve_context(torture->lp_ctx),
                                        "IPC$", NULL,
                                        machine_account,
                                        lp_resolve_context(torture->lp_ctx),
-                                       NULL, &options);
+                                       torture->ev, &options);
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(0, ("%s failed to connect to IPC$ with workstation credentials\n",
                          TORTURE_NETBIOS_NAME));
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(0, ("%s failed to connect to IPC$ with workstation credentials\n",
                          TORTURE_NETBIOS_NAME));
@@ -65,7 +65,7 @@ bool torture_rpc_join(struct torture_context *torture)
                                        "IPC$", NULL,
                                        machine_account,
                                        lp_resolve_context(torture->lp_ctx),
                                        "IPC$", NULL,
                                        machine_account,
                                        lp_resolve_context(torture->lp_ctx),
-                                       NULL, &options);
+                                       torture->ev, &options);
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(0, ("%s failed to connect to IPC$ with workstation credentials\n",
                          TORTURE_NETBIOS_NAME));
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(0, ("%s failed to connect to IPC$ with workstation credentials\n",
                          TORTURE_NETBIOS_NAME));
index 6e38d0465a413d904e8aa7d83df75b647eef5216..7c8e78b160f9486f85e5bc6137f311adcb2f578b 100644 (file)
@@ -83,7 +83,7 @@ _PUBLIC_ NTSTATUS torture_rpc_connection(struct torture_context *tctx,
 
        status = dcerpc_pipe_connect_b(tctx, 
                                     p, binding, table,
 
        status = dcerpc_pipe_connect_b(tctx, 
                                     p, binding, table,
-                                    cmdline_credentials, NULL, tctx->lp_ctx);
+                                    cmdline_credentials, tctx->ev, tctx->lp_ctx);
  
        if (NT_STATUS_IS_ERR(status)) {
                printf("Failed to connect to remote server: %s %s\n", 
  
        if (NT_STATUS_IS_ERR(status)) {
                printf("Failed to connect to remote server: %s %s\n", 
@@ -113,7 +113,7 @@ NTSTATUS torture_rpc_connection_transport(struct torture_context *tctx,
        binding->assoc_group_id = assoc_group_id;
 
        status = dcerpc_pipe_connect_b(tctx, p, binding, table,
        binding->assoc_group_id = assoc_group_id;
 
        status = dcerpc_pipe_connect_b(tctx, p, binding, table,
-                                      cmdline_credentials, NULL, tctx->lp_ctx);
+                                      cmdline_credentials, tctx->ev, tctx->lp_ctx);
                                           
        if (NT_STATUS_IS_ERR(status)) {
                *p = NULL;
                                           
        if (NT_STATUS_IS_ERR(status)) {
                *p = NULL;
@@ -147,7 +147,7 @@ static bool torture_rpc_setup_machine(struct torture_context *tctx,
                                &(tcase_data->pipe),
                                binding,
                                tcase->table,
                                &(tcase_data->pipe),
                                binding,
                                tcase->table,
-                               tcase_data->credentials, NULL, tctx->lp_ctx);
+                               tcase_data->credentials, tctx->ev, tctx->lp_ctx);
 
        torture_assert_ntstatus_ok(tctx, status, "Error connecting to server");
 
 
        torture_assert_ntstatus_ok(tctx, status, "Error connecting to server");
 
@@ -205,7 +205,7 @@ static bool torture_rpc_setup_anonymous(struct torture_context *tctx,
                                &(tcase_data->pipe),
                                binding,
                                tcase->table,
                                &(tcase_data->pipe),
                                binding,
                                tcase->table,
-                               tcase_data->credentials, NULL, tctx->lp_ctx);
+                               tcase_data->credentials, tctx->ev, tctx->lp_ctx);
 
        torture_assert_ntstatus_ok(tctx, status, "Error connecting to server");
 
 
        torture_assert_ntstatus_ok(tctx, status, "Error connecting to server");
 
index 8eb1f54b4fd3d3bd9223e36e907a4660f108c4fd..40a7c156f41deb715fb75d90a77e5be33d6840b6 100644 (file)
@@ -89,7 +89,7 @@ bool torture_bind_authcontext(struct torture_context *torture)
                                        lp_smb_ports(torture->lp_ctx),
                                        "IPC$", NULL, cmdline_credentials,
                                        lp_resolve_context(torture->lp_ctx),
                                        lp_smb_ports(torture->lp_ctx),
                                        "IPC$", NULL, cmdline_credentials,
                                        lp_resolve_context(torture->lp_ctx),
-                                       NULL, &options);
+                                       torture->ev, &options);
        if (!NT_STATUS_IS_OK(status)) {
                d_printf("smbcli_full_connection failed: %s\n",
                         nt_errstr(status));
        if (!NT_STATUS_IS_OK(status)) {
                d_printf("smbcli_full_connection failed: %s\n",
                         nt_errstr(status));
@@ -303,7 +303,7 @@ bool torture_bind_samba3(struct torture_context *torture)
                                        lp_smb_ports(torture->lp_ctx),
                                        "IPC$", NULL, cmdline_credentials,
                                        lp_resolve_context(torture->lp_ctx),
                                        lp_smb_ports(torture->lp_ctx),
                                        "IPC$", NULL, cmdline_credentials,
                                        lp_resolve_context(torture->lp_ctx),
-                                       NULL, &options);
+                                       torture->ev, &options);
        if (!NT_STATUS_IS_OK(status)) {
                d_printf("smbcli_full_connection failed: %s\n",
                         nt_errstr(status));
        if (!NT_STATUS_IS_OK(status)) {
                d_printf("smbcli_full_connection failed: %s\n",
                         nt_errstr(status));
@@ -1220,7 +1220,7 @@ bool torture_netlogon_samba3(struct torture_context *torture)
                                        lp_smb_ports(torture->lp_ctx),
                                        "IPC$", NULL, anon_creds, 
                                        lp_resolve_context(torture->lp_ctx),
                                        lp_smb_ports(torture->lp_ctx),
                                        "IPC$", NULL, anon_creds, 
                                        lp_resolve_context(torture->lp_ctx),
-                                       NULL, &options);
+                                       torture->ev, &options);
        if (!NT_STATUS_IS_OK(status)) {
                d_printf("smbcli_full_connection failed: %s\n",
                         nt_errstr(status));
        if (!NT_STATUS_IS_OK(status)) {
                d_printf("smbcli_full_connection failed: %s\n",
                         nt_errstr(status));
@@ -1307,7 +1307,7 @@ static bool test_join3(struct torture_context *tctx,
                                        lp_smb_ports(tctx->lp_ctx),
                                        "IPC$", NULL, smb_creds, 
                                        lp_resolve_context(tctx->lp_ctx),
                                        lp_smb_ports(tctx->lp_ctx),
                                        "IPC$", NULL, smb_creds, 
                                        lp_resolve_context(tctx->lp_ctx),
-                                       NULL, &options);
+                                       tctx->ev, &options);
        if (!NT_STATUS_IS_OK(status)) {
                d_printf("smbcli_full_connection failed: %s\n",
                         nt_errstr(status));
        if (!NT_STATUS_IS_OK(status)) {
                d_printf("smbcli_full_connection failed: %s\n",
                         nt_errstr(status));
@@ -1682,7 +1682,7 @@ bool torture_samba3_rpc_getusername(struct torture_context *torture)
                lp_smb_ports(torture->lp_ctx),
                "IPC$", NULL, cmdline_credentials, 
                lp_resolve_context(torture->lp_ctx),
                lp_smb_ports(torture->lp_ctx),
                "IPC$", NULL, cmdline_credentials, 
                lp_resolve_context(torture->lp_ctx),
-               NULL, &options);
+               torture->ev, &options);
        if (!NT_STATUS_IS_OK(status)) {
                d_printf("(%s) smbcli_full_connection failed: %s\n",
                         __location__, nt_errstr(status));
        if (!NT_STATUS_IS_OK(status)) {
                d_printf("(%s) smbcli_full_connection failed: %s\n",
                         __location__, nt_errstr(status));
@@ -1709,7 +1709,7 @@ bool torture_samba3_rpc_getusername(struct torture_context *torture)
                lp_smb_ports(torture->lp_ctx),
                "IPC$", NULL, anon_creds, 
                lp_resolve_context(torture->lp_ctx),
                lp_smb_ports(torture->lp_ctx),
                "IPC$", NULL, anon_creds, 
                lp_resolve_context(torture->lp_ctx),
-               NULL, &options);
+               torture->ev, &options);
        if (!NT_STATUS_IS_OK(status)) {
                d_printf("(%s) anon smbcli_full_connection failed: %s\n",
                         __location__, nt_errstr(status));
        if (!NT_STATUS_IS_OK(status)) {
                d_printf("(%s) anon smbcli_full_connection failed: %s\n",
                         __location__, nt_errstr(status));
index 24b2511bc75e98e77f1ce021ada80e327f6ee2d3..ab3283a952e05c597bdca4d36d8c9329c1514efb 100644 (file)
@@ -1602,7 +1602,7 @@ bool torture_rpc_samlogon(struct torture_context *torture)
 
        status = dcerpc_pipe_connect_b(mem_ctx, &p, b, 
                                       &ndr_table_netlogon,
 
        status = dcerpc_pipe_connect_b(mem_ctx, &p, b, 
                                       &ndr_table_netlogon,
-                                      machine_credentials, NULL, torture->lp_ctx);
+                                      machine_credentials, torture->ev, torture->lp_ctx);
 
        if (!NT_STATUS_IS_OK(status)) {
                d_printf("RPC pipe connect as domain member failed: %s\n", nt_errstr(status));
 
        if (!NT_STATUS_IS_OK(status)) {
                d_printf("RPC pipe connect as domain member failed: %s\n", nt_errstr(status));
index 3b152d92aa739ad083f22b0bc152ddff828747b1..9705f7b0de81d50b1478d47df972838027ac1abb 100644 (file)
@@ -1560,7 +1560,7 @@ bool torture_rpc_samsync(struct torture_context *torture)
        status = dcerpc_pipe_connect_b(samsync_state,
                                       &samsync_state->p, b, 
                                           &ndr_table_netlogon,
        status = dcerpc_pipe_connect_b(samsync_state,
                                       &samsync_state->p, b, 
                                           &ndr_table_netlogon,
-                                      credentials, NULL, torture->lp_ctx);
+                                      credentials, torture->ev, torture->lp_ctx);
        
        if (!NT_STATUS_IS_OK(status)) {
                printf("Failed to connect to server as a BDC: %s\n", nt_errstr(status));
        
        if (!NT_STATUS_IS_OK(status)) {
                printf("Failed to connect to server as a BDC: %s\n", nt_errstr(status));
@@ -1598,7 +1598,7 @@ bool torture_rpc_samsync(struct torture_context *torture)
                                       &samsync_state->p_netlogon_wksta, 
                                       b_netlogon_wksta, 
                                           &ndr_table_netlogon,
                                       &samsync_state->p_netlogon_wksta, 
                                       b_netlogon_wksta, 
                                           &ndr_table_netlogon,
-                                      credentials_wksta, NULL, torture->lp_ctx);
+                                      credentials_wksta, torture->ev, torture->lp_ctx);
 
        if (!NT_STATUS_IS_OK(status)) {
                printf("Failed to connect to server as a Workstation: %s\n", nt_errstr(status));
 
        if (!NT_STATUS_IS_OK(status)) {
                printf("Failed to connect to server as a Workstation: %s\n", nt_errstr(status));
index 46605e53e6d2d852d86b8e5a95466fbf798c8069..c89b71baaf4c68f16599e3b2da44a0bf59ecc565 100644 (file)
@@ -258,7 +258,7 @@ static bool test_schannel(struct torture_context *tctx,
        b->flags |= dcerpc_flags;
 
        status = dcerpc_pipe_connect_b(tctx, &p, b, &ndr_table_samr,
        b->flags |= dcerpc_flags;
 
        status = dcerpc_pipe_connect_b(tctx, &p, b, &ndr_table_samr,
-                                      credentials, NULL, tctx->lp_ctx);
+                                      credentials, tctx->ev, tctx->lp_ctx);
        torture_assert_ntstatus_ok(tctx, status, 
                "Failed to connect with schannel");
 
        torture_assert_ntstatus_ok(tctx, status, 
                "Failed to connect with schannel");
 
@@ -328,7 +328,7 @@ static bool test_schannel(struct torture_context *tctx,
        b->flags |= dcerpc_flags;
 
        status = dcerpc_pipe_connect_b(tctx, &p_samr2, b, &ndr_table_samr,
        b->flags |= dcerpc_flags;
 
        status = dcerpc_pipe_connect_b(tctx, &p_samr2, b, &ndr_table_samr,
-                                      credentials, NULL, tctx->lp_ctx);
+                                      credentials, tctx->ev, tctx->lp_ctx);
        torture_assert_ntstatus_ok(tctx, status, 
                "Failed to connect with schannel");
 
        torture_assert_ntstatus_ok(tctx, status, 
                "Failed to connect with schannel");
 
@@ -370,7 +370,7 @@ static bool test_schannel(struct torture_context *tctx,
        b->flags &= ~DCERPC_AUTH_OPTIONS;
 
        status = dcerpc_pipe_connect_b(tctx, &p_netlogon3, b, &ndr_table_netlogon,
        b->flags &= ~DCERPC_AUTH_OPTIONS;
 
        status = dcerpc_pipe_connect_b(tctx, &p_netlogon3, b, &ndr_table_netlogon,
-                                      credentials, NULL, tctx->lp_ctx);
+                                      credentials, tctx->ev, tctx->lp_ctx);
        torture_assert_ntstatus_ok(tctx, status, "Failed to connect without schannel");
 
        torture_assert(tctx, !test_netlogon_ex_ops(p_netlogon3, tctx, credentials, creds),
        torture_assert_ntstatus_ok(tctx, status, "Failed to connect without schannel");
 
        torture_assert(tctx, !test_netlogon_ex_ops(p_netlogon3, tctx, credentials, creds),
@@ -453,12 +453,12 @@ bool torture_rpc_schannel2(struct torture_context *torture)
 
        printf("Opening first connection\n");
        status = dcerpc_pipe_connect_b(torture, &p1, b, &ndr_table_netlogon,
 
        printf("Opening first connection\n");
        status = dcerpc_pipe_connect_b(torture, &p1, b, &ndr_table_netlogon,
-                                      credentials1, NULL, torture->lp_ctx);
+                                      credentials1, torture->ev, torture->lp_ctx);
        torture_assert_ntstatus_ok(torture, status, "Failed to connect with schannel");
 
        torture_comment(torture, "Opening second connection\n");
        status = dcerpc_pipe_connect_b(torture, &p2, b, &ndr_table_netlogon,
        torture_assert_ntstatus_ok(torture, status, "Failed to connect with schannel");
 
        torture_comment(torture, "Opening second connection\n");
        status = dcerpc_pipe_connect_b(torture, &p2, b, &ndr_table_netlogon,
-                                      credentials2, NULL, torture->lp_ctx);
+                                      credentials2, torture->ev, torture->lp_ctx);
        torture_assert_ntstatus_ok(torture, status, "Failed to connect with schannel");
 
        credentials1->netlogon_creds = NULL;
        torture_assert_ntstatus_ok(torture, status, "Failed to connect with schannel");
 
        credentials1->netlogon_creds = NULL;
index fcb828ddb2daa14e4c39b9eff4288bd7680c0048..0df7e576ee9175a66413a425c959186917cce506 100644 (file)
@@ -158,7 +158,11 @@ static bool test_secrets(struct torture_context *torture, const void *_data)
        binding->flags |= settings->bindoptions;
 
        torture_assert_ntstatus_ok(torture, 
        binding->flags |= settings->bindoptions;
 
        torture_assert_ntstatus_ok(torture, 
-                                  dcerpc_pipe_connect_b(torture, &p, binding, &ndr_table_lsarpc, cmdline_credentials, NULL, torture->lp_ctx),
+                                  dcerpc_pipe_connect_b(torture, &p, binding,
+                                                        &ndr_table_lsarpc,
+                                                        cmdline_credentials,
+                                                        torture->ev,
+                                                        torture->lp_ctx),
                                   "connect");
 
        if (!test_lsa_OpenPolicy2(p, torture, &handle)) {
                                   "connect");
 
        if (!test_lsa_OpenPolicy2(p, torture, &handle)) {
index c14be9e2d0726c38ce735d948f1af848db9b3def..d7482ddcf1f5e98b035435dedce835ce2b098da1 100644 (file)
@@ -63,8 +63,8 @@ static struct smbcli_state *connect_to_server(struct torture_context *tctx)
                                        lp_smb_ports(tctx->lp_ctx),
                                        share, NULL,
                                        cmdline_credentials, 
                                        lp_smb_ports(tctx->lp_ctx),
                                        share, NULL,
                                        cmdline_credentials, 
-                                       lp_resolve_context(tctx->lp_ctx), NULL, 
-                                       &options);
+                                       lp_resolve_context(tctx->lp_ctx),
+                                       tctx->ev, &options);
 
        if (!NT_STATUS_IS_OK(status)) {
                printf("failed to connect to //%s/%s: %s\n",
 
        if (!NT_STATUS_IS_OK(status)) {
                printf("failed to connect to //%s/%s: %s\n",
index a1333ac5bdfc91faaf5cbc63c4b16e366f562fd9..d4f19bb57a1ced02656c7a0283ee0294fc49f591 100644 (file)
@@ -84,7 +84,7 @@ static struct smbcli_state *connect_to_server(struct torture_context *tctx,
                                        lp_smb_ports(tctx->lp_ctx),
                                        share, NULL,
                                        creds, lp_resolve_context(tctx->lp_ctx),
                                        lp_smb_ports(tctx->lp_ctx),
                                        share, NULL,
                                        creds, lp_resolve_context(tctx->lp_ctx),
-                                       NULL, &options);
+                                       tctx->ev, &options);
 
        if (!NT_STATUS_IS_OK(status)) {
                printf("failed to connect to //%s/%s: %s\n",
 
        if (!NT_STATUS_IS_OK(status)) {
                printf("failed to connect to //%s/%s: %s\n",
index fe03e0dbbeb23ddccf97969d05a7753e098160ae..980e06602d91f3be3c9faa6b599f3c17f1af45c5 100644 (file)
@@ -24,6 +24,7 @@
 #include "includes.h"
 #include "lib/cmdline/popt_common.h"
 #include "lib/socket/socket.h"
 #include "includes.h"
 #include "lib/cmdline/popt_common.h"
 #include "lib/socket/socket.h"
+#include "lib/events/events.h"
 #include "system/network.h"
 #include "system/locale.h"
 #include "lib/socket/netif.h"
 #include "system/network.h"
 #include "system/locale.h"
 #include "lib/socket/netif.h"
@@ -180,7 +181,7 @@ static NTSTATUS do_node_query(struct nbt_name_socket *nbtsock,
 }
 
 
 }
 
 
-static bool process_one(struct loadparm_context *lp_ctx, 
+static bool process_one(struct loadparm_context *lp_ctx, struct event_context *ev,
                        struct interface *ifaces, const char *name, int nbt_port)
 {
        TALLOC_CTX *tmp_ctx = talloc_new(NULL);
                        struct interface *ifaces, const char *name, int nbt_port)
 {
        TALLOC_CTX *tmp_ctx = talloc_new(NULL);
@@ -211,7 +212,7 @@ static bool process_one(struct loadparm_context *lp_ctx,
                node_name = talloc_strdup(tmp_ctx, name);
        }
 
                node_name = talloc_strdup(tmp_ctx, name);
        }
 
-       nbtsock = nbt_name_socket_init(tmp_ctx, NULL, lp_iconv_convenience(lp_ctx));
+       nbtsock = nbt_name_socket_init(tmp_ctx, ev, lp_iconv_convenience(lp_ctx));
        
        if (options.root_port) {
                all_zero_addr = socket_address_from_strings(tmp_ctx, nbtsock->sock->backend_name, 
        
        if (options.root_port) {
                all_zero_addr = socket_address_from_strings(tmp_ctx, nbtsock->sock->backend_name, 
@@ -271,6 +272,7 @@ int main(int argc, const char *argv[])
 {
        bool ret = true;
        struct interface *ifaces;
 {
        bool ret = true;
        struct interface *ifaces;
+       struct event_context *ev;
        poptContext pc;
        int opt;
        enum {
        poptContext pc;
        int opt;
        enum {
@@ -356,13 +358,17 @@ int main(int argc, const char *argv[])
        }
 
        load_interfaces(NULL, lp_interfaces(cmdline_lp_ctx), &ifaces);
        }
 
        load_interfaces(NULL, lp_interfaces(cmdline_lp_ctx), &ifaces);
-       
+
+       ev = event_context_init(talloc_autofree_context());
+
        while (poptPeekArg(pc)) {
                const char *name = poptGetArg(pc);
 
        while (poptPeekArg(pc)) {
                const char *name = poptGetArg(pc);
 
-               ret &= process_one(cmdline_lp_ctx, ifaces, name, lp_nbt_port(cmdline_lp_ctx));
+               ret &= process_one(cmdline_lp_ctx, ev, ifaces, name, lp_nbt_port(cmdline_lp_ctx));
        }
 
        }
 
+       talloc_free(ev);
+
        talloc_free(ifaces);
 
        poptFreeContext(pc);
        talloc_free(ifaces);
 
        poptFreeContext(pc);
index 0c9a41fd70d7143cc550acc5783e7dfd81b3320c..07c0e4f31e175923dab6458563d98010c7446eac 100644 (file)
@@ -461,6 +461,10 @@ static void manage_gensec_request(enum stdio_helper_mode stdio_helper_mode,
                return;
        }
 
                return;
        }
 
+       ev = event_context_init(state);
+       if (!ev) {
+               exit(1);
+       }
        /* setup gensec */
        if (!(state->gensec_state)) {
                switch (stdio_helper_mode) {
        /* setup gensec */
        if (!(state->gensec_state)) {
                switch (stdio_helper_mode) {
@@ -468,7 +472,7 @@ static void manage_gensec_request(enum stdio_helper_mode stdio_helper_mode,
                case NTLMSSP_CLIENT_1:
                        /* setup the client side */
 
                case NTLMSSP_CLIENT_1:
                        /* setup the client side */
 
-                       nt_status = gensec_client_start(NULL, &state->gensec_state, NULL, lp_ctx);
+                       nt_status = gensec_client_start(NULL, &state->gensec_state, ev, lp_ctx);
                        if (!NT_STATUS_IS_OK(nt_status)) {
                                exit(1);
                        }
                        if (!NT_STATUS_IS_OK(nt_status)) {
                                exit(1);
                        }
@@ -476,10 +480,6 @@ static void manage_gensec_request(enum stdio_helper_mode stdio_helper_mode,
                        break;
                case GSS_SPNEGO_SERVER:
                case SQUID_2_5_NTLMSSP:
                        break;
                case GSS_SPNEGO_SERVER:
                case SQUID_2_5_NTLMSSP:
-                       ev = event_context_init(state);
-                       if (!ev) {
-                               exit(1);
-                       }
                        msg = messaging_client_init(state, lp_messaging_path(state, lp_ctx), 
                                                    lp_iconv_convenience(lp_ctx), ev);
                        if (!msg) {
                        msg = messaging_client_init(state, lp_messaging_path(state, lp_ctx), 
                                                    lp_iconv_convenience(lp_ctx), ev);
                        if (!msg) {