summaryrefslogtreecommitdiffstats
path: root/sca-cpp/trunk/modules
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xsca-cpp/trunk/modules/http/httpd-debug25
-rwxr-xr-xsca-cpp/trunk/modules/http/httpd-memgrind25
-rwxr-xr-xsca-cpp/trunk/modules/http/httpd-stop2
-rw-r--r--sca-cpp/trunk/modules/http/httpd.hpp4
-rw-r--r--sca-cpp/trunk/modules/http/mod-openauth.cpp1
-rw-r--r--sca-cpp/trunk/modules/http/mod-ssltunnel.cpp7
-rw-r--r--sca-cpp/trunk/modules/java/eval.hpp5
-rw-r--r--sca-cpp/trunk/modules/js/eval.hpp8
-rw-r--r--sca-cpp/trunk/modules/oauth/mod-oauth1.cpp3
-rw-r--r--sca-cpp/trunk/modules/oauth/mod-oauth2.cpp3
-rw-r--r--sca-cpp/trunk/modules/python/eval.hpp34
-rw-r--r--sca-cpp/trunk/modules/server/mod-eval.hpp2
-rw-r--r--sca-cpp/trunk/modules/server/mod-wiring.cpp8
13 files changed, 112 insertions, 15 deletions
diff --git a/sca-cpp/trunk/modules/http/httpd-debug b/sca-cpp/trunk/modules/http/httpd-debug
new file mode 100755
index 0000000000..93a6bf81d4
--- /dev/null
+++ b/sca-cpp/trunk/modules/http/httpd-debug
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Start httpd server
+here=`readlink -f $0`; here=`dirname $here`
+root=`readlink -f $1`
+
+httpd=`cat $here/httpd.prefix`
+$httpd/bin/httpd -X -E $root/logs/error_log -d $root -f $root/conf/httpd.conf
diff --git a/sca-cpp/trunk/modules/http/httpd-memgrind b/sca-cpp/trunk/modules/http/httpd-memgrind
new file mode 100755
index 0000000000..3219046c22
--- /dev/null
+++ b/sca-cpp/trunk/modules/http/httpd-memgrind
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Start httpd server
+here=`readlink -f $0`; here=`dirname $here`
+root=`readlink -f $1`
+
+httpd=`cat $here/httpd.prefix`
+$here/../../etc/memgrind $httpd/bin/httpd -X -E $root/logs/error_log -d $root -f $root/conf/httpd.conf
diff --git a/sca-cpp/trunk/modules/http/httpd-stop b/sca-cpp/trunk/modules/http/httpd-stop
index 09ac5d035f..cadec1e6a0 100755
--- a/sca-cpp/trunk/modules/http/httpd-stop
+++ b/sca-cpp/trunk/modules/http/httpd-stop
@@ -22,4 +22,4 @@ here=`readlink -f $0`; here=`dirname $here`
root=`readlink -f $1`
apachectl=`cat $here/httpd-apachectl.prefix`
-$apachectl -k graceful-stop -d $root -f $root/conf/httpd.conf
+$apachectl -k graceful-stop -d $root -f $root/conf/httpd.conf 2>/dev/null
diff --git a/sca-cpp/trunk/modules/http/httpd.hpp b/sca-cpp/trunk/modules/http/httpd.hpp
index a222b38556..b6756c51e3 100644
--- a/sca-cpp/trunk/modules/http/httpd.hpp
+++ b/sca-cpp/trunk/modules/http/httpd.hpp
@@ -631,6 +631,7 @@ const char* debugOptional(const char* s) {
* Log a header
*/
int debugHeader(unused void* r, const char* key, const char* value) {
+ gc_scoped_pool();
cdebug << " header key: " << key << ", value: " << value << endl;
return 1;
}
@@ -639,6 +640,7 @@ int debugHeader(unused void* r, const char* key, const char* value) {
* Log an environment variable
*/
int debugEnv(unused void* r, const char* key, const char* value) {
+ gc_scoped_pool();
cdebug << " var key: " << key << ", value: " << value << endl;
return 1;
}
@@ -647,6 +649,7 @@ int debugEnv(unused void* r, const char* key, const char* value) {
* Log a note.
*/
int debugNote(unused void* r, const char* key, const char* value) {
+ gc_scoped_pool();
cdebug << " note key: " << key << ", value: " << value << endl;
return 1;
}
@@ -655,6 +658,7 @@ int debugNote(unused void* r, const char* key, const char* value) {
* Log a request.
*/
const bool debugRequest(request_rec* r, const string& msg) {
+ gc_scoped_pool();
cdebug << msg << ":" << endl;
cdebug << " unparsed uri: " << debugOptional(r->unparsed_uri) << endl;
cdebug << " uri: " << debugOptional(r->uri) << endl;
diff --git a/sca-cpp/trunk/modules/http/mod-openauth.cpp b/sca-cpp/trunk/modules/http/mod-openauth.cpp
index 688f2b0ba8..6917c8862c 100644
--- a/sca-cpp/trunk/modules/http/mod-openauth.cpp
+++ b/sca-cpp/trunk/modules/http/mod-openauth.cpp
@@ -202,6 +202,7 @@ static int checkAuthn(request_rec *r) {
if (atype == NULL || strcasecmp(atype, "Open"))
return DECLINED;
+ // Create a scoped memory pool
gc_scoped_pool pool(r->pool);
httpdDebugRequest(r, "modopenauth::checkAuthn::input");
diff --git a/sca-cpp/trunk/modules/http/mod-ssltunnel.cpp b/sca-cpp/trunk/modules/http/mod-ssltunnel.cpp
index d2c53b462e..edbc8f3b99 100644
--- a/sca-cpp/trunk/modules/http/mod-ssltunnel.cpp
+++ b/sca-cpp/trunk/modules/http/mod-ssltunnel.cpp
@@ -264,7 +264,9 @@ int processConnection(conn_rec *conn) {
if (ap_get_module_config(conn->base_server->module_config, &mod_tuscany_ssltunnel) == NULL)
return DECLINED;
- gc_scoped_pool(conn->pool);
+ // Create a scoped memory pool
+ gc_scoped_pool pool;
+
const ServerConf& sc = httpd::serverConf<ServerConf>(conn->base_server, &mod_tuscany_ssltunnel);
if (length(sc.pass) == 0)
return DECLINED;
@@ -287,6 +289,9 @@ int handler(request_rec* r) {
if (strcmp(r->server->server_scheme, "https"))
return DECLINED;
+ // Create a scoped memory pool
+ gc_scoped_pool pool(r->pool);
+
// Build the target URL
debug(r->uri, "modssltunnel::handler::uri");
const list<value> path(pathValues(r->uri));
diff --git a/sca-cpp/trunk/modules/java/eval.hpp b/sca-cpp/trunk/modules/java/eval.hpp
index 11e57cb08a..a73c84c64c 100644
--- a/sca-cpp/trunk/modules/java/eval.hpp
+++ b/sca-cpp/trunk/modules/java/eval.hpp
@@ -51,6 +51,7 @@ jobject JNICALL nativeUUID(JNIEnv *env);
class JavaRuntime {
public:
JavaRuntime() {
+ debug("java::javaruntime");
// Get existing JVM
jsize nvms = 0;
@@ -151,6 +152,10 @@ public:
env->RegisterNatives(uuidClass, &uuidnm, 1);
}
+ ~JavaRuntime() {
+ debug("java::~javaruntime");
+ }
+
JavaVM* jvm;
JNIEnv* env;
diff --git a/sca-cpp/trunk/modules/js/eval.hpp b/sca-cpp/trunk/modules/js/eval.hpp
index b7c69a1a0c..6bbbdac0d7 100644
--- a/sca-cpp/trunk/modules/js/eval.hpp
+++ b/sca-cpp/trunk/modules/js/eval.hpp
@@ -55,6 +55,7 @@ class JSRuntime {
public:
JSRuntime() {
// Create JS runtime
+ debug("js::jsruntime");
rt = JS_NewRuntime(8L * 1024L * 1024L);
if(rt == NULL)
cleanup();
@@ -63,6 +64,11 @@ public:
operator ::JSRuntime*() const {
return rt;
}
+
+ ~JSRuntime() {
+ debug("js::~jsruntime");
+ }
+
private:
bool cleanup() {
if(rt != NULL) {
@@ -86,6 +92,7 @@ class JSContext {
public:
JSContext() {
// Create JS context
+ debug("js::jscontext");
cx = JS_NewContext(jsRuntime, 8192);
if(cx == NULL)
return;
@@ -108,6 +115,7 @@ public:
}
~JSContext() {
+ debug("js::~jscontext");
cleanup();
}
diff --git a/sca-cpp/trunk/modules/oauth/mod-oauth1.cpp b/sca-cpp/trunk/modules/oauth/mod-oauth1.cpp
index 0f190127db..84de8f2d05 100644
--- a/sca-cpp/trunk/modules/oauth/mod-oauth1.cpp
+++ b/sca-cpp/trunk/modules/oauth/mod-oauth1.cpp
@@ -394,7 +394,10 @@ static int checkAuthn(request_rec *r) {
if (atype == NULL || strcasecmp(atype, "Open"))
return DECLINED;
+ // Create a scoped memory pool
gc_scoped_pool pool(r->pool);
+
+ // Get the server configuration
httpdDebugRequest(r, "modoauth1::checkAuthn::input");
const ServerConf& sc = httpd::serverConf<ServerConf>(r, &mod_tuscany_oauth1);
diff --git a/sca-cpp/trunk/modules/oauth/mod-oauth2.cpp b/sca-cpp/trunk/modules/oauth/mod-oauth2.cpp
index b52967977e..51bd240177 100644
--- a/sca-cpp/trunk/modules/oauth/mod-oauth2.cpp
+++ b/sca-cpp/trunk/modules/oauth/mod-oauth2.cpp
@@ -246,7 +246,10 @@ static int checkAuthn(request_rec *r) {
if (atype == NULL || strcasecmp(atype, "Open"))
return DECLINED;
+ // Create a scoped memory pool
gc_scoped_pool pool(r->pool);
+
+ // Get the server configuration
httpdDebugRequest(r, "modoauth2::checkAuthn::input");
const ServerConf& sc = httpd::serverConf<ServerConf>(r, &mod_tuscany_oauth2);
diff --git a/sca-cpp/trunk/modules/python/eval.hpp b/sca-cpp/trunk/modules/python/eval.hpp
index 2dd4b8ba33..bf539faa38 100644
--- a/sca-cpp/trunk/modules/python/eval.hpp
+++ b/sca-cpp/trunk/modules/python/eval.hpp
@@ -39,12 +39,17 @@ namespace python {
class PythonRuntime {
public:
PythonRuntime() {
+ debug("python::pythonruntime");
if (Py_IsInitialized())
return;
Py_InitializeEx(0);
const char* arg0 = "";
PySys_SetArgv(0, const_cast<char**>(&arg0));
}
+
+ ~PythonRuntime() {
+ debug("python::~pythonruntime");
+ }
};
/**
@@ -97,11 +102,15 @@ typedef struct {
PyObject *mkPyLambda(const lambda<value(const list<value>&)>& l);
void pyLambda_dealloc(PyObject* self) {
- PyMem_DEL(self);
+ debug(self, "python::pylambda_dealloc");
+ PyObject_Del(self);
}
-const string pyRepr(PyObject * o) {
- return PyString_AsString(PyObject_Repr(o));
+const string pyRepr(PyObject* o) {
+ PyObject* r = PyObject_Repr(o);
+ const string s = PyString_AsString(r);
+ Py_DECREF(r);
+ return s;
}
PyObject* pyLambda_call(PyObject* self, PyObject* args, unused PyObject* kwds) {
@@ -109,9 +118,7 @@ PyObject* pyLambda_call(PyObject* self, PyObject* args, unused PyObject* kwds) {
const pyLambda* pyl = (pyLambda*)self;
const value result = pyl->func(pyTupleToValues(args));
debug(result, "python::call::result");
- Py_DECREF(args);
PyObject *pyr = valueToPyObject(result);
- Py_INCREF(pyr);
return pyr;
}
@@ -143,7 +150,6 @@ PyObject* pyLambda_getattr(PyObject *self, PyObject *attrname) {
const pyLambda* pyl = (pyLambda*)self;
debug(name, "python::getattr::name");
PyObject* pyr = mkPyLambda(pyProxy(name, pyl->func));
- Py_INCREF(pyr);
return pyr;
}
@@ -169,9 +175,10 @@ PyTypeObject pyLambda_type = {
*/
PyObject *mkPyLambda(const lambda<value(const list<value>&)>& l) {
pyLambda* pyl = NULL;
- pyl = PyObject_NEW(pyLambda, &pyLambda_type);
+ pyl = PyObject_New(pyLambda, &pyLambda_type);
if (pyl != NULL)
pyl->func = l;
+ debug(pyl, "python::mkpylambda");
return (PyObject *)pyl;
}
@@ -181,12 +188,17 @@ PyObject *mkPyLambda(const lambda<value(const list<value>&)>& l) {
PyObject* valuesToPyListHelper(PyObject* l, const list<value>& v) {
if (isNil(v))
return l;
- PyList_Append(l, valueToPyObject(car(v)));
+ PyObject* pyv = valueToPyObject(car(v));
+ PyList_Append(l, pyv);
+ Py_DECREF(pyv);
return valuesToPyListHelper(l, cdr(v));
}
PyObject* valuesToPyTuple(const list<value>& v) {
- return PyList_AsTuple(valuesToPyListHelper(PyList_New(0), v));
+ PyObject* pyl = valuesToPyListHelper(PyList_New(0), v);
+ PyObject* pyt = PyList_AsTuple(pyl);
+ Py_DECREF(pyl);
+ return pyt;
}
/**
@@ -242,8 +254,8 @@ struct pyCallable {
const value operator()(const list<value>& args) const {
PyObject* pyargs = valuesToPyTuple(args);
PyObject* result = PyObject_CallObject(func, pyargs);
- Py_DECREF(pyargs);
const value v = pyObjectToValue(result);
+ Py_DECREF(pyargs);
Py_DECREF(result);
return v;
}
@@ -309,8 +321,8 @@ const failable<value> evalScript(const value& expr, PyObject* script) {
// Call the function
PyObject* result = PyObject_CallObject(func, args);
- Py_DECREF(args);
Py_DECREF(func);
+ Py_DECREF(args);
if (result == NULL)
return mkfailure<value>(string("Function call failed: ") + car<value>(expr) + " : " + lastError());
diff --git a/sca-cpp/trunk/modules/server/mod-eval.hpp b/sca-cpp/trunk/modules/server/mod-eval.hpp
index 8dac21de04..4ee40e51ee 100644
--- a/sca-cpp/trunk/modules/server/mod-eval.hpp
+++ b/sca-cpp/trunk/modules/server/mod-eval.hpp
@@ -628,7 +628,9 @@ int handler(request_rec *r) {
if(strcmp(r->handler, "mod_tuscany_eval"))
return DECLINED;
+ // Create a scoped memory pool
gc_scoped_pool pool(r->pool);
+
ScopedRequest sr(r);
httpdDebugRequest(r, "modeval::handler::input");
diff --git a/sca-cpp/trunk/modules/server/mod-wiring.cpp b/sca-cpp/trunk/modules/server/mod-wiring.cpp
index 0ab61f5af8..b63cd3fb37 100644
--- a/sca-cpp/trunk/modules/server/mod-wiring.cpp
+++ b/sca-cpp/trunk/modules/server/mod-wiring.cpp
@@ -310,8 +310,10 @@ int translate(request_rec *r) {
if (!strncmp(r->uri, "/components/", 12))
return DECLINED;
- // Get the server configuration
+ // Create a scoped memory pool
gc_scoped_pool pool(r->pool);
+
+ // Get the server configuration
const ServerConf& sc = httpd::serverConf<ServerConf>(r, &mod_tuscany_wiring);
// Process dynamic virtual host configuration
@@ -346,8 +348,10 @@ int handler(request_rec *r) {
if (r->status == HTTP_MOVED_TEMPORARILY)
return OK;
- // Do an internal redirect
+ // Create a scoped memory pool
gc_scoped_pool pool(r->pool);
+
+ // Do an internal redirect
httpdDebugRequest(r, "modwiring::handler::input");
debug(r->uri, "modwiring::handler::uri");