You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by jp...@apache.org on 2012/11/17 07:23:21 UTC
[3/4] git commit: TS-1551: use ConfigInfo rather than similar custom
code
TS-1551: use ConfigInfo rather than similar custom code
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/b4816b08
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/b4816b08
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/b4816b08
Branch: refs/heads/master
Commit: b4816b089d79c429a858c214333c6a3ea0e7dfa2
Parents: c63c4dd
Author: James Peach <jp...@apache.org>
Authored: Fri Nov 16 21:16:34 2012 -0800
Committer: James Peach <jp...@apache.org>
Committed: Fri Nov 16 22:22:51 2012 -0800
----------------------------------------------------------------------
iocore/net/P_SSLCertLookup.h | 29 +---------
iocore/net/SSLCertLookup.cc | 117 +------------------------------------
proxy/ProxyConfig.h | 3 +-
proxy/http/HttpAccept.cc | 1 +
4 files changed, 7 insertions(+), 143 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b4816b08/iocore/net/P_SSLCertLookup.h
----------------------------------------------------------------------
diff --git a/iocore/net/P_SSLCertLookup.h b/iocore/net/P_SSLCertLookup.h
index cd2e7dc..dca4199 100644
--- a/iocore/net/P_SSLCertLookup.h
+++ b/iocore/net/P_SSLCertLookup.h
@@ -25,33 +25,11 @@
#define _ssl_Cert_Lookup_h_
#include "libts.h"
#include "P_SSLNetProcessor.h"
-
-struct SSLCertConfigInfo
-{
- volatile int m_refcount;
-
- virtual ~SSLCertConfigInfo()
- { }
-};
-
-
-class SSLCertConfigProcessor
-{
-public:
- SSLCertConfigProcessor();
-
- unsigned int set(unsigned int id, SSLCertConfigInfo * info);
- SSLCertConfigInfo *get(unsigned int id);
- void release(unsigned int id, SSLCertConfigInfo * data);
-
-public:
- SSLCertConfigInfo *infos[MAX_CONFIGS];
- int ninfos;
-};
+#include "ProxyConfig.h"
class SSLContextStorage;
-class SSLCertLookup : public SSLCertConfigInfo
+class SSLCertLookup : public ConfigInfo
{
const char *extractIPAndCert(
matcher_line * line_info, char **addr, char **cert, char **ca, char **priKey) const;
@@ -59,7 +37,6 @@ class SSLCertLookup : public SSLCertConfigInfo
const SSLConfigParams * param,
const char *strAddr, const char *cert, const char *ca, const char *serverPrivateKey);
- char config_file_path[PATH_NAME_MAX];
SSLContextStorage * ssl_storage;
SSL_CTX * ssl_default;
@@ -84,6 +61,4 @@ public:
static void release(SSLCertLookup *p);
};
-extern SSLCertLookup sslCertLookup;
-
#endif
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b4816b08/iocore/net/SSLCertLookup.cc
----------------------------------------------------------------------
diff --git a/iocore/net/SSLCertLookup.cc b/iocore/net/SSLCertLookup.cc
index 62e4b2f..13bbd1e 100644
--- a/iocore/net/SSLCertLookup.cc
+++ b/iocore/net/SSLCertLookup.cc
@@ -45,8 +45,6 @@ typedef const SSL_METHOD * ink_ssl_method_t;
typedef SSL_METHOD * ink_ssl_method_t;
#endif
-#define SSL_MULTICERT_TIMEOUT HRTIME_SECOND * 5
-SSLCertConfigProcessor sslCertConfigProcessor;
static Ptr<ProxyMutex> ssl_reconfig_mutex = NULL;
int SSLCertLookup::id = 0;
int sslCertFile_CB(const char *name, RecDataT data_type, RecData data, void *cookie);
@@ -147,7 +145,6 @@ static const matcher_tags sslCertTags = {
SSLCertLookup::SSLCertLookup()
: ssl_storage(NEW(new SSLContextStorage())), ssl_default(NULL)
{
- *config_file_path = '\0';
}
SSLCertLookup::~SSLCertLookup()
@@ -183,19 +180,19 @@ SSLCertLookup::reconfigure()
lookup->buildTable(param);
lookup->checkDefaultContext();
- id = sslCertConfigProcessor.set(id, lookup);
+ id = configProcessor.set(id, lookup);
}
SSLCertLookup *
SSLCertLookup::acquire()
{
- return ((SSLCertLookup *) sslCertConfigProcessor.get(id));
+ return (SSLCertLookup *)configProcessor.get(id);
}
void
SSLCertLookup::release(SSLCertLookup *sslCertTable)
{
- sslCertConfigProcessor.release(id, sslCertTable);
+ configProcessor.release(id, sslCertTable);
}
bool
@@ -644,114 +641,6 @@ SSLContextStorage::lookup(const char * name) const
return NULL;
}
-class SSLCertConfigInfoReleaser:public Continuation
-{
-public:
- SSLCertConfigInfoReleaser(unsigned int id, SSLCertConfigInfo * info)
- : Continuation(new_ProxyMutex()), m_id(id), m_info(info)
- {
- SET_HANDLER(&SSLCertConfigInfoReleaser::handle_event);
- }
-
- int handle_event(int event, void *edata)
- {
- NOWARN_UNUSED(event);
- NOWARN_UNUSED(edata);
- sslCertConfigProcessor.release(m_id, m_info);
- delete this;
- return 0;
- }
-
-public:
- unsigned int m_id;
- SSLCertConfigInfo *m_info;
-};
-
-SSLCertConfigProcessor::SSLCertConfigProcessor()
- : ninfos(0)
-{
- for (int i = 0; i < MAX_CONFIGS; i++) {
- infos[i] = NULL;
- }
-}
-
-unsigned int
-SSLCertConfigProcessor::set(unsigned int id, SSLCertConfigInfo * info)
-{
- SSLCertConfigInfo *old_info;
- int idx;
-
- if (id == 0) {
- id = ink_atomic_increment((int *) &ninfos, 1) + 1;
- ink_assert(id != 0);
- ink_assert(id <= MAX_CONFIGS);
- }
-
- info->m_refcount = 1;
-
- if (id > MAX_CONFIGS) {
- // invalid index
- Error("[SSLCertConfigProcessor::set] invalid index");
- return 0;
- }
-
- idx = id - 1;
-
- do {
- old_info = infos[idx];
- } while (!ink_atomic_cas( &infos[idx], old_info, info));
-
- if (old_info) {
- eventProcessor.schedule_in(NEW(new SSLCertConfigInfoReleaser(id, old_info)), SSL_MULTICERT_TIMEOUT, ET_CACHE);
- }
-
- return id;
-}
-
-SSLCertConfigInfo *
-SSLCertConfigProcessor::get(unsigned int id)
-{
- SSLCertConfigInfo *info;
- int idx;
-
- ink_assert(id != 0);
- ink_assert(id <= MAX_CONFIGS);
-
- if (id == 0 || id > MAX_CONFIGS) {
- // return NULL, because we of an invalid index
- return NULL;
- }
-
- idx = id - 1;
- info = (SSLCertConfigInfo *) infos[idx];
- if (ink_atomic_increment((int *) &info->m_refcount, 1) < 0) {
- ink_assert(!"not reached");
- }
-
- return info;
-}
-
-void
-SSLCertConfigProcessor::release(unsigned int id, SSLCertConfigInfo * info)
-{
- int val;
- int idx;
-
- ink_assert(id != 0);
- ink_assert(id <= MAX_CONFIGS);
-
- if (id == 0 || id > MAX_CONFIGS) {
- // nothing to delete since we have an invalid index
- return;
- }
-
- idx = id - 1;
- val = ink_atomic_increment((int *) &info->m_refcount, -1);
- if ((infos[idx] != info) && (val == 1)) {
- delete info;
- }
-}
-
// struct SSLCert_UpdateContinuation
//
// Used to read the ssl_multicert.config file after the manager signals
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b4816b08/proxy/ProxyConfig.h
----------------------------------------------------------------------
diff --git a/proxy/ProxyConfig.h b/proxy/ProxyConfig.h
index f7ad0ab..6a3811d 100644
--- a/proxy/ProxyConfig.h
+++ b/proxy/ProxyConfig.h
@@ -33,7 +33,6 @@
#include "libts.h"
#include "ProcessManager.h"
-#include "Error.h"
void *config_int_cb(void *data, void *value);
void *config_long_long_cb(void *data, void *value);
@@ -58,7 +57,7 @@ struct ConfigInfo
{
volatile int m_refcount;
- virtual ~ ConfigInfo()
+ virtual ~ ConfigInfo()
{
}
};
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b4816b08/proxy/http/HttpAccept.cc
----------------------------------------------------------------------
diff --git a/proxy/http/HttpAccept.cc b/proxy/http/HttpAccept.cc
index 45a5bea..88c04d4 100644
--- a/proxy/http/HttpAccept.cc
+++ b/proxy/http/HttpAccept.cc
@@ -25,6 +25,7 @@
#include "IPAllow.h"
#include "HttpClientSession.h"
#include "I_Machine.h"
+#include "Error.h"
HttpAccept::Options const HttpAccept::DEFAULT_OPTIONS;