diff options
author | Volker Lendecke <vl@samba.org> | 2011-04-17 20:16:07 +0200 |
---|---|---|
committer | Volker Lendecke <vl@samba.org> | 2011-04-25 09:50:32 +0200 |
commit | 23a6af46c84cd9b738af403d80c5187d858eac03 (patch) | |
tree | 22dc5bca73c8bf14b5e7be550e65a8d9de3520c8 /source3/libsmb/smbsock_connect.c | |
parent | f7bc84409a7a6736ec2cf1110dd7200a954e3b7e (diff) | |
download | samba-23a6af46c84cd9b738af403d80c5187d858eac03.tar.gz |
s3: Add a 10-second timeout for the 445 or netbios connection to a DC
Diffstat (limited to 'source3/libsmb/smbsock_connect.c')
-rw-r--r-- | source3/libsmb/smbsock_connect.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/source3/libsmb/smbsock_connect.c b/source3/libsmb/smbsock_connect.c index fd8626f5ad2..9dc2f689343 100644 --- a/source3/libsmb/smbsock_connect.c +++ b/source3/libsmb/smbsock_connect.c @@ -368,7 +368,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 +385,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; } @@ -610,6 +615,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 +635,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; } |