Revert "TODO NOT NEEDED cli_connect_sock_send/recv return sock_storage"
authorStefan Metzmacher <metze@samba.org>
Wed, 21 Jun 2017 14:02:50 +0000 (16:02 +0200)
committerStefan Metzmacher <metze@samba.org>
Mon, 18 Feb 2019 11:47:34 +0000 (12:47 +0100)
This reverts commit 6c0bd63a73bf8140fb92ea6896008109a0598097.

source3/libsmb/cliconnect.c

index f612dc2d53afa2d7735e6da4f971914bf713ebe3..fcc8e0b67b8a0475ed51b43657e14e42cb543e51 100644 (file)
@@ -2548,12 +2548,9 @@ fail:
 }
 
 struct cli_connect_sock_state {
-       struct sockaddr_storage *addrs;
-       size_t num_addrs;
        const char **called_names;
        const char **calling_names;
        int *called_types;
-       size_t chosen_index;
        int fd;
        uint16_t port;
 };
@@ -2573,7 +2570,7 @@ static struct tevent_req *cli_connect_sock_send(
        struct tevent_req *req, *subreq;
        struct cli_connect_sock_state *state;
        struct sockaddr_storage *addrs;
-       size_t i;
+       unsigned i, num_addrs;
        NTSTATUS status;
 
        req = tevent_req_create(mem_ctx, &state,
@@ -2591,18 +2588,18 @@ static struct tevent_req *cli_connect_sock_send(
                 */
 
                status = resolve_name_list(state, host, name_type,
-                                          &state->addrs, &state->num_addrs);
+                                          &addrs, &num_addrs);
                if (!NT_STATUS_IS_OK(status)) {
                        tevent_req_nterror(req, status);
                        return tevent_req_post(req, ev);
                }
        } else {
-               state->addrs = talloc_array(state, struct sockaddr_storage, 1);
-               if (tevent_req_nomem(state->addrs, req)) {
+               addrs = talloc_array(state, struct sockaddr_storage, 1);
+               if (tevent_req_nomem(addrs, req)) {
                        return tevent_req_post(req, ev);
                }
-               state->addrs[0] = *pss;
-               state->num_addrs = 1;
+               addrs[0] = *pss;
+               num_addrs = 1;
        }
 
        state->called_names = talloc_array(state, const char *, num_addrs);
@@ -2617,16 +2614,15 @@ static struct tevent_req *cli_connect_sock_send(
        if (tevent_req_nomem(state->calling_names, req)) {
                return tevent_req_post(req, ev);
        }
-       for (i=0; i<state->num_addrs; i++) {
+       for (i=0; i<num_addrs; i++) {
                state->called_names[i] = host;
                state->called_types[i] = name_type;
                state->calling_names[i] = myname;
        }
 
        subreq = smbsock_any_connect_send(
-               state, ev, state->addrs,
-               state->called_names, state->called_types, state->calling_names,
-               NULL, state->num_addrs, port);
+               state, ev, addrs, state->called_names, state->called_types,
+               state->calling_names, NULL, num_addrs, port);
        if (tevent_req_nomem(subreq, req)) {
                return tevent_req_post(req, ev);
        }
@@ -2642,8 +2638,7 @@ static void cli_connect_sock_done(struct tevent_req *subreq)
                req, struct cli_connect_sock_state);
        NTSTATUS status;
 
-       status = smbsock_any_connect_recv(subreq, &state->fd,
-                                         &state->chosen_index,
+       status = smbsock_any_connect_recv(subreq, &state->fd, NULL,
                                          &state->port);
        TALLOC_FREE(subreq);
        if (tevent_req_nterror(req, status)) {
@@ -2654,9 +2649,7 @@ static void cli_connect_sock_done(struct tevent_req *subreq)
 }
 
 static NTSTATUS cli_connect_sock_recv(struct tevent_req *req,
-                                     int *pfd,
-                                     struct sockaddr_storage *pss,
-                                     uint16_t *pport)
+                                     int *pfd, uint16_t *pport)
 {
        struct cli_connect_sock_state *state = tevent_req_data(
                req, struct cli_connect_sock_state);
@@ -2666,7 +2659,6 @@ static NTSTATUS cli_connect_sock_recv(struct tevent_req *req,
                return status;
        }
        *pfd = state->fd;
-       *pss = state->addrs[state->chosen_index];
        *pport = state->port;
        return NT_STATUS_OK;
 }