summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvzykov <vzykov@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2009-10-26 10:45:28 +0000
committervzykov <vzykov@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2009-10-26 10:45:28 +0000
commit09508d4279743b6034143ef9bf322d6b4273dcbd (patch)
tree4f5172215cec9cb0ada9c2d3aa3ebe170f408a27
parent69e68bb81950ec1824cf57dd8f667c59c1d68af4 (diff)
downloadATCD-09508d4279743b6034143ef9bf322d6b4273dcbd.tar.gz
Mon Oct 26 10:41:43 UTC 2009 Vladimir Zykov <vladimir.zykov@prismtech.com>
* protocols/ace/HTBP/HTBP_Inside_Squid_Filter.cpp: * protocols/ace/HTBP/HTBP_Session.h: * protocols/ace/HTBP/HTBP_Environment.cpp: * protocols/ace/HTBP/HTBP_Channel.h: * protocols/ace/HTBP/HTBP_Filter_Factory.h: * protocols/ace/HTBP/HTBP_Session.cpp: * protocols/ace/HTBP/HTBP_Session.inl: * protocols/ace/HTBP/HTBP_ID_Requestor.cpp: * protocols/ace/HTBP/HTBP_Channel.inl: * protocols/ace/HTBP/HTBP_Channel.cpp: * protocols/ace/HTBP/HTBP_Environment.h: * protocols/ace/HTBP/HTBP_Filter_Factory.cpp: Simplified the code and fixed several memory leaks.
-rw-r--r--ACE/ChangeLog16
-rw-r--r--ACE/protocols/ace/HTBP/HTBP_Channel.cpp22
-rw-r--r--ACE/protocols/ace/HTBP/HTBP_Channel.h3
-rw-r--r--ACE/protocols/ace/HTBP/HTBP_Channel.inl3
-rw-r--r--ACE/protocols/ace/HTBP/HTBP_Environment.cpp2
-rw-r--r--ACE/protocols/ace/HTBP/HTBP_Environment.h2
-rw-r--r--ACE/protocols/ace/HTBP/HTBP_Filter_Factory.cpp1
-rw-r--r--ACE/protocols/ace/HTBP/HTBP_Filter_Factory.h2
-rw-r--r--ACE/protocols/ace/HTBP/HTBP_ID_Requestor.cpp2
-rw-r--r--ACE/protocols/ace/HTBP/HTBP_Inside_Squid_Filter.cpp4
-rw-r--r--ACE/protocols/ace/HTBP/HTBP_Session.cpp32
-rw-r--r--ACE/protocols/ace/HTBP/HTBP_Session.h13
-rw-r--r--ACE/protocols/ace/HTBP/HTBP_Session.inl2
13 files changed, 53 insertions, 51 deletions
diff --git a/ACE/ChangeLog b/ACE/ChangeLog
index 67bff87cf27..b99a0dc5304 100644
--- a/ACE/ChangeLog
+++ b/ACE/ChangeLog
@@ -1,3 +1,19 @@
+Mon Oct 26 10:41:43 UTC 2009 Vladimir Zykov <vladimir.zykov@prismtech.com>
+
+ * protocols/ace/HTBP/HTBP_Inside_Squid_Filter.cpp:
+ * protocols/ace/HTBP/HTBP_Session.h:
+ * protocols/ace/HTBP/HTBP_Environment.cpp:
+ * protocols/ace/HTBP/HTBP_Channel.h:
+ * protocols/ace/HTBP/HTBP_Filter_Factory.h:
+ * protocols/ace/HTBP/HTBP_Session.cpp:
+ * protocols/ace/HTBP/HTBP_Session.inl:
+ * protocols/ace/HTBP/HTBP_ID_Requestor.cpp:
+ * protocols/ace/HTBP/HTBP_Channel.inl:
+ * protocols/ace/HTBP/HTBP_Channel.cpp:
+ * protocols/ace/HTBP/HTBP_Environment.h:
+ * protocols/ace/HTBP/HTBP_Filter_Factory.cpp:
+ Simplified the code and fixed several memory leaks.
+
Mon Oct 26 10:23:13 UTC 2009 Olli Savia <ops@iki.fi>
* tests/run_test.lst:
diff --git a/ACE/protocols/ace/HTBP/HTBP_Channel.cpp b/ACE/protocols/ace/HTBP/HTBP_Channel.cpp
index 1d2c48f5fd6..b74b99cda0d 100644
--- a/ACE/protocols/ace/HTBP/HTBP_Channel.cpp
+++ b/ACE/protocols/ace/HTBP/HTBP_Channel.cpp
@@ -38,7 +38,7 @@ ACE::HTBP::Channel::Channel (ACE::HTBP::Session *s)
error_buffer_ (0)
{
ACE_NEW (this->notifier_,ACE::HTBP::Notifier(this));
- this->filter_ = get_filter ();
+ this->filter_ = ACE::HTBP::Filter_Factory::get_filter (this->session_ != 0);
this->request_count_ = static_cast<unsigned long> (ACE_OS::time());
}
@@ -55,7 +55,7 @@ ACE::HTBP::Channel::Channel (ACE_SOCK_Stream &s)
error_buffer_ (0)
{
- filter_ = get_filter ();
+ this->filter_ = ACE::HTBP::Filter_Factory::get_filter (this->session_ != 0);
this->request_count_ = static_cast<unsigned long> (ACE_OS::time());
}
@@ -70,7 +70,7 @@ ACE::HTBP::Channel::Channel (ACE_HANDLE h)
state_ (Init),
error_buffer_ (0)
{
- filter_ = get_filter ();
+ this->filter_ = ACE::HTBP::Filter_Factory::get_filter (this->session_ != 0);
this->request_count_ = static_cast<unsigned long> (ACE_OS::time());
}
@@ -395,6 +395,7 @@ ACE::HTBP::Channel::recvv (iovec iov[],
{
int ndx = 0;
iovec *iov2 = new iovec[iovcnt];
+ ACE_Auto_Array_Ptr<iovec> guard (iov2);
for (int i = 0; i < iovcnt; i++)
{
size_t n = ACE_MIN ((size_t) iov[i].iov_len ,
@@ -414,7 +415,6 @@ ACE::HTBP::Channel::recvv (iovec iov[],
}
if (ndx > 0)
result += this->ace_stream_.recvv(iov2,ndx,timeout);
- delete [] iov2;
}
else
result = this->ace_stream_.recvv(iov,iovcnt,timeout);
@@ -548,18 +548,4 @@ ACE::HTBP::Channel::disable (int value) const
return 0;//this->ace_stream_.disable(value);
}
-ACE::HTBP::Filter *
-ACE::HTBP::Channel::get_filter ()
-{
- ACE::HTBP::Filter_Factory *factory = 0;
-
- // @todo Should I be throwing an exception here if
- // memory is not allocated right ?
- ACE_NEW_RETURN (factory,
- ACE::HTBP::Filter_Factory,
- 0);
- int inside = (this->session_ != 0);
- return factory->get_filter (inside);
-}
-
ACE_END_VERSIONED_NAMESPACE_DECL
diff --git a/ACE/protocols/ace/HTBP/HTBP_Channel.h b/ACE/protocols/ace/HTBP/HTBP_Channel.h
index b33d446e40b..9756ceebf26 100644
--- a/ACE/protocols/ace/HTBP/HTBP_Channel.h
+++ b/ACE/protocols/ace/HTBP/HTBP_Channel.h
@@ -235,9 +235,6 @@ namespace ACE
private:
- /// Get the filter from the Filter_Factory
- Filter * get_filter ();
-
/// The filter_ is a pluggable component used to manage the
/// wrapping of data in a way suitable for the proxy to
/// manage. The actual filter instance is owned by the
diff --git a/ACE/protocols/ace/HTBP/HTBP_Channel.inl b/ACE/protocols/ace/HTBP/HTBP_Channel.inl
index 7df1ba8f16e..c6281dc0a8f 100644
--- a/ACE/protocols/ace/HTBP/HTBP_Channel.inl
+++ b/ACE/protocols/ace/HTBP/HTBP_Channel.inl
@@ -36,8 +36,7 @@ ACE_INLINE
void
ACE::HTBP::Channel::filter (ACE::HTBP::Filter *f)
{
- if (this->filter_)
- delete this->filter_;
+ delete this->filter_;
this->filter_ = f;
}
diff --git a/ACE/protocols/ace/HTBP/HTBP_Environment.cpp b/ACE/protocols/ace/HTBP/HTBP_Environment.cpp
index 8fa1b0cc397..81a6b83a4ba 100644
--- a/ACE/protocols/ace/HTBP/HTBP_Environment.cpp
+++ b/ACE/protocols/ace/HTBP/HTBP_Environment.cpp
@@ -85,6 +85,7 @@ ACE::HTBP::Environment::open_registry_config ()
ACE_NEW_RETURN (this->config_,
ACE_Configuration_Win32Registry (root),
-1);
+ this->own_config_ = true;
return 0;
#else
errno = ENOTSUP;
@@ -101,6 +102,7 @@ ACE::HTBP::Environment::open_persistent_config (const ACE_TCHAR *persistent_file
-1);
// do this before trying to open so it isn't leaked if the open fails.
this->config_ = heap;
+ this->own_config_ = true;
if (persistent_file == 0)
heap->open();
else
diff --git a/ACE/protocols/ace/HTBP/HTBP_Environment.h b/ACE/protocols/ace/HTBP/HTBP_Environment.h
index 894a376457a..d958cecbb10 100644
--- a/ACE/protocols/ace/HTBP/HTBP_Environment.h
+++ b/ACE/protocols/ace/HTBP/HTBP_Environment.h
@@ -98,7 +98,7 @@ namespace ACE
ACE_Ini_ImpExp *imp_exp_;
/// We created the config instance, so we must clean it up
- int own_config_;
+ bool own_config_;
};
}
diff --git a/ACE/protocols/ace/HTBP/HTBP_Filter_Factory.cpp b/ACE/protocols/ace/HTBP/HTBP_Filter_Factory.cpp
index bd9e9751b6d..b4403be2ac8 100644
--- a/ACE/protocols/ace/HTBP/HTBP_Filter_Factory.cpp
+++ b/ACE/protocols/ace/HTBP/HTBP_Filter_Factory.cpp
@@ -4,7 +4,6 @@
#include "HTBP_Inside_Squid_Filter.h"
#include "HTBP_Outside_Squid_Filter.h"
-#include "HTBP_Stream.h"
#include "ace/Service_Object.h"
#include "ace/Dynamic_Service.h"
#include "ace/Log_Msg.h"
diff --git a/ACE/protocols/ace/HTBP/HTBP_Filter_Factory.h b/ACE/protocols/ace/HTBP/HTBP_Filter_Factory.h
index 0681055b679..2cc9220bf70 100644
--- a/ACE/protocols/ace/HTBP/HTBP_Filter_Factory.h
+++ b/ACE/protocols/ace/HTBP/HTBP_Filter_Factory.h
@@ -54,7 +54,7 @@ namespace ACE
virtual int init (int argc, ACE_TCHAR *argv[]);
//
- Filter *get_filter (int inside);
+ static Filter *get_filter (int inside);
};
}
}
diff --git a/ACE/protocols/ace/HTBP/HTBP_ID_Requestor.cpp b/ACE/protocols/ace/HTBP/HTBP_ID_Requestor.cpp
index a048a295459..ee29ed17ca2 100644
--- a/ACE/protocols/ace/HTBP/HTBP_ID_Requestor.cpp
+++ b/ACE/protocols/ace/HTBP/HTBP_ID_Requestor.cpp
@@ -83,10 +83,10 @@ ACE::HTBP::ID_Requestor::send_request (ACE_SOCK_Stream *cli_stream)
{
char *buffer;
ACE_NEW_RETURN (buffer, char[this->url_.length()+16],-1);
+ ACE_Auto_Array_Ptr<char> guard (buffer);
ACE_OS::sprintf (buffer,"GET %s HTTP/1.0\n\n",
ACE_TEXT_ALWAYS_CHAR(url_.c_str()));
int result = cli_stream->send_n (buffer,ACE_OS::strlen(buffer));
- delete [] buffer;
if (result == -1)
ACE_ERROR_RETURN ((LM_ERROR,
ACE_TEXT("(%P|%t) ACE::HTBP::ID_Requestor::")
diff --git a/ACE/protocols/ace/HTBP/HTBP_Inside_Squid_Filter.cpp b/ACE/protocols/ace/HTBP/HTBP_Inside_Squid_Filter.cpp
index 1bc9f4a208b..d776b5cc42b 100644
--- a/ACE/protocols/ace/HTBP/HTBP_Inside_Squid_Filter.cpp
+++ b/ACE/protocols/ace/HTBP/HTBP_Inside_Squid_Filter.cpp
@@ -94,6 +94,7 @@ ACE::HTBP::Inside_Squid_Filter::send_data_header (ssize_t data_len,
ACE::HTBP::Channel *ch)
{
char *buffer = new char[BUFSIZ];
+ ACE_Auto_Array_Ptr<char> guard (buffer);
ssize_t result = -1;
if (this->make_request_header (ch,"POST ",buffer,BUFSIZ) != -1)
{
@@ -178,6 +179,7 @@ int
ACE::HTBP::Inside_Squid_Filter::send_ack (ACE::HTBP::Channel *ch)
{
char *buffer = new char[BUFSIZ];
+ ACE_Auto_Array_Ptr<char> guard (buffer);
ssize_t result = -1;
if (ch->state() == ACE::HTBP::Channel::Ack_Sent)
{
@@ -209,7 +211,7 @@ ACE::HTBP::Inside_Squid_Filter::recv_ack (ACE::HTBP::Channel *ch)
errno = EWOULDBLOCK;
ACE_ERROR_RETURN ((LM_ERROR,
ACE_TEXT("HTBP::Inside_Squid_Filter::")
- ACE_TEXT("recv_data_header, ")
+ ACE_TEXT("recv_ack, ")
ACE_TEXT("header not complete\n")),0);
}
if (this->http_code() == 200)
diff --git a/ACE/protocols/ace/HTBP/HTBP_Session.cpp b/ACE/protocols/ace/HTBP/HTBP_Session.cpp
index cb1dc421250..a4666489d78 100644
--- a/ACE/protocols/ace/HTBP/HTBP_Session.cpp
+++ b/ACE/protocols/ace/HTBP/HTBP_Session.cpp
@@ -62,7 +62,7 @@ ACE::HTBP::Session::Session (void)
destroy_proxy_addr_ (0),
inbound_ (0),
outbound_ (0),
- closed_ (0),
+ closed_ (false),
handler_ (0),
reactor_(0),
stream_ (0),
@@ -70,8 +70,8 @@ ACE::HTBP::Session::Session (void)
{
ACE::HTBP::ID_Requestor req;
ACE_TCHAR * htid = req.get_HTID();
+ ACE_Auto_Array_Ptr<ACE_TCHAR> guard (htid);
session_id_.local_ = ACE_TEXT_ALWAYS_CHAR(htid);
- delete[] htid;
session_id_.id_ = ACE::HTBP::Session::next_session_id();
ACE_NEW (inbound_, ACE::HTBP::Channel (this));
ACE_NEW (outbound_, ACE::HTBP::Channel (this));
@@ -81,12 +81,12 @@ ACE::HTBP::Session::Session (const ACE::HTBP::Addr &peer,
const ACE::HTBP::Addr &local,
ACE_UINT32 sid,
ACE_INET_Addr *proxy,
- int take_proxy)
+ bool take_proxy)
: proxy_addr_ (proxy),
destroy_proxy_addr_ (take_proxy),
inbound_ (0),
outbound_ (0),
- closed_ (0),
+ closed_ (false),
handler_ (0),
reactor_(0),
stream_ (0),
@@ -103,13 +103,13 @@ ACE::HTBP::Session::Session (const ACE::HTBP::Addr &peer,
ACE::HTBP::Session::Session (const ACE::HTBP::Session_Id_t &id,
ACE_INET_Addr *proxy,
- int take_proxy)
+ bool take_proxy)
: proxy_addr_ (proxy),
destroy_proxy_addr_ (take_proxy),
session_id_(id),
inbound_ (0),
outbound_ (0),
- closed_ (0),
+ closed_ (false),
handler_ (0),
reactor_ (0),
stream_ (0),
@@ -138,6 +138,9 @@ ACE::HTBP::Session::~Session (void)
{
if (destroy_proxy_addr_)
delete proxy_addr_;
+
+ delete this->inbound_;
+ delete this->outbound_;
}
int
@@ -147,7 +150,7 @@ ACE::HTBP::Session::close (void)
this->inbound_->close();
if (this->outbound_)
this->outbound_->close();
- this->closed_= 1;
+ this->closed_ = true;
return ACE::HTBP::Session::remove_session (this);
}
@@ -156,7 +159,7 @@ ACE::HTBP::Channel *
ACE::HTBP::Session::outbound (void) const
{
if (!this->closed_ && this->proxy_addr_)
- const_cast<ACE::HTBP::Session *> (this)->reconnect();
+ this->reconnect();
if ( this->outbound_ == 0)
return 0;
ACE::HTBP::Channel::State s =this->outbound_->state();
@@ -164,11 +167,9 @@ ACE::HTBP::Session::outbound (void) const
}
void
-ACE::HTBP::Session::reconnect_i (ACE::HTBP::Channel *s)
+ACE::HTBP::Session::reconnect_i (ACE::HTBP::Channel *s) const
{
ACE_SOCK_Connector conn;
- char host[100];
- this->proxy_addr_->get_host_name(host,100);
if (conn.connect (s->ace_stream(),*this->proxy_addr_) == -1)
{
ACE_TCHAR buffer[128];
@@ -235,6 +236,7 @@ ACE::HTBP::Session::flush_outbound_queue (void)
ACE_NEW_RETURN (iov,
iovec[this->outbound_queue_.message_count()],
-1);
+ ACE_Auto_Array_Ptr<iovec> guard (iov);
this->outbound_queue_.peek_dequeue_head (msg);
for (size_t i = 0; i < this->outbound_queue_.message_count(); i++)
{
@@ -245,9 +247,11 @@ ACE::HTBP::Session::flush_outbound_queue (void)
if (this->outbound_->state() == ACE::HTBP::Channel::Wait_For_Ack)
this->outbound_->recv_ack();
result = this->outbound_->sendv (iov,this->outbound_queue_.message_count(),0);
- delete [] iov;
- while (this->outbound_queue_.dequeue_head(msg))
- msg->release();
+ while (this->outbound_queue_.message_count ())
+ {
+ this->outbound_queue_.dequeue_head (msg);
+ msg->release ();
+ }
}
return result;
}
diff --git a/ACE/protocols/ace/HTBP/HTBP_Session.h b/ACE/protocols/ace/HTBP/HTBP_Session.h
index 5b46c6e86b3..b74cd51247d 100644
--- a/ACE/protocols/ace/HTBP/HTBP_Session.h
+++ b/ACE/protocols/ace/HTBP/HTBP_Session.h
@@ -82,10 +82,10 @@ namespace ACE
const Addr& local,
ACE_UINT32 sid = 0,
ACE_INET_Addr *proxy = 0,
- int take_proxy = 0);
+ bool take_proxy = false);
Session (const Session_Id_t &id,
ACE_INET_Addr *proxy = 0,
- int take_proxy = 0);
+ bool take_proxy = false);
Session (const Session &other);
Session& operator= (const Session &other);
@@ -155,8 +155,8 @@ namespace ACE
/// the reference passed in, so that it may be used inline for
/// the inboundor outbound methods
- void reconnect ();
- void reconnect_i (Channel *);
+ void reconnect () const;
+ void reconnect_i (Channel *) const;
typedef ACE_Hash_Map_Manager<Session_Id_t, Session*,
ACE_SYNCH_MUTEX> Session_Map;
@@ -173,10 +173,7 @@ namespace ACE
Channel *inbound_;
Channel *outbound_;
- Filter *inbound_filter_;
- Filter *outbound_filter_;
-
- int closed_;
+ bool closed_;
ACE_Event_Handler *handler_;
ACE_Reactor *reactor_;
diff --git a/ACE/protocols/ace/HTBP/HTBP_Session.inl b/ACE/protocols/ace/HTBP/HTBP_Session.inl
index 06c510650c9..aee8cbf4dc3 100644
--- a/ACE/protocols/ace/HTBP/HTBP_Session.inl
+++ b/ACE/protocols/ace/HTBP/HTBP_Session.inl
@@ -6,7 +6,7 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_INLINE
void
-ACE::HTBP::Session::reconnect ()
+ACE::HTBP::Session::reconnect () const
{
if (!this->closed_ && this->proxy_addr_)
{