diff options
author | Andrew Bartlett <abartlet@samba.org> | 2011-06-24 16:26:23 +1000 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2011-06-24 16:26:23 +1000 |
commit | 6da26870e0ae5acd6ff49a30ec2f6886b44d095e (patch) | |
tree | 850c71039563c16a5d563c47e7ba2ab645baf198 /source3/libsmb/smbsock_connect.c | |
parent | 6925a799d04c6fa59dd2ddef1f5510f9bb7d17d1 (diff) | |
parent | 2610c05b5b95cc7036b3d6dfb894c6cfbdb68483 (diff) | |
download | samba-6da26870e0ae5acd6ff49a30ec2f6886b44d095e.tar.gz samba-6da26870e0ae5acd6ff49a30ec2f6886b44d095e.tar.bz2 samba-6da26870e0ae5acd6ff49a30ec2f6886b44d095e.zip |
Merge 2610c05b5b95cc7036b3d6dfb894c6cfbdb68483 as Samba-4.0alpha16
Diffstat (limited to 'source3/libsmb/smbsock_connect.c')
-rw-r--r-- | source3/libsmb/smbsock_connect.c | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/source3/libsmb/smbsock_connect.c b/source3/libsmb/smbsock_connect.c index fd8626f5ad..3a228b1b9e 100644 --- a/source3/libsmb/smbsock_connect.c +++ b/source3/libsmb/smbsock_connect.c @@ -18,7 +18,8 @@ */ #include "includes.h" -#include "../lib/async_req/async_sock.h" +#include "../lib/util/tevent_ntstatus.h" +#include "client.h" #include "async_smb.h" #include "libsmb/nmblib.h" @@ -215,7 +216,7 @@ struct tevent_req *smbsock_connect_send(TALLOC_CTX *mem_ctx, state->called_type = (called_type != -1) ? called_type : 0x20; state->calling_name = - (calling_name != NULL) ? calling_name : global_myname(); + (calling_name != NULL) ? calling_name : lp_netbios_name(); state->calling_type = (calling_type != -1) ? calling_type : 0x00; @@ -270,6 +271,7 @@ static int smbsock_connect_state_destructor( { if (state->sock != -1) { close(state->sock); + state->sock = -1; } return 0; } @@ -368,7 +370,7 @@ NTSTATUS smbsock_connect_recv(struct tevent_req *req, int *sock, NTSTATUS smbsock_connect(const struct sockaddr_storage *addr, uint16_t port, const char *called_name, int called_type, const char *calling_name, int calling_type, - int *pfd, uint16_t *ret_port) + int *pfd, uint16_t *ret_port, int sec_timeout) { TALLOC_CTX *frame = talloc_stackframe(); struct event_context *ev; @@ -385,6 +387,11 @@ NTSTATUS smbsock_connect(const struct sockaddr_storage *addr, uint16_t port, if (req == NULL) { goto fail; } + if ((sec_timeout != 0) && + !tevent_req_set_endtime( + req, ev, timeval_current_ofs(sec_timeout, 0))) { + goto fail; + } if (!tevent_req_poll_ntstatus(req, ev, &status)) { goto fail; } @@ -568,7 +575,7 @@ static void smbsock_any_connect_connected(struct tevent_req *subreq) } state->num_received += 1; - if (state->num_received <= state->num_addrs) { + if (state->num_received < state->num_addrs) { /* * More addrs pending, wait for the others */ @@ -610,6 +617,7 @@ NTSTATUS smbsock_any_connect(const struct sockaddr_storage *addrs, int *calling_types, size_t num_addrs, uint16_t port, + int sec_timeout, int *pfd, size_t *chosen_index, uint16_t *chosen_port) { @@ -629,6 +637,11 @@ NTSTATUS smbsock_any_connect(const struct sockaddr_storage *addrs, if (req == NULL) { goto fail; } + if ((sec_timeout != 0) && + !tevent_req_set_endtime( + req, ev, timeval_current_ofs(sec_timeout, 0))) { + goto fail; + } if (!tevent_req_poll_ntstatus(req, ev, &status)) { goto fail; } |