Remove another global_loadparm instance.
authorJelmer Vernooij <jelmer@samba.org>
Thu, 21 Feb 2008 17:43:02 +0000 (18:43 +0100)
committerJelmer Vernooij <jelmer@samba.org>
Thu, 21 Feb 2008 17:43:02 +0000 (18:43 +0100)
(This used to be commit ccb29c0b463f5ccb53553f0a1c411ad77a84482a)

source4/libcli/wrepl/winsrepl.c
source4/torture/nbt/winsreplication.c
source4/wrepl_server/wrepl_out_helpers.c

index 87e5282539d84ce940c0855a8c90d9639d92870f..3e7793c0c7113750ad31765e518aed8d878b548e 100644 (file)
@@ -311,6 +311,14 @@ static void wrepl_connect_handler(struct composite_context *creq)
        composite_done(result);
 }
 
+const char *wrepl_best_ip(struct loadparm_context *lp_ctx, const char *peer_ip)
+{
+       struct interface *ifaces;
+       load_interfaces(lp_ctx, lp_interfaces(lp_ctx), &ifaces);
+       return iface_best_ip(ifaces, peer_ip);
+}
+
+
 /*
   connect a wrepl_socket to a WINS server
 */
@@ -334,12 +342,6 @@ struct composite_context *wrepl_connect_send(struct wrepl_socket *wrepl_socket,
        state->result           = result;
        state->wrepl_socket     = wrepl_socket;
 
-       if (!our_ip) {
-               struct interface *ifaces;
-               load_interfaces(state, lp_interfaces(global_loadparm), &ifaces);
-               our_ip = iface_best_ip(ifaces, peer_ip);
-       }
-
        us = socket_address_from_strings(state, wrepl_socket->sock->backend_name, 
                                         our_ip, 0);
        if (composite_nomem(us, result)) return result;
index 94f797bf52d0fa02a0ffc640efe529e6333ec681..470eee831003d9c20e66070ab2e530882e5d1977 100644 (file)
@@ -107,10 +107,10 @@ static bool test_assoc_ctx1(struct torture_context *tctx)
        wrepl_socket2 = wrepl_socket_init(tctx, NULL, 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), NULL, address);
+       status = wrepl_connect(wrepl_socket1, lp_resolve_context(tctx->lp_ctx), wrepl_best_ip(tctx->lp_ctx, address), address);
        CHECK_STATUS(tctx, status, NT_STATUS_OK);
 
-       status = wrepl_connect(wrepl_socket2, lp_resolve_context(tctx->lp_ctx), NULL, address);
+       status = wrepl_connect(wrepl_socket2, lp_resolve_context(tctx->lp_ctx), wrepl_best_ip(tctx->lp_ctx, address), address);
        CHECK_STATUS(tctx, status, NT_STATUS_OK);
 
        torture_comment(tctx, "Send a start association request (conn1)\n");
@@ -189,7 +189,7 @@ static bool test_assoc_ctx2(struct torture_context *tctx)
        wrepl_socket = wrepl_socket_init(tctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
        
        torture_comment(tctx, "Setup wrepl connections\n");
-       status = wrepl_connect(wrepl_socket, lp_resolve_context(tctx->lp_ctx), NULL, address);
+       status = wrepl_connect(wrepl_socket, lp_resolve_context(tctx->lp_ctx), wrepl_best_ip(tctx->lp_ctx, address), address);
        CHECK_STATUS(tctx, status, NT_STATUS_OK);
 
        torture_comment(tctx, "Send 1st start association request\n");
@@ -258,7 +258,7 @@ static bool test_wins_replication(struct torture_context *tctx)
        wrepl_socket = wrepl_socket_init(tctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
        
        torture_comment(tctx, "Setup wrepl connections\n");
-       status = wrepl_connect(wrepl_socket, lp_resolve_context(tctx->lp_ctx), NULL, address);
+       status = wrepl_connect(wrepl_socket, lp_resolve_context(tctx->lp_ctx), wrepl_best_ip(tctx->lp_ctx, address), address);
        CHECK_STATUS(tctx, status, NT_STATUS_OK);
 
        torture_comment(tctx, "Send a start association request\n");
@@ -557,7 +557,7 @@ static struct test_wrepl_conflict_conn *test_create_conflict_ctx(
        if (!ctx->pull) return NULL;
 
        torture_comment(tctx, "Setup wrepl conflict pull connection\n");
-       status = wrepl_connect(ctx->pull, lp_resolve_context(tctx->lp_ctx), NULL, ctx->address);
+       status = wrepl_connect(ctx->pull, lp_resolve_context(tctx->lp_ctx), wrepl_best_ip(tctx->lp_ctx, ctx->address), ctx->address);
        if (!NT_STATUS_IS_OK(status)) return NULL;
 
        status = wrepl_associate(ctx->pull, &associate);
@@ -724,7 +724,7 @@ static bool test_wrepl_update_one(struct torture_context *tctx,
 
        wrepl_socket = wrepl_socket_init(ctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
 
-       status = wrepl_connect(wrepl_socket, lp_resolve_context(tctx->lp_ctx), NULL, ctx->address);
+       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_associate(wrepl_socket, &associate);
index 72d55985bbcaeb835cbda736b7f8b468d9f03fa3..12605196ab6f11b2b472e232ab47bc0f161d7f52 100644 (file)
@@ -194,7 +194,7 @@ static struct composite_context *wreplsrv_out_connect_send(struct wreplsrv_partn
        state->wreplconn= wreplconn;
        state->c_req    = wrepl_connect_send(wreplconn->sock,
                                             lp_resolve_context(service->task->lp_ctx),
-                                            partner->our_address,
+                                            partner->our_address?partner->our_address:wrepl_best_ip(service->task->lp_ctx, partner->address),
                                             partner->address);
        if (!state->c_req) goto failed;