summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
authorGerald Carter <jerry@samba.org>2003-07-16 02:17:55 +0000
committerGerald Carter <jerry@samba.org>2003-07-16 02:17:55 +0000
commit6b814c9908c307abf427af37c00332de5e369eb4 (patch)
treea14e967f015601212828f6600f8cb743f351819c /source3/lib
parentbd9a42fa8df5eb37af9f23ff4498c4747f084131 (diff)
downloadsamba-6b814c9908c307abf427af37c00332de5e369eb4.tar.gz
samba-6b814c9908c307abf427af37c00332de5e369eb4.tar.bz2
samba-6b814c9908c307abf427af37c00332de5e369eb4.zip
Volker's patch for open_socket_out() to speed up connections
(This used to be commit 7d63b690004a59316a70059db0d9ad0ea9001288)
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/util_sock.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c
index 8c171852ab..1bd4c3a96b 100644
--- a/source3/lib/util_sock.c
+++ b/source3/lib/util_sock.c
@@ -654,8 +654,8 @@ int open_socket_out(int type, struct in_addr *addr, int port ,int timeout)
{
struct sockaddr_in sock_out;
int res,ret;
- int connect_loop = 250; /* 250 milliseconds */
- int loops = (timeout) / connect_loop;
+ int connect_loop = 10;
+ int increment = 10;
/* create a socket to write to */
res = socket(PF_INET, type, 0);
@@ -681,8 +681,13 @@ connect_again:
/* Some systems return EAGAIN when they mean EINPROGRESS */
if (ret < 0 && (errno == EINPROGRESS || errno == EALREADY ||
- errno == EAGAIN) && loops--) {
+ errno == EAGAIN) && (connect_loop < timeout) ) {
msleep(connect_loop);
+ connect_loop += increment;
+ if (increment < 250) {
+ /* After 8 rounds we end up at a max of 255 msec */
+ increment *= 1.5;
+ }
goto connect_again;
}