summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorschmidt <douglascraigschmidt@users.noreply.github.com>2001-05-03 18:12:11 +0000
committerschmidt <douglascraigschmidt@users.noreply.github.com>2001-05-03 18:12:11 +0000
commita7e39417a2f37ca95093bd1afc8e04fc28c52a72 (patch)
treee3eac5ed9312389bea5b41bbfd7432b0a7aa72f5
parent1e2cf1c06c570d991b13cc9a921962b066d62562 (diff)
downloadATCD-a7e39417a2f37ca95093bd1afc8e04fc28c52a72.tar.gz
ChangeLogTag:Thu May 3 06:58:29 2001 Douglas C. Schmidt <schmidt@tango.doc.wustl.edu>
-rw-r--r--ChangeLog15
-rw-r--r--ChangeLogs/ChangeLog-02a15
-rw-r--r--ChangeLogs/ChangeLog-03a15
-rw-r--r--ace/Acceptor.cpp16
-rw-r--r--ace/Acceptor.h6
-rw-r--r--ace/SOCK_Acceptor.cpp6
-rw-r--r--ace/SOCK_Acceptor.h3
7 files changed, 75 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 82fbd33593d..7234c943ec9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,20 @@
Thu May 3 06:58:29 2001 Douglas C. Schmidt <schmidt@tango.doc.wustl.edu>
+ * ace/Acceptor.{h,cpp},
+ * ace/SOCK_Acceptor.{h,cpp}: When the number of clients
+ connecting to a server exceeds the process handle limit the
+ server would busy loop. The Acceptor accept_svc_handler()
+ method is called which (1) constructs a handler and (2) attempts
+ to accept the connection, which fails (because there is no
+ available handle). The handler is destructed, but the connect
+ request is still queued and so the acceptor gets called back
+ again.... and so on until one of the client which is already
+ connected disconnects and frees up a descriptor. Changed the
+ Acceptor the close and reopen the connection when accept()
+ fails. A check is done to make sure address reuse is set. So
+ this fix will only work in case where it is set. Thanks to
+ Dominic Hughes <dominic@aersoft.ie> for this fix.
+
* ace/Unbounded_Queue.h: The comment was incorrect for
~ACE_Unbounded_Queue. Thanks to Johnny Willemsen for
reporting this.
diff --git a/ChangeLogs/ChangeLog-02a b/ChangeLogs/ChangeLog-02a
index 82fbd33593d..7234c943ec9 100644
--- a/ChangeLogs/ChangeLog-02a
+++ b/ChangeLogs/ChangeLog-02a
@@ -1,5 +1,20 @@
Thu May 3 06:58:29 2001 Douglas C. Schmidt <schmidt@tango.doc.wustl.edu>
+ * ace/Acceptor.{h,cpp},
+ * ace/SOCK_Acceptor.{h,cpp}: When the number of clients
+ connecting to a server exceeds the process handle limit the
+ server would busy loop. The Acceptor accept_svc_handler()
+ method is called which (1) constructs a handler and (2) attempts
+ to accept the connection, which fails (because there is no
+ available handle). The handler is destructed, but the connect
+ request is still queued and so the acceptor gets called back
+ again.... and so on until one of the client which is already
+ connected disconnects and frees up a descriptor. Changed the
+ Acceptor the close and reopen the connection when accept()
+ fails. A check is done to make sure address reuse is set. So
+ this fix will only work in case where it is set. Thanks to
+ Dominic Hughes <dominic@aersoft.ie> for this fix.
+
* ace/Unbounded_Queue.h: The comment was incorrect for
~ACE_Unbounded_Queue. Thanks to Johnny Willemsen for
reporting this.
diff --git a/ChangeLogs/ChangeLog-03a b/ChangeLogs/ChangeLog-03a
index 82fbd33593d..7234c943ec9 100644
--- a/ChangeLogs/ChangeLog-03a
+++ b/ChangeLogs/ChangeLog-03a
@@ -1,5 +1,20 @@
Thu May 3 06:58:29 2001 Douglas C. Schmidt <schmidt@tango.doc.wustl.edu>
+ * ace/Acceptor.{h,cpp},
+ * ace/SOCK_Acceptor.{h,cpp}: When the number of clients
+ connecting to a server exceeds the process handle limit the
+ server would busy loop. The Acceptor accept_svc_handler()
+ method is called which (1) constructs a handler and (2) attempts
+ to accept the connection, which fails (because there is no
+ available handle). The handler is destructed, but the connect
+ request is still queued and so the acceptor gets called back
+ again.... and so on until one of the client which is already
+ connected disconnects and frees up a descriptor. Changed the
+ Acceptor the close and reopen the connection when accept()
+ fails. A check is done to make sure address reuse is set. So
+ this fix will only work in case where it is set. Thanks to
+ Dominic Hughes <dominic@aersoft.ie> for this fix.
+
* ace/Unbounded_Queue.h: The comment was incorrect for
~ACE_Unbounded_Queue. Thanks to Johnny Willemsen for
reporting this.
diff --git a/ace/Acceptor.cpp b/ace/Acceptor.cpp
index 173e4407049..6c46e07f827 100644
--- a/ace/Acceptor.cpp
+++ b/ace/Acceptor.cpp
@@ -66,6 +66,8 @@ ACE_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::open
ACE_TRACE ("ACE_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::open");
this->flags_ = flags;
this->use_select_ = use_select;
+ this->reuse_addr_ = reuse_addr;
+ this->peer_acceptor_addr_ = local_addr;
// Must supply a valid Reactor to Acceptor::open()...
@@ -101,7 +103,9 @@ ACE_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::open
template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1>
ACE_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::ACE_Acceptor (ACE_Reactor *reactor,
int use_select)
- : use_select_ (use_select)
+ : use_select_ (use_select),
+ flags_ (0),
+ reuse_addr_ (1)
{
ACE_TRACE ("ACE_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::ACE_Acceptor");
@@ -285,6 +289,16 @@ ACE_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::accept_svc_handler
{
// Close down handler to avoid memory leaks.
svc_handler->close (0);
+
+ // If <reuse_addr> is true then we will close the socket and
+ // open it again...
+ if (this->reuse_addr_)
+ {
+ this->peer_acceptor_.close ();
+ this->peer_acceptor_.open (this->peer_acceptor_addr_,
+ this->reuse_addr_);
+ }
+
return -1;
}
else
diff --git a/ace/Acceptor.h b/ace/Acceptor.h
index 60e31c49959..0c9fb6dc934 100644
--- a/ace/Acceptor.h
+++ b/ace/Acceptor.h
@@ -181,6 +181,9 @@ protected:
/// Concrete factory for accepting connections from clients...
ACE_PEER_ACCEPTOR peer_acceptor_;
+ /// Needed to reopen the socket if <accept> fails.
+ ACE_PEER_ACCEPTOR_ADDR peer_acceptor_addr_;
+
/**
* Flags that indicate how <SVC_HANDLER>'s should be initialized
* prior to being activated. Right now, the only flag that is
@@ -192,6 +195,9 @@ protected:
/// Flag that indicates whether it shall use <select> in the
/// <accept>-loop.
int use_select_;
+
+ /// Needed to reopen the socket if <accept> fails.
+ int reuse_addr_;
};
/**
diff --git a/ace/SOCK_Acceptor.cpp b/ace/SOCK_Acceptor.cpp
index 2bdff4c00a4..8477e4809ca 100644
--- a/ace/SOCK_Acceptor.cpp
+++ b/ace/SOCK_Acceptor.cpp
@@ -342,3 +342,9 @@ ACE_SOCK_Acceptor::ACE_SOCK_Acceptor (const ACE_Addr &local_sap,
ACE_LIB_TEXT ("%p\n"),
ACE_LIB_TEXT ("ACE_SOCK_Acceptor")));
}
+
+int
+ACE_SOCK_Acceptor::close (void)
+{
+ return ACE_SOCK::close ();
+}
diff --git a/ace/SOCK_Acceptor.h b/ace/SOCK_Acceptor.h
index 5a65b0e46af..d1ffcd7c36e 100644
--- a/ace/SOCK_Acceptor.h
+++ b/ace/SOCK_Acceptor.h
@@ -88,6 +88,9 @@ public:
int backlog = ACE_DEFAULT_BACKLOG,
int protocol = 0);
+ /// Close the socket. Returns 0 on success and -1 on failure.
+ int close (void);
+
/// Default dtor.
~ACE_SOCK_Acceptor (void);