From 304554115a2f2dc316386a9ea5bec237d67f595f Mon Sep 17 00:00:00 2001 From: Steven Danneman Date: Wed, 3 Sep 2008 15:31:39 -0700 Subject: Cleanup of DC enumeration in get_dcs() This is a fix for a few small inefficiencies/bugs in the get_dcs() path. * because the third add_one_dc_unique() loop was outside the ADS check all DCs returned from the non-sitename lookup were being tacked onto the dc_name_ip list twice. * add_one_dc_unique() now checks if the given IP address already exists before adding it to the list, making the returned list actually unique * added more thorough doxygen comment headers (This used to be commit cb2d488e1dbd90953c496c5e25d648977884f7e3) --- source3/lib/util_sock.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'source3/lib/util_sock.c') diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c index 7356b3ec35..e20768ed89 100644 --- a/source3/lib/util_sock.c +++ b/source3/lib/util_sock.c @@ -1379,11 +1379,22 @@ int open_socket_out(int type, return res; } -/**************************************************************************** - Create an outgoing TCP socket to any of the addrs. This is for - simultaneous connects to port 445 and 139 of a host or even a variety - of DC's all of which are equivalent for our purposes. -**************************************************************************/ +/******************************************************************* + Create an outgoing TCP socket to the first addr that connects. + + This is for simultaneous connection attempts to port 445 and 139 of a host + or for simultatneous connection attempts to multiple DCs at once. We return + a socket fd of the first successful connection. + + @param[in] addrs list of Internet addresses and ports to connect to + @param[in] num_addrs number of address/port pairs in the addrs list + @param[in] timeout time after which we stop waiting for a socket connection + to succeed, given in milliseconds + @param[out] fd_index the entry in addrs which we successfully connected to + @param[out] fd fd of the open and connected socket + @return true on a successful connection, false if all connection attempts + failed or we timed out +*******************************************************************/ bool open_any_socket_out(struct sockaddr_storage *addrs, int num_addrs, int timeout, int *fd_index, int *fd) -- cgit