summaryrefslogtreecommitdiffstats
path: root/sca-cpp
diff options
context:
space:
mode:
authorjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2012-05-28 04:39:18 +0000
committerjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2012-05-28 04:39:18 +0000
commitf278315081b24b59bf73e9613e552e3519200a71 (patch)
treecdfe0e8d00e2c3e8002284c4541429f91cb66e68 /sca-cpp
parentc3eb9d1e20e1f8a7a101854d6a883692cac4e8d0 (diff)
Improve error reporting with a reason code. Improve debug and audit logging. Fix test scripts to cleanup state from previous builds and correctly report test errors.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1343138 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-cpp')
-rw-r--r--sca-cpp/trunk/components/cache/Makefile.am3
-rw-r--r--sca-cpp/trunk/components/cache/datacache.cpp2
-rw-r--r--sca-cpp/trunk/components/cache/memcache.cpp8
-rw-r--r--sca-cpp/trunk/components/cache/memcache.hpp2
-rwxr-xr-xsca-cpp/trunk/components/cache/memcached-ssl-test1
-rwxr-xr-xsca-cpp/trunk/components/cache/memcached-stop6
-rwxr-xr-xsca-cpp/trunk/components/cache/memcached-test1
-rw-r--r--sca-cpp/trunk/components/cache/partitioner.cpp12
-rwxr-xr-xsca-cpp/trunk/components/cache/server-test1
-rw-r--r--sca-cpp/trunk/components/chat/chat-sender.cpp6
-rw-r--r--sca-cpp/trunk/components/chat/chat-sender2.cpp6
-rw-r--r--sca-cpp/trunk/components/chat/chat-sendreceiver.cpp6
-rwxr-xr-xsca-cpp/trunk/components/chat/server-test1
-rwxr-xr-xsca-cpp/trunk/components/chat/vysper-stop5
-rw-r--r--sca-cpp/trunk/components/chat/xmpp.hpp4
-rwxr-xr-xsca-cpp/trunk/components/constdb/constdb-test1
-rw-r--r--sca-cpp/trunk/components/constdb/constdb.cpp8
-rwxr-xr-xsca-cpp/trunk/components/constdb/server-test1
-rw-r--r--sca-cpp/trunk/components/constdb/tinycdb.hpp8
-rwxr-xr-xsca-cpp/trunk/components/filedb/filedb-test1
-rw-r--r--sca-cpp/trunk/components/filedb/filedb.cpp8
-rw-r--r--sca-cpp/trunk/components/filedb/filedb.hpp8
-rwxr-xr-xsca-cpp/trunk/components/filedb/server-test1
-rw-r--r--sca-cpp/trunk/components/http/httpdelete.cpp2
-rw-r--r--sca-cpp/trunk/components/http/httpget.cpp2
-rw-r--r--sca-cpp/trunk/components/http/httppatch.cpp2
-rw-r--r--sca-cpp/trunk/components/http/httppost.cpp2
-rw-r--r--sca-cpp/trunk/components/http/httpput.cpp2
-rwxr-xr-xsca-cpp/trunk/components/http/server-test1
-rwxr-xr-xsca-cpp/trunk/components/kvdb/kvdb-test1
-rw-r--r--sca-cpp/trunk/components/kvdb/kvdb.cpp8
-rw-r--r--sca-cpp/trunk/components/kvdb/leveldb.hpp3
-rwxr-xr-xsca-cpp/trunk/components/kvdb/server-test1
-rw-r--r--sca-cpp/trunk/components/log/log.composite2
-rw-r--r--sca-cpp/trunk/components/log/log.cpp22
-rw-r--r--sca-cpp/trunk/components/log/logger.cpp18
-rw-r--r--sca-cpp/trunk/components/log/scribe-cat.cpp10
-rw-r--r--sca-cpp/trunk/components/log/scribe-status.cpp2
-rwxr-xr-xsca-cpp/trunk/components/log/scribe-tail-stop5
-rw-r--r--sca-cpp/trunk/components/log/scribe.hpp8
-rwxr-xr-xsca-cpp/trunk/components/log/scribed-central-stop6
-rwxr-xr-xsca-cpp/trunk/components/log/scribed-client-stop6
-rwxr-xr-xsca-cpp/trunk/components/log/server-test1
-rwxr-xr-xsca-cpp/trunk/components/queue/qpidd-stop6
-rw-r--r--sca-cpp/trunk/components/queue/queue-listener.cpp2
-rw-r--r--sca-cpp/trunk/components/queue/queue-sender.cpp2
-rwxr-xr-xsca-cpp/trunk/components/queue/server-test1
-rwxr-xr-xsca-cpp/trunk/components/smtp/server-test1
-rw-r--r--sca-cpp/trunk/components/smtp/smtppost.cpp6
-rwxr-xr-xsca-cpp/trunk/components/sqldb/server-test1
-rwxr-xr-xsca-cpp/trunk/components/sqldb/sqldb-test1
-rw-r--r--sca-cpp/trunk/components/sqldb/sqldb.cpp8
-rwxr-xr-xsca-cpp/trunk/components/sqldb/standby-test5
-rw-r--r--sca-cpp/trunk/components/webservice/axis2.hpp8
-rwxr-xr-xsca-cpp/trunk/components/webservice/server-test1
-rw-r--r--sca-cpp/trunk/components/webservice/webservice-listener.cpp2
-rw-r--r--sca-cpp/trunk/kernel/dynlib.hpp2
-rw-r--r--sca-cpp/trunk/kernel/fstream.hpp23
-rw-r--r--sca-cpp/trunk/kernel/gc.hpp4
-rw-r--r--sca-cpp/trunk/kernel/kernel-test.cpp14
-rw-r--r--sca-cpp/trunk/kernel/monad.hpp102
-rw-r--r--sca-cpp/trunk/kernel/value.hpp2
-rw-r--r--sca-cpp/trunk/kernel/xml.hpp4
-rw-r--r--sca-cpp/trunk/modules/http/Makefile.am2
-rwxr-xr-xsca-cpp/trunk/modules/http/http-test1
-rw-r--r--sca-cpp/trunk/modules/http/http.hpp30
-rwxr-xr-xsca-cpp/trunk/modules/http/httpd-test1
-rw-r--r--sca-cpp/trunk/modules/http/httpd.hpp10
-rwxr-xr-xsca-cpp/trunk/modules/http/mod-security-audit-conf44
-rwxr-xr-xsca-cpp/trunk/modules/http/mod-security-conf21
-rwxr-xr-xsca-cpp/trunk/modules/http/proxy-test1
-rw-r--r--sca-cpp/trunk/modules/java/mod-java.cpp2
-rw-r--r--sca-cpp/trunk/modules/java/mod-java.hpp4
-rwxr-xr-xsca-cpp/trunk/modules/java/server-test1
-rwxr-xr-xsca-cpp/trunk/modules/java/wiring-test1
-rw-r--r--sca-cpp/trunk/modules/js/eval.hpp2
-rw-r--r--sca-cpp/trunk/modules/json/json.hpp4
-rw-r--r--sca-cpp/trunk/modules/oauth/mod-oauth1.cpp8
-rw-r--r--sca-cpp/trunk/modules/oauth/mod-oauth2.cpp6
-rwxr-xr-xsca-cpp/trunk/modules/oauth/start-mixed-test1
-rwxr-xr-xsca-cpp/trunk/modules/oauth/start-test1
-rw-r--r--sca-cpp/trunk/modules/opencl/eval.hpp12
-rwxr-xr-xsca-cpp/trunk/modules/opencl/server-test1
-rwxr-xr-xsca-cpp/trunk/modules/openid/start-test1
-rw-r--r--sca-cpp/trunk/modules/python/mod-python.cpp2
-rw-r--r--sca-cpp/trunk/modules/python/mod-python.hpp4
-rwxr-xr-xsca-cpp/trunk/modules/python/server-test1
-rwxr-xr-xsca-cpp/trunk/modules/python/wiring-test1
-rw-r--r--sca-cpp/trunk/modules/scheme/json-value.cpp2
-rw-r--r--sca-cpp/trunk/modules/scheme/value-json.cpp2
-rw-r--r--sca-cpp/trunk/modules/scheme/value-xml.cpp2
-rwxr-xr-xsca-cpp/trunk/modules/server/httpd-test1
-rw-r--r--sca-cpp/trunk/modules/server/mod-eval.cpp2
-rw-r--r--sca-cpp/trunk/modules/server/mod-eval.hpp135
-rwxr-xr-xsca-cpp/trunk/modules/server/server-test1
-rwxr-xr-xsca-cpp/trunk/modules/server/wiring-test1
-rwxr-xr-xsca-cpp/trunk/modules/wsgi/gae-stop6
-rwxr-xr-xsca-cpp/trunk/modules/wsgi/http-test3
-rwxr-xr-xsca-cpp/trunk/modules/wsgi/util-test1
-rwxr-xr-xsca-cpp/trunk/modules/wsgi/wiring-test1
-rwxr-xr-xsca-cpp/trunk/modules/wsgi/wsgi-stop6
-rwxr-xr-xsca-cpp/trunk/modules/wsgi/wsgi-test1
-rwxr-xr-xsca-cpp/trunk/samples/store-cluster/start1
-rwxr-xr-xsca-cpp/trunk/samples/store-constdb/start1
-rwxr-xr-xsca-cpp/trunk/samples/store-cpp/start1
-rwxr-xr-xsca-cpp/trunk/samples/store-gae/server-test1
-rwxr-xr-xsca-cpp/trunk/samples/store-java/start1
-rwxr-xr-xsca-cpp/trunk/samples/store-python/start1
-rwxr-xr-xsca-cpp/trunk/samples/store-scheme/start1
-rwxr-xr-xsca-cpp/trunk/samples/store-sql/start1
-rwxr-xr-xsca-cpp/trunk/samples/store-vhost/start1
111 files changed, 483 insertions, 251 deletions
diff --git a/sca-cpp/trunk/components/cache/Makefile.am b/sca-cpp/trunk/components/cache/Makefile.am
index 1f24d59c72..0240a32bb4 100644
--- a/sca-cpp/trunk/components/cache/Makefile.am
+++ b/sca-cpp/trunk/components/cache/Makefile.am
@@ -54,4 +54,5 @@ client_test_LDFLAGS = -lxml2 -lcurl -lmozjs
dist_noinst_SCRIPTS = memcached-test memcached-ssl-test server-test
noinst_PROGRAMS = memcache-test client-test
-TESTS = memcached-test memcached-ssl-test server-test
+#TESTS = memcached-test memcached-ssl-test server-test
+TESTS = memcached-test server-test
diff --git a/sca-cpp/trunk/components/cache/datacache.cpp b/sca-cpp/trunk/components/cache/datacache.cpp
index f7e812dd18..c26e6eb868 100644
--- a/sca-cpp/trunk/components/cache/datacache.cpp
+++ b/sca-cpp/trunk/components/cache/datacache.cpp
@@ -56,7 +56,7 @@ const failable<value> get(const value& key, const lambda<value(const list<value>
if (isNil(val2)) {
ostringstream os;
os << "Couldn't get cache entry: " << key;
- return mkfailure<value>(str(os), false);
+ return mkfailure<value>(str(os), 404, false);
}
// Update level1 cache
diff --git a/sca-cpp/trunk/components/cache/memcache.cpp b/sca-cpp/trunk/components/cache/memcache.cpp
index 6347eb55de..af710696b3 100644
--- a/sca-cpp/trunk/components/cache/memcache.cpp
+++ b/sca-cpp/trunk/components/cache/memcache.cpp
@@ -48,7 +48,7 @@ const failable<value> post(const list<value>& params, memcache::MemCached& ch) {
const value id = append<value>(car(params), mklist(mkuuid()));
const failable<bool> val = memcache::post(id, cadr(params), ch);
if (!hasContent(val))
- return mkfailure<value>(reason(val));
+ return mkfailure<value>(val);
return id;
}
@@ -58,7 +58,7 @@ const failable<value> post(const list<value>& params, memcache::MemCached& ch) {
const failable<value> put(const list<value>& params, memcache::MemCached& ch) {
const failable<bool> val = memcache::put(car(params), cadr(params), ch);
if (!hasContent(val))
- return mkfailure<value>(reason(val));
+ return mkfailure<value>(val);
return value(content(val));
}
@@ -68,7 +68,7 @@ const failable<value> put(const list<value>& params, memcache::MemCached& ch) {
const failable<value> del(const list<value>& params, memcache::MemCached& ch) {
const failable<bool> val = memcache::del(car(params), ch);
if (!hasContent(val))
- return mkfailure<value>(reason(val));
+ return mkfailure<value>(val);
return value(content(val));
}
@@ -90,7 +90,7 @@ public:
return put(cdr(params), ch);
if (func == "delete")
return del(cdr(params), ch);
- return tuscany::mkfailure<tuscany::value>();
+ return mkfailure<value>();
}
private:
diff --git a/sca-cpp/trunk/components/cache/memcache.hpp b/sca-cpp/trunk/components/cache/memcache.hpp
index 2dcd6ea033..fe77c26671 100644
--- a/sca-cpp/trunk/components/cache/memcache.hpp
+++ b/sca-cpp/trunk/components/cache/memcache.hpp
@@ -180,7 +180,7 @@ const failable<value> get(const value& key, const MemCached& cache) {
if (rc != APR_SUCCESS) {
ostringstream os;
os << "Couldn't get memcached entry: " << key;
- return mkfailure<value>(str(os), false);
+ return mkfailure<value>(str(os), 404, false);
}
const value val(scheme::readValue(string(data, size)));
diff --git a/sca-cpp/trunk/components/cache/memcached-ssl-test b/sca-cpp/trunk/components/cache/memcached-ssl-test
index 6a9dc2cd27..8ef37a0b98 100755
--- a/sca-cpp/trunk/components/cache/memcached-ssl-test
+++ b/sca-cpp/trunk/components/cache/memcached-ssl-test
@@ -18,6 +18,7 @@
# under the License.
# Setup
+rm -rf tmp
../../modules/http/ssl-ca-conf tmp/ssl localhost
../../modules/http/ssl-cert-conf tmp/ssl localhost server
../../modules/http/ssl-cert-conf tmp/ssl localhost tunnel
diff --git a/sca-cpp/trunk/components/cache/memcached-stop b/sca-cpp/trunk/components/cache/memcached-stop
index 2b3b66c74d..50d094b9c7 100755
--- a/sca-cpp/trunk/components/cache/memcached-stop
+++ b/sca-cpp/trunk/components/cache/memcached-stop
@@ -37,4 +37,8 @@ else
mc="$memcached_prefix/bin/memcached -d -l $ip -m 4 -p $port"
fi
-kill `ps -ef | grep -v grep | grep "${mc}" | awk '{ print $2 }'`
+k=`ps -ef | grep -v grep | grep "${mc}" | awk '{ print $2 }'`
+if [ "$k" != "" ]; then
+ kill $k
+fi
+
diff --git a/sca-cpp/trunk/components/cache/memcached-test b/sca-cpp/trunk/components/cache/memcached-test
index e647c5525e..dc274bd4aa 100755
--- a/sca-cpp/trunk/components/cache/memcached-test
+++ b/sca-cpp/trunk/components/cache/memcached-test
@@ -18,6 +18,7 @@
# under the License.
# Setup
+rm -rf tmp
./memcached-start tmp 11211
./memcached-start tmp 11212
./memcached-start tmp 11213
diff --git a/sca-cpp/trunk/components/cache/partitioner.cpp b/sca-cpp/trunk/components/cache/partitioner.cpp
index 609d42f494..ea12699977 100644
--- a/sca-cpp/trunk/components/cache/partitioner.cpp
+++ b/sca-cpp/trunk/components/cache/partitioner.cpp
@@ -47,7 +47,7 @@ const failable<lambda<value(const list<value>&)> > partition(const value& key, c
if (isNil(p)) {
ostringstream os;
os << "Couldn't get partition number: " << key;
- return mkfailure<lambda<value(const list<value>&)> >(str(os), false);
+ return mkfailure<lambda<value(const list<value>&)> >(str(os), -1, false);
}
return (const lambda<value(const list<value>&)>)p;
}
@@ -60,14 +60,14 @@ const failable<value> get(const value& key, const lambda<value(const list<value>
// Select partition
const failable<lambda<value(const list<value>&)> > p = partition(key, selector, partitions);
if (!hasContent(p))
- return mkfailure<value>(reason(p));
+ return mkfailure<value>(p);
// Get from selected partition
const value val = content(p)(mklist<value>("get", key));
if (isNil(val)) {
ostringstream os;
os << "Couldn't get entry from partition: " << key;
- return mkfailure<value>(str(os), false);
+ return mkfailure<value>(str(os), 404, false);
}
return val;
@@ -82,7 +82,7 @@ const failable<value> post(const value& key, const value& val, const lambda<valu
// Select partition
const failable<lambda<value(const list<value>&)> > p = partition(id, selector, partitions);
if (!hasContent(p))
- return mkfailure<value>(reason(p));
+ return mkfailure<value>(p);
// Put into select partition
content(p)(mklist<value>("put", id, val));
@@ -98,7 +98,7 @@ const failable<value> put(const value& key, const value& val, const lambda<value
// Select partition
const failable<lambda<value(const list<value>&)> > p = partition(key, selector, partitions);
if (!hasContent(p))
- return mkfailure<value>(reason(p));
+ return mkfailure<value>(p);
// Put into selected partition
content(p)(mklist<value>("put", key, val));
@@ -114,7 +114,7 @@ const failable<value> del(const value& key, const lambda<value(const list<value>
// Select partition
const failable<lambda<value(const list<value>&)> > p = partition(key, selector, partitions);
if (!hasContent(p))
- return mkfailure<value>(reason(p));
+ return mkfailure<value>(p);
// Delete from selected partition
content(p)(mklist<value>("delete", key));
diff --git a/sca-cpp/trunk/components/cache/server-test b/sca-cpp/trunk/components/cache/server-test
index bc56b1fe19..951159c4c8 100755
--- a/sca-cpp/trunk/components/cache/server-test
+++ b/sca-cpp/trunk/components/cache/server-test
@@ -18,6 +18,7 @@
# under the License.
# Setup
+rm -rf tmp
../../modules/http/httpd-conf tmp localhost 8090 ../../modules/http/htdocs
../../modules/http/httpd-event-conf tmp
../../modules/server/server-conf tmp
diff --git a/sca-cpp/trunk/components/chat/chat-sender.cpp b/sca-cpp/trunk/components/chat/chat-sender.cpp
index 5e289d7eac..0672292a06 100644
--- a/sca-cpp/trunk/components/chat/chat-sender.cpp
+++ b/sca-cpp/trunk/components/chat/chat-sender.cpp
@@ -46,7 +46,7 @@ const failable<value> post(const list<value>& params, XMPPClient& xc) {
debug(val, "chat::post::value");
const failable<bool> r = post(to, val, xc);
if (!hasContent(r))
- return mkfailure<value>(reason(r));
+ return mkfailure<value>(r);
return value(mklist<value>(to));
}
@@ -96,7 +96,7 @@ public:
// Stop the chat sender component
if (func != "stop")
- return tuscany::mkfailure<tuscany::value>();
+ return mkfailure<value>();
debug("chat::sender::stop");
// Disconnect and shutdown the worker thread
@@ -125,7 +125,7 @@ const failable<value> start(const list<value>& params) {
XMPPClient xc(jid, pass, false);
const failable<bool> r = connect(xc);
if (!hasContent(r))
- return mkfailure<value>(reason(r));
+ return mkfailure<value>(r);
// Listen and relay messages in a worker thread
worker w(3);
diff --git a/sca-cpp/trunk/components/chat/chat-sender2.cpp b/sca-cpp/trunk/components/chat/chat-sender2.cpp
index 05dec36270..b230d130c1 100644
--- a/sca-cpp/trunk/components/chat/chat-sender2.cpp
+++ b/sca-cpp/trunk/components/chat/chat-sender2.cpp
@@ -55,12 +55,12 @@ const failable<value> post(const lambda<value(const list<value>&)> jid, const la
XMPPClient xc(vjid, vpass);
const failable<bool> c = connect(xc);
if (!hasContent(c))
- return mkfailure<value>(reason(c));
+ return mkfailure<value>(c);
// Post the message
const failable<bool> r = post(vto, vmsg, xc);
if (!hasContent(r))
- return mkfailure<value>(reason(r));
+ return mkfailure<value>(r);
return value(mklist<value>(vto));
}
@@ -79,7 +79,7 @@ public:
// Stop the chat sender component
if (func != "stop")
- return tuscany::mkfailure<tuscany::value>();
+ return mkfailure<value>();
debug("chat::sender::stop");
return failable<value>(value(lambda<value(const list<value>&)>()));
}
diff --git a/sca-cpp/trunk/components/chat/chat-sendreceiver.cpp b/sca-cpp/trunk/components/chat/chat-sendreceiver.cpp
index ddc12bb164..aac8d69f6c 100644
--- a/sca-cpp/trunk/components/chat/chat-sendreceiver.cpp
+++ b/sca-cpp/trunk/components/chat/chat-sendreceiver.cpp
@@ -46,7 +46,7 @@ const failable<value> post(const list<value>& params, XMPPClient& xc) {
debug(val, "chat::post::value");
const failable<bool> r = post(to, val, xc);
if (!hasContent(r))
- return mkfailure<value>(reason(r));
+ return mkfailure<value>(r);
return value(mklist<value>(to));
}
@@ -107,7 +107,7 @@ public:
// Stop the chat sender/receiver component
if (func != "stop")
- return tuscany::mkfailure<tuscany::value>();
+ return mkfailure<value>();
debug("chat::sendreceiver::stop");
// Disconnect and shutdown the worker thread
@@ -138,7 +138,7 @@ const failable<value> start(const list<value>& params) {
XMPPClient xc(jid, pass, false);
const failable<bool> r = connect(xc);
if (!hasContent(r))
- return mkfailure<value>(reason(r));
+ return mkfailure<value>(r);
// Listen and relay messages in a worker thread
worker w(3);
diff --git a/sca-cpp/trunk/components/chat/server-test b/sca-cpp/trunk/components/chat/server-test
index 4b3a7bfc6a..7b5fabfe14 100755
--- a/sca-cpp/trunk/components/chat/server-test
+++ b/sca-cpp/trunk/components/chat/server-test
@@ -18,6 +18,7 @@
# under the License.
# Setup
+rm -rf tmp
../../modules/http/httpd-conf tmp localhost 8090 ../../modules/http/htdocs
../../modules/http/httpd-event-conf tmp
../../modules/server/server-conf tmp
diff --git a/sca-cpp/trunk/components/chat/vysper-stop b/sca-cpp/trunk/components/chat/vysper-stop
index 6ae9246134..0fec98400d 100755
--- a/sca-cpp/trunk/components/chat/vysper-stop
+++ b/sca-cpp/trunk/components/chat/vysper-stop
@@ -21,5 +21,8 @@
here=`echo "import os; print os.path.realpath('$0')" | python`; here=`dirname $here`
java_prefix=`cat $here/../../modules/java/java.prefix`
-kill `ps -ef | grep -v grep | grep "${java_prefix}/jre/bin/java" | grep "vysper" | awk '{ print $2 }'`
+k=`ps -ef | grep -v grep | grep "${java_prefix}/jre/bin/java" | grep "vysper" | awk '{ print $2 }'`
+if [ "$k" != "" ]; then
+ kill $k
+fi
diff --git a/sca-cpp/trunk/components/chat/xmpp.hpp b/sca-cpp/trunk/components/chat/xmpp.hpp
index cafe342f05..e5f423c270 100644
--- a/sca-cpp/trunk/components/chat/xmpp.hpp
+++ b/sca-cpp/trunk/components/chat/xmpp.hpp
@@ -291,7 +291,7 @@ const failable<bool> post(const value& to, const value& val, XMPPClient& xc) {
const failable<size_t> r = send(stanza, xc);
xmpp_stanza_release(stanza);
if (!hasContent(r))
- return mkfailure<bool>(reason(r));
+ return mkfailure<bool>(r);
return true;
}
@@ -302,7 +302,7 @@ const failable<bool> disconnect(XMPPClient& xc) {
xc.disconnecting = true;
const failable<size_t> r = send("</stream:stream>", xc);
if (!hasContent(r))
- return mkfailure<bool>(reason(r));
+ return mkfailure<bool>(r);
return true;
}
diff --git a/sca-cpp/trunk/components/constdb/constdb-test b/sca-cpp/trunk/components/constdb/constdb-test
index 3730ed67a4..420b98559c 100755
--- a/sca-cpp/trunk/components/constdb/constdb-test
+++ b/sca-cpp/trunk/components/constdb/constdb-test
@@ -18,6 +18,7 @@
# under the License.
# Setup
+rm -rf tmp
mkdir -p tmp
./tinycdb -c -m tmp/test.cdb </dev/null
diff --git a/sca-cpp/trunk/components/constdb/constdb.cpp b/sca-cpp/trunk/components/constdb/constdb.cpp
index 94df433a67..c3b9d63284 100644
--- a/sca-cpp/trunk/components/constdb/constdb.cpp
+++ b/sca-cpp/trunk/components/constdb/constdb.cpp
@@ -48,7 +48,7 @@ const failable<value> post(const list<value>& params, tinycdb::TinyCDB& cdb) {
const value id = append<value>(car(params), mklist(mkuuid()));
const failable<bool> val = tinycdb::post(id, cadr(params), cdb);
if (!hasContent(val))
- return mkfailure<value>(reason(val));
+ return mkfailure<value>(val);
return id;
}
@@ -58,7 +58,7 @@ const failable<value> post(const list<value>& params, tinycdb::TinyCDB& cdb) {
const failable<value> put(const list<value>& params, tinycdb::TinyCDB& cdb) {
const failable<bool> val = tinycdb::put(car(params), cadr(params), cdb);
if (!hasContent(val))
- return mkfailure<value>(reason(val));
+ return mkfailure<value>(val);
return value(content(val));
}
@@ -68,7 +68,7 @@ const failable<value> put(const list<value>& params, tinycdb::TinyCDB& cdb) {
const failable<value> del(const list<value>& params, tinycdb::TinyCDB& cdb) {
const failable<bool> val = tinycdb::del(car(params), cdb);
if (!hasContent(val))
- return mkfailure<value>(reason(val));
+ return mkfailure<value>(val);
return value(content(val));
}
@@ -90,7 +90,7 @@ public:
return put(cdr(params), cdb);
if (func == "delete")
return del(cdr(params), cdb);
- return tuscany::mkfailure<tuscany::value>();
+ return mkfailure<value>();
}
private:
diff --git a/sca-cpp/trunk/components/constdb/server-test b/sca-cpp/trunk/components/constdb/server-test
index 7e98e42bbb..abeceaf98e 100755
--- a/sca-cpp/trunk/components/constdb/server-test
+++ b/sca-cpp/trunk/components/constdb/server-test
@@ -18,6 +18,7 @@
# under the License.
# Setup
+rm -rf tmp
../../modules/http/httpd-conf tmp localhost 8090 ../../modules/http/htdocs
../../modules/http/httpd-event-conf tmp
../../modules/server/server-conf tmp
diff --git a/sca-cpp/trunk/components/constdb/tinycdb.hpp b/sca-cpp/trunk/components/constdb/tinycdb.hpp
index 02114cf1ae..c7d4cf520b 100644
--- a/sca-cpp/trunk/components/constdb/tinycdb.hpp
+++ b/sca-cpp/trunk/components/constdb/tinycdb.hpp
@@ -222,7 +222,7 @@ const failable<bool> rewrite(const lambda<failable<bool>(buffer& buf, const unsi
// Open existing db
failable<int> ffd = cdbopen(cdb);
if (!hasContent(ffd))
- return mkfailure<bool>(reason(ffd));
+ return mkfailure<bool>(ffd);
const int fd = content(ffd);
// Read the db header
@@ -307,7 +307,7 @@ const failable<bool> rewrite(const lambda<failable<bool>(buffer& buf, const unsi
cdbclose(cdb);
failable<int> ffd = cdbopen(cdb);
if (!hasContent(ffd))
- return mkfailure<bool>(reason(ffd));
+ return mkfailure<bool>(ffd);
return true;
}
@@ -413,7 +413,7 @@ const failable<value> get(const value& key, TinyCDB& cdb) {
const failable<int> ffd = cdbopen(cdb);
if (!hasContent(ffd))
- return mkfailure<value>(reason(ffd));
+ return mkfailure<value>(ffd);
const int fd = content(ffd);
const string ks(scheme::writeValue(key));
@@ -422,7 +422,7 @@ const failable<value> get(const value& key, TinyCDB& cdb) {
if (cdb_seek(fd, c_str(ks), (unsigned int)length(ks), &vlen) <= 0) {
ostringstream os;
os << "Couldn't get tinycdb entry: " << key;
- return mkfailure<value>(str(os));
+ return mkfailure<value>(str(os), 404, false);
}
char* data = gc_cnew(vlen + 1);
cdb_bread(fd, data, vlen);
diff --git a/sca-cpp/trunk/components/filedb/filedb-test b/sca-cpp/trunk/components/filedb/filedb-test
index 6d82936f6d..6d2d66424a 100755
--- a/sca-cpp/trunk/components/filedb/filedb-test
+++ b/sca-cpp/trunk/components/filedb/filedb-test
@@ -18,6 +18,7 @@
# under the License.
# Setup
+rm -rf tmp
mkdir -p tmp
mkdir -p tmp/schemedb
mkdir -p tmp/xmldb
diff --git a/sca-cpp/trunk/components/filedb/filedb.cpp b/sca-cpp/trunk/components/filedb/filedb.cpp
index ac4c3faa6b..21b509a3b7 100644
--- a/sca-cpp/trunk/components/filedb/filedb.cpp
+++ b/sca-cpp/trunk/components/filedb/filedb.cpp
@@ -48,7 +48,7 @@ const failable<value> post(const list<value>& params, filedb::FileDB& db) {
const value id = append<value>(car(params), mklist(mkuuid()));
const failable<bool> val = filedb::post(id, cadr(params), db);
if (!hasContent(val))
- return mkfailure<value>(reason(val));
+ return mkfailure<value>(val);
return id;
}
@@ -58,7 +58,7 @@ const failable<value> post(const list<value>& params, filedb::FileDB& db) {
const failable<value> put(const list<value>& params, filedb::FileDB& db) {
const failable<bool> val = filedb::put(car(params), cadr(params), db);
if (!hasContent(val))
- return mkfailure<value>(reason(val));
+ return mkfailure<value>(val);
return value(content(val));
}
@@ -68,7 +68,7 @@ const failable<value> put(const list<value>& params, filedb::FileDB& db) {
const failable<value> del(const list<value>& params, filedb::FileDB& db) {
const failable<bool> val = filedb::del(car(params), db);
if (!hasContent(val))
- return mkfailure<value>(reason(val));
+ return mkfailure<value>(val);
return value(content(val));
}
@@ -90,7 +90,7 @@ public:
return put(cdr(params), db);
if (func == "delete")
return del(cdr(params), db);
- return tuscany::mkfailure<tuscany::value>();
+ return mkfailure<value>();
}
private:
diff --git a/sca-cpp/trunk/components/filedb/filedb.hpp b/sca-cpp/trunk/components/filedb/filedb.hpp
index ea7638320f..a7151eade1 100644
--- a/sca-cpp/trunk/components/filedb/filedb.hpp
+++ b/sca-cpp/trunk/components/filedb/filedb.hpp
@@ -125,7 +125,7 @@ const failable<bool> write(const value& v, ostream& os, const string& format) {
if (format == "xml") {
failable<list<string> > s = writeXML(valuesToElements(v));
if (!hasContent(s))
- return mkfailure<bool>(reason(s));
+ return mkfailure<bool>(s);
write(content(s), os);
return true;
}
@@ -133,7 +133,7 @@ const failable<bool> write(const value& v, ostream& os, const string& format) {
js::JSContext jscx;
failable<list<string> > s = json::writeJSON(valuesToElements(v), jscx);
if (!hasContent(s))
- return mkfailure<bool>(reason(s));
+ return mkfailure<bool>(s);
write(content(s), os);
return true;
}
@@ -155,7 +155,7 @@ const failable<value> read(istream& is, const string& format) {
js::JSContext jscx;
const failable<list<value> > fv = json::readJSON(streamList(is), jscx);
if (!hasContent(fv))
- return mkfailure<value>(reason(fv));
+ return mkfailure<value>(fv);
const value v = elementsToValues(content(fv));
return v;
}
@@ -223,7 +223,7 @@ const failable<value> get(const value& key, FileDB& db) {
if (is.fail()) {
ostringstream os;
os << "Couldn't get file database entry: " << key;
- return mkfailure<value>(str(os));
+ return mkfailure<value>(str(os), 404, false);
}
const failable<value> val = read(is, db.format);
diff --git a/sca-cpp/trunk/components/filedb/server-test b/sca-cpp/trunk/components/filedb/server-test
index edd5386b08..94afe464e1 100755
--- a/sca-cpp/trunk/components/filedb/server-test
+++ b/sca-cpp/trunk/components/filedb/server-test
@@ -18,6 +18,7 @@
# under the License.
# Setup
+rm -rf tmp
../../modules/http/httpd-conf tmp localhost 8090 ../../modules/http/htdocs
../../modules/http/httpd-event-conf tmp
../../modules/server/server-conf tmp
diff --git a/sca-cpp/trunk/components/http/httpdelete.cpp b/sca-cpp/trunk/components/http/httpdelete.cpp
index 109049f75d..d78a4d60df 100644
--- a/sca-cpp/trunk/components/http/httpdelete.cpp
+++ b/sca-cpp/trunk/components/http/httpdelete.cpp
@@ -57,7 +57,7 @@ public:
const value func(car(params));
if (func == "get")
return get(url, *ch);
- return tuscany::mkfailure<tuscany::value>();
+ return mkfailure<value>();
}
private:
diff --git a/sca-cpp/trunk/components/http/httpget.cpp b/sca-cpp/trunk/components/http/httpget.cpp
index 59dc231209..8515d6f41e 100644
--- a/sca-cpp/trunk/components/http/httpget.cpp
+++ b/sca-cpp/trunk/components/http/httpget.cpp
@@ -58,7 +58,7 @@ public:
const value func(car(params));
if (func == "get")
return get(url, *ch);
- return tuscany::mkfailure<tuscany::value>();
+ return mkfailure<value>();
}
private:
diff --git a/sca-cpp/trunk/components/http/httppatch.cpp b/sca-cpp/trunk/components/http/httppatch.cpp
index 06810e5d90..3e6f7af2c0 100644
--- a/sca-cpp/trunk/components/http/httppatch.cpp
+++ b/sca-cpp/trunk/components/http/httppatch.cpp
@@ -60,7 +60,7 @@ public:
const value func(car(params));
if (func == "get")
return get(url, val, *ch);
- return tuscany::mkfailure<tuscany::value>();
+ return mkfailure<value>();
}
private:
diff --git a/sca-cpp/trunk/components/http/httppost.cpp b/sca-cpp/trunk/components/http/httppost.cpp
index f4b85710bb..8d0f526bdc 100644
--- a/sca-cpp/trunk/components/http/httppost.cpp
+++ b/sca-cpp/trunk/components/http/httppost.cpp
@@ -60,7 +60,7 @@ public:
const value func(car(params));
if (func == "get")
return get(url, val, *ch);
- return tuscany::mkfailure<tuscany::value>();
+ return mkfailure<value>();
}
private:
diff --git a/sca-cpp/trunk/components/http/httpput.cpp b/sca-cpp/trunk/components/http/httpput.cpp
index 448456652b..c157ee32cc 100644
--- a/sca-cpp/trunk/components/http/httpput.cpp
+++ b/sca-cpp/trunk/components/http/httpput.cpp
@@ -60,7 +60,7 @@ public:
const value func(car(params));
if (func == "get")
return get(url, val, *ch);
- return tuscany::mkfailure<tuscany::value>();
+ return mkfailure<value>();
}
private:
diff --git a/sca-cpp/trunk/components/http/server-test b/sca-cpp/trunk/components/http/server-test
index 1deb46aa26..7e3116c59d 100755
--- a/sca-cpp/trunk/components/http/server-test
+++ b/sca-cpp/trunk/components/http/server-test
@@ -18,6 +18,7 @@
# under the License.
# Setup
+rm -rf tmp
../../modules/http/httpd-conf tmp localhost 8090 ../../modules/http/htdocs
../../modules/server/server-conf tmp
../../modules/server/scheme-conf tmp
diff --git a/sca-cpp/trunk/components/kvdb/kvdb-test b/sca-cpp/trunk/components/kvdb/kvdb-test
index 3730ed67a4..420b98559c 100755
--- a/sca-cpp/trunk/components/kvdb/kvdb-test
+++ b/sca-cpp/trunk/components/kvdb/kvdb-test
@@ -18,6 +18,7 @@
# under the License.
# Setup
+rm -rf tmp
mkdir -p tmp
./tinycdb -c -m tmp/test.cdb </dev/null
diff --git a/sca-cpp/trunk/components/kvdb/kvdb.cpp b/sca-cpp/trunk/components/kvdb/kvdb.cpp
index bab4e5d82b..24a2fb5a16 100644
--- a/sca-cpp/trunk/components/kvdb/kvdb.cpp
+++ b/sca-cpp/trunk/components/kvdb/kvdb.cpp
@@ -48,7 +48,7 @@ const failable<value> post(const list<value>& params, leveldb::LevelDB& cdb) {
const value id = append<value>(car(params), mklist(mkuuid()));
const failable<bool> val = leveldb::post(id, cadr(params), cdb);
if (!hasContent(val))
- return mkfailure<value>(reason(val));
+ return mkfailure<value>(val);
return id;
}
@@ -58,7 +58,7 @@ const failable<value> post(const list<value>& params, leveldb::LevelDB& cdb) {
const failable<value> put(const list<value>& params, leveldb::LevelDB& cdb) {
const failable<bool> val = leveldb::put(car(params), cadr(params), cdb);
if (!hasContent(val))
- return mkfailure<value>(reason(val));
+ return mkfailure<value>(val);
return value(content(val));
}
@@ -68,7 +68,7 @@ const failable<value> put(const list<value>& params, leveldb::LevelDB& cdb) {
const failable<value> del(const list<value>& params, leveldb::LevelDB& cdb) {
const failable<bool> val = leveldb::del(car(params), cdb);
if (!hasContent(val))
- return mkfailure<value>(reason(val));
+ return mkfailure<value>(val);
return value(content(val));
}
@@ -90,7 +90,7 @@ public:
return put(cdr(params), cdb);
if (func == "delete")
return del(cdr(params), cdb);
- return tuscany::mkfailure<tuscany::value>();
+ return mkfailure<value>();
}
private:
diff --git a/sca-cpp/trunk/components/kvdb/leveldb.hpp b/sca-cpp/trunk/components/kvdb/leveldb.hpp
index b26cde73fe..8105f86ec4 100644
--- a/sca-cpp/trunk/components/kvdb/leveldb.hpp
+++ b/sca-cpp/trunk/components/kvdb/leveldb.hpp
@@ -157,8 +157,7 @@ const failable<int> dbopen(LevelDB& db) {
struct stat st;
const int s = stat(c_str(db.name), &st);
if (s == -1)
- return mkfailure<int>(
- string("Couldn't leveldb read database stat: ") + db.name);
+ return mkfailure<int>(string("Couldn't leveldb read database stat: ") + db.name);
leveldb::DB* ldb;
leveldb::Options options;
diff --git a/sca-cpp/trunk/components/kvdb/server-test b/sca-cpp/trunk/components/kvdb/server-test
index 1836336c70..ebf01b9b4b 100755
--- a/sca-cpp/trunk/components/kvdb/server-test
+++ b/sca-cpp/trunk/components/kvdb/server-test
@@ -18,6 +18,7 @@
# under the License.
# Setup
+rm -rf tmp
../../modules/http/httpd-conf tmp localhost 8090 ../../modules/http/htdocs
../../modules/server/server-conf tmp
../../modules/server/scheme-conf tmp
diff --git a/sca-cpp/trunk/components/log/log.composite b/sca-cpp/trunk/components/log/log.composite
index 97754b534c..c6755f3655 100644
--- a/sca-cpp/trunk/components/log/log.composite
+++ b/sca-cpp/trunk/components/log/log.composite
@@ -23,6 +23,7 @@
<component name="log">
<implementation.cpp path="." library="liblog"/>
+ <property name="host"></property>
<property name="category">default</property>
<service name="log">
<binding.http uri="log"/>
@@ -39,6 +40,7 @@
<component name="logger">
<implementation.cpp path="." library="liblogger"/>
+ <property name="host"></property>
<property name="category">default</property>
<service name="logger">
<binding.http uri="logger"/>
diff --git a/sca-cpp/trunk/components/log/log.cpp b/sca-cpp/trunk/components/log/log.cpp
index d43833680d..2e7742cfd7 100644
--- a/sca-cpp/trunk/components/log/log.cpp
+++ b/sca-cpp/trunk/components/log/log.cpp
@@ -29,6 +29,7 @@
#include "list.hpp"
#include "value.hpp"
#include "monad.hpp"
+#include "../../modules/http/http.hpp"
#include "scribe.hpp"
namespace tuscany {
@@ -37,11 +38,11 @@ namespace log {
/**
* Post an item to the Scribe log.
*/
-const failable<value> post(const list<value>& params, const value& category, scribe::Scribe& sc) {
+const failable<value> post(const list<value>& params, const value& host, const value& category, scribe::Scribe& sc) {
debug(cadr(params), "log::post::value");
- const failable<bool> val = scribe::log(cadr(params), category, sc);
+ const failable<bool> val = scribe::log(cadr(params), host, category, sc);
if (!hasContent(val))
- return mkfailure<value>(reason(val));
+ return mkfailure<value>(val);
return value(mklist<value>(true));
}
@@ -50,17 +51,18 @@ const failable<value> post(const list<value>& params, const value& category, scr
*/
class applyLog {
public:
- applyLog(const value& category, scribe::Scribe& sc) : category(category), sc(sc) {
+ applyLog(const value& host, const value& category, scribe::Scribe& sc) : host(host), category(category), sc(sc) {
}
const value operator()(const list<value>& params) const {
const value func(car(params));
if (func == "post")
- return post(cdr(params), category, sc);
- return tuscany::mkfailure<tuscany::value>();
+ return post(cdr(params), host, category, sc);
+ return mkfailure<value>();
}
private:
+ const value host;
const value category;
scribe::Scribe& sc;
};
@@ -68,16 +70,18 @@ private:
/**
* Start the component.
*/
-const failable<value> start(unused const list<value>& params) {
+const failable<value> start(const list<value>& params) {
// Connect to Scribe
scribe::Scribe& sc = *(new (gc_new<scribe::Scribe>()) scribe::Scribe("localhost", 1464));
// Extract the configured category
- const value category = ((lambda<value(list<value>)>)car(params))(list<value>());
+ const value host = ((lambda<value(list<value>)>)car(params))(list<value>());
+ const value category = ((lambda<value(list<value>)>)cadr(params))(list<value>());
+ debug(host, "log::start::host");
debug(category, "log::start::category");
// Return the component implementation lambda function
- return value(lambda<value(const list<value>&)>(applyLog(category, sc)));
+ return value(lambda<value(const list<value>&)>(applyLog(host, category, sc)));
}
}
diff --git a/sca-cpp/trunk/components/log/logger.cpp b/sca-cpp/trunk/components/log/logger.cpp
index eb18ed30db..d7a54507fb 100644
--- a/sca-cpp/trunk/components/log/logger.cpp
+++ b/sca-cpp/trunk/components/log/logger.cpp
@@ -30,6 +30,7 @@
#include "list.hpp"
#include "value.hpp"
#include "monad.hpp"
+#include "../../modules/http/http.hpp"
#include "scribe.hpp"
namespace tuscany {
@@ -40,24 +41,25 @@ namespace logger {
*/
class applyLog {
public:
- applyLog(const lambda<value(const list<value>&)>& relay, const value& category, scribe::Scribe& sc) : relay(relay), category(category), sc(sc) {
+ applyLog(const lambda<value(const list<value>&)>& relay, const value& host, const value& category, scribe::Scribe& sc) : relay(relay), host(host), category(category), sc(sc) {
}
const value operator()(const list<value>& params) const {
// Log the function params
debug(params, "logger::apply::params");
- scribe::log(params, category, sc);
+ scribe::log(params, host, category, sc);
- // Relay the function
+ // Relay the function call
const failable<value> res = relay(params);
// Log the result
- scribe::log(res, category, sc);
+ scribe::log(res, host, category, sc);
return res;
}
private:
const lambda<value(const list<value>&)> relay;
+ const value host;
const value category;
scribe::Scribe& sc;
};
@@ -65,17 +67,19 @@ private:
/**
* Start the component.
*/
-const failable<value> start(unused const list<value>& params) {
+const failable<value> start(const list<value>& params) {
// Connect to Scribe
scribe::Scribe& sc = *(new (gc_new<scribe::Scribe>()) scribe::Scribe("localhost", 1464));
// Extract the configured relay service and category
const value rel = car(params);
- const value category = ((lambda<value(list<value>)>)cadr(params))(list<value>());
+ const value host = ((lambda<value(list<value>)>)cadr(params))(list<value>());
+ const value category = ((lambda<value(list<value>)>)caddr(params))(list<value>());
+ debug(host, "logger::start::host");
debug(category, "logger::start::category");
// Return the component implementation lambda function
- return value(lambda<value(const list<value>&)>(applyLog(rel, category, sc)));
+ return value(lambda<value(const list<value>&)>(applyLog(rel, host, category, sc)));
}
}
diff --git a/sca-cpp/trunk/components/log/scribe-cat.cpp b/sca-cpp/trunk/components/log/scribe-cat.cpp
index 7f48ddb59b..fbfdaca533 100644
--- a/sca-cpp/trunk/components/log/scribe-cat.cpp
+++ b/sca-cpp/trunk/components/log/scribe-cat.cpp
@@ -47,7 +47,6 @@ int cat(const string& host, const string& category, const string& type) {
// Write line prefix
ostringstream os;
- os << "[" << host << "] ";
if (length(type) != 0)
os << "[" << logTime() << "] [" << type << "] ";
const string prefix = str(os);
@@ -58,13 +57,14 @@ int cat(const string& host, const string& category, const string& type) {
const char* s = fgets(buf + pl, 8192 - pl, stdin);
if (s == NULL)
return 0;
+
+ // Remove trailing '\n'
const size_t l = strlen(s);
- if (l < 2)
- return 0;
- buf[pl + l - 1] = '\0';
+ if (l > 0)
+ buf[pl + l - 1] = '\0';
// Log the line
- const failable<bool> val = scribe::log(buf, category, sc);
+ const failable<bool> val = scribe::log(buf, host, category, sc);
if (!hasContent(val))
return 1;
}
diff --git a/sca-cpp/trunk/components/log/scribe-status.cpp b/sca-cpp/trunk/components/log/scribe-status.cpp
index 0e5f03f501..79f7572947 100644
--- a/sca-cpp/trunk/components/log/scribe-status.cpp
+++ b/sca-cpp/trunk/components/log/scribe-status.cpp
@@ -45,7 +45,7 @@ const int status(const string& host, const int port) {
// Interpret and display results
if (!hasContent(fs)) {
- cerr << reason(fs) << endl;
+ cerr << reason(fs) << " : " << rcode(fs) << endl;
return 2;
}
const string s = content(fs);
diff --git a/sca-cpp/trunk/components/log/scribe-tail-stop b/sca-cpp/trunk/components/log/scribe-tail-stop
index b46c1ecca6..0d43570a6f 100755
--- a/sca-cpp/trunk/components/log/scribe-tail-stop
+++ b/sca-cpp/trunk/components/log/scribe-tail-stop
@@ -38,5 +38,8 @@ fi
file=`echo "import os; print os.path.realpath('$file')" | python`
cmd="tail -f -n 0 $file"
-kill `ps -ef | grep -v grep | grep "${cmd}" | awk '{ print $2 }'`
+k=`ps -ef | grep -v grep | grep "${cmd}" | awk '{ print $2 }'`
+if [ "$k" != "" ]; then
+ kill $k
+fi
diff --git a/sca-cpp/trunk/components/log/scribe.hpp b/sca-cpp/trunk/components/log/scribe.hpp
index 7fa420f945..5ae8a50776 100644
--- a/sca-cpp/trunk/components/log/scribe.hpp
+++ b/sca-cpp/trunk/components/log/scribe.hpp
@@ -98,7 +98,7 @@ private:
::scribe::thrift::scribeClient* client;
boost::shared_ptr<apache::thrift::transport::TTransport> transport;
- friend const failable<bool> log(const value& val, const value& category, const Scribe& sc);
+ friend const failable<bool> log(const value& val, const string& host, const value& category, const Scribe& sc);
friend const failable<string> status(const Scribe& sc);
/**
@@ -122,18 +122,20 @@ private:
/**
* Log an item.
*/
-const failable<bool> log(const value& val, const value& category, const Scribe& sc) {
+const failable<bool> log(const value& val, const string& host, const value& category, const Scribe& sc) {
debug(val, "scribe::log::value");
debug(category, "scribe::log::category");
const value cat = isString(category)? value(c_str(category)):category;
const string cs(scheme::writeValue(cat));
const string vs(scheme::writeValue(val));
+ ostringstream os;
+ os << "[" << host << "] " << vs;
try {
::scribe::thrift::LogEntry entry;
entry.category = c_str(cs);
- entry.message = c_str(vs);
+ entry.message = c_str(str(os));
std::vector< ::scribe::thrift::LogEntry> msgs;
msgs.push_back(entry);
diff --git a/sca-cpp/trunk/components/log/scribed-central-stop b/sca-cpp/trunk/components/log/scribed-central-stop
index acded2a482..2d301149b8 100755
--- a/sca-cpp/trunk/components/log/scribed-central-stop
+++ b/sca-cpp/trunk/components/log/scribed-central-stop
@@ -25,4 +25,8 @@ scribe_prefix=`cat $here/scribe.prefix`
thrift_prefix=`cat $here/thrift.prefix`
scribed="$scribe_prefix/bin/scribed -c $root/scribe/conf/scribe-central.conf"
-kill `ps -ef | grep -v grep | grep "${scribed}" | awk '{ print $2 }'`
+k=`ps -ef | grep -v grep | grep "${scribed}" | awk '{ print $2 }'`
+if [ "$k" != "" ]; then
+ kill $k
+fi
+
diff --git a/sca-cpp/trunk/components/log/scribed-client-stop b/sca-cpp/trunk/components/log/scribed-client-stop
index 0f9c409183..d6a6345f29 100755
--- a/sca-cpp/trunk/components/log/scribed-client-stop
+++ b/sca-cpp/trunk/components/log/scribed-client-stop
@@ -25,4 +25,8 @@ scribe_prefix=`cat $here/scribe.prefix`
thrift_prefix=`cat $here/thrift.prefix`
scribed="$scribe_prefix/bin/scribed -c $root/scribe/conf/scribe-client.conf"
-kill `ps -ef | grep -v grep | grep "${scribed}" | awk '{ print $2 }'`
+k=`ps -ef | grep -v grep | grep "${scribed}" | awk '{ print $2 }'`
+if [ "$k" != "" ]; then
+ kill $k
+fi
+
diff --git a/sca-cpp/trunk/components/log/server-test b/sca-cpp/trunk/components/log/server-test
index 015691f958..6c9cf47135 100755
--- a/sca-cpp/trunk/components/log/server-test
+++ b/sca-cpp/trunk/components/log/server-test
@@ -18,6 +18,7 @@
# under the License.
# Setup
+rm -rf tmp
../../modules/http/httpd-conf tmp localhost 8090 ../../modules/http/htdocs
../../modules/http/httpd-event-conf tmp
../../modules/server/server-conf tmp
diff --git a/sca-cpp/trunk/components/queue/qpidd-stop b/sca-cpp/trunk/components/queue/qpidd-stop
index bb43d8aaba..c8af680d78 100755
--- a/sca-cpp/trunk/components/queue/qpidd-stop
+++ b/sca-cpp/trunk/components/queue/qpidd-stop
@@ -23,4 +23,8 @@ here=`echo "import os; print os.path.realpath('$0')" | python`; here=`dirname $h
qpid_prefix=`cat $here/qpidc.prefix`
qpidd="$qpid_prefix/sbin/qpidd"
-kill `ps -ef | grep -v grep | grep "${qpidd}" | awk '{ print $2 }'`
+k=`ps -ef | grep -v grep | grep "${qpidd}" | awk '{ print $2 }'`
+if [ "$k" != "" ]; then
+ kill $k
+fi
+
diff --git a/sca-cpp/trunk/components/queue/queue-listener.cpp b/sca-cpp/trunk/components/queue/queue-listener.cpp
index 8d253a670d..3c30e7feca 100644
--- a/sca-cpp/trunk/components/queue/queue-listener.cpp
+++ b/sca-cpp/trunk/components/queue/queue-listener.cpp
@@ -97,7 +97,7 @@ public:
// Stop the component
if (func != "stop")
- return tuscany::mkfailure<tuscany::value>();
+ return mkfailure<value>();
debug("queue::listener::stop");
// TODO check why stop() and close() hang in child processes
diff --git a/sca-cpp/trunk/components/queue/queue-sender.cpp b/sca-cpp/trunk/components/queue/queue-sender.cpp
index ea6e45d988..ff2ede1057 100644
--- a/sca-cpp/trunk/components/queue/queue-sender.cpp
+++ b/sca-cpp/trunk/components/queue/queue-sender.cpp
@@ -54,7 +54,7 @@ const failable<value> post(const list<value>& params) {
debug(cadr(params), "queue::post::value");
const failable<bool> r = post(key, cadr(params), qs);
if (!hasContent(r))
- return mkfailure<value>(reason(r));
+ return mkfailure<value>(r);
return key;
}
diff --git a/sca-cpp/trunk/components/queue/server-test b/sca-cpp/trunk/components/queue/server-test
index 6b572fce6f..269d3f9376 100755
--- a/sca-cpp/trunk/components/queue/server-test
+++ b/sca-cpp/trunk/components/queue/server-test
@@ -18,6 +18,7 @@
# under the License.
# Setup
+rm -rf tmp
../../modules/http/httpd-conf tmp localhost 8090 ../../modules/http/htdocs
../../modules/http/httpd-event-conf tmp
../../modules/server/server-conf tmp
diff --git a/sca-cpp/trunk/components/smtp/server-test b/sca-cpp/trunk/components/smtp/server-test
index 55464edc89..c111021c85 100755
--- a/sca-cpp/trunk/components/smtp/server-test
+++ b/sca-cpp/trunk/components/smtp/server-test
@@ -18,6 +18,7 @@
# under the License.
# Setup
+rm -rf tmp
../../modules/http/httpd-conf tmp localhost 8090 ../../modules/http/htdocs
../../modules/http/httpd-loglevel-conf tmp debug
../../modules/server/server-conf tmp
diff --git a/sca-cpp/trunk/components/smtp/smtppost.cpp b/sca-cpp/trunk/components/smtp/smtppost.cpp
index a3eae095ef..db2ac9ef18 100644
--- a/sca-cpp/trunk/components/smtp/smtppost.cpp
+++ b/sca-cpp/trunk/components/smtp/smtppost.cpp
@@ -42,14 +42,14 @@ const failable<value> post(const string& url, const string& user, const string&
// Convert value to a content request
const failable<list<list<string> > > freq = http::contentRequest(val, url);
if (!hasContent(freq))
- return mkfailure<value>(reason(freq));
+ return mkfailure<value>(freq);
const list<list<string> > req = content(freq);
debug(req, "smtp::post::input");
// Setup the CURL session
const failable<CURL*> fch = http::setup(url, cs);
if (!hasContent(fch))
- return mkfailure<value>(reason(fch));
+ return mkfailure<value>(fch);
CURL* ch = content(fch);
curl_easy_setopt(ch, CURLOPT_USE_SSL, (long)CURLUSESSL_ALL);
@@ -129,7 +129,7 @@ public:
const value func(car(params));
if (func == "get")
return get(url, user, pass, from, to, subject, val, *ch);
- return tuscany::mkfailure<tuscany::value>();
+ return mkfailure<value>();
}
private:
diff --git a/sca-cpp/trunk/components/sqldb/server-test b/sca-cpp/trunk/components/sqldb/server-test
index 666a9a1f0b..db756ec1c4 100755
--- a/sca-cpp/trunk/components/sqldb/server-test
+++ b/sca-cpp/trunk/components/sqldb/server-test
@@ -18,6 +18,7 @@
# under the License.
# Setup
+rm -rf tmp
../../modules/http/httpd-conf tmp localhost 8090 ../../modules/http/htdocs
../../modules/http/httpd-event-conf tmp
./pgsql-conf tmp
diff --git a/sca-cpp/trunk/components/sqldb/sqldb-test b/sca-cpp/trunk/components/sqldb/sqldb-test
index bbbbd4d373..cb023fec3a 100755
--- a/sca-cpp/trunk/components/sqldb/sqldb-test
+++ b/sca-cpp/trunk/components/sqldb/sqldb-test
@@ -18,6 +18,7 @@
# under the License.
# Setup
+rm -rf tmp
./pgsql-conf tmp
./pgsql-start tmp
./pgsql "drop table test;" 1>/dev/null 2>&1
diff --git a/sca-cpp/trunk/components/sqldb/sqldb.cpp b/sca-cpp/trunk/components/sqldb/sqldb.cpp
index c2b178f13e..bbf118385e 100644
--- a/sca-cpp/trunk/components/sqldb/sqldb.cpp
+++ b/sca-cpp/trunk/components/sqldb/sqldb.cpp
@@ -49,7 +49,7 @@ const failable<value> post(const list<value>& params, pgsql::PGSql& pg) {
const value id = append<value>(car(params), mklist(mkuuid()));
const failable<bool> val = pgsql::post(id, cadr(params), pg);
if (!hasContent(val))
- return mkfailure<value>(reason(val));
+ return mkfailure<value>(val);
return id;
}
@@ -59,7 +59,7 @@ const failable<value> post(const list<value>& params, pgsql::PGSql& pg) {
const failable<value> put(const list<value>& params, pgsql::PGSql& pg) {
const failable<bool> val = pgsql::put(car(params), cadr(params), pg);
if (!hasContent(val))
- return mkfailure<value>(reason(val));
+ return mkfailure<value>(val);
return value(content(val));
}
@@ -69,7 +69,7 @@ const failable<value> put(const list<value>& params, pgsql::PGSql& pg) {
const failable<value> del(const list<value>& params, pgsql::PGSql& pg) {
const failable<bool> val = pgsql::del(car(params), pg);
if (!hasContent(val))
- return mkfailure<value>(reason(val));
+ return mkfailure<value>(val);
return value(content(val));
}
@@ -91,7 +91,7 @@ public:
return put(cdr(params), *pg);
if (func == "delete")
return del(cdr(params), *pg);
- return tuscany::mkfailure<tuscany::value>();
+ return mkfailure<value>();
}
private:
diff --git a/sca-cpp/trunk/components/sqldb/standby-test b/sca-cpp/trunk/components/sqldb/standby-test
index fbb27b5bc3..3c91e477e4 100755
--- a/sca-cpp/trunk/components/sqldb/standby-test
+++ b/sca-cpp/trunk/components/sqldb/standby-test
@@ -18,12 +18,13 @@
# under the License.
# Setup
+rm -rf tmp
../../modules/http/httpd-conf tmp/master localhost 8090 tmp/master/htdocs
../../modules/http/httpd-event-conf tmp
./pgsql-conf tmp/master 5432
./pgsql-start tmp/master
-./pgsql localhost 5432 "drop table test;" 1>/dev/null 2>&1
-./pgsql localhost 5432 "create table test(key text, value text);" 1>/dev/null 2>&1
+./pgsql localhost 6432 "drop table test;" 1>/dev/null 2>&1
+./pgsql localhost 6432 "create table test(key text, value text);" 1>/dev/null 2>&1
../../modules/http/httpd-start tmp/master
sleep 2
./pgsql-standby-conf tmp/standby 5433 localhost 5432 8090
diff --git a/sca-cpp/trunk/components/webservice/axis2.hpp b/sca-cpp/trunk/components/webservice/axis2.hpp
index 62797d86f2..7630b54295 100644
--- a/sca-cpp/trunk/components/webservice/axis2.hpp
+++ b/sca-cpp/trunk/components/webservice/axis2.hpp
@@ -112,7 +112,7 @@ const failable<axiom_node_t*> stringToAxiomNode(const string& s, const Axis2Cont
const failable<axiom_node_t*> valuesToAxiomNode(const list<value>& l, const Axis2Context& ax) {
const failable<list<string> > xml = writeXML(valuesToElements(l), false);
if (!hasContent(xml))
- return mkfailure<axiom_node_t*>(reason(xml));
+ return mkfailure<axiom_node_t*>(xml);
ostringstream os;
write(content(xml), os);
return stringToAxiomNode(str(os), ax);
@@ -136,7 +136,7 @@ const failable<const string> axiomNodeToString(axiom_node_t* node, const Axis2Co
const failable<const list<value> > axiomNodeToValues(axiom_node_t* node, const Axis2Context& ax) {
const failable<const string> s = axiomNodeToString(node, ax);
if (!hasContent(s))
- return mkfailure<const list<value> >(reason(s));
+ return mkfailure<const list<value> >(s);
istringstream is(content(s));
const failable<const list<value> > l = readXML(streamList(is));
if (!hasContent(l))
@@ -170,7 +170,7 @@ const failable<value> evalExpr(const value& expr, const Axis2Context& ax) {
// Construct request Axiom node
const failable<axiom_node_t*> req = valuesToAxiomNode(param, ax);
if (!hasContent(req))
- return mkfailure<value>(reason(req));
+ return mkfailure<value>(req);
// Call the Web service
axiom_node_t* res = axis2_svc_client_send_receive(client, env(ax), content(req));
@@ -182,7 +182,7 @@ const failable<value> evalExpr(const value& expr, const Axis2Context& ax) {
// Parse result Axiom node
const failable<const list<value> > lval = axiomNodeToValues(res, ax);
if (!hasContent(lval))
- return mkfailure<value>(reason(lval));
+ return mkfailure<value>(lval);
const value rval = content(lval);
debug(rval, "webservice::evalExpr::result");
diff --git a/sca-cpp/trunk/components/webservice/server-test b/sca-cpp/trunk/components/webservice/server-test
index 35cca9f7ad..cb12accbfb 100755
--- a/sca-cpp/trunk/components/webservice/server-test
+++ b/sca-cpp/trunk/components/webservice/server-test
@@ -18,6 +18,7 @@
# under the License.
# Setup
+rm -rf tmp
../../modules/http/httpd-conf tmp localhost 8090 ../../modules/http/htdocs
../../modules/http/httpd-event-conf tmp
../../modules/server/server-conf tmp
diff --git a/sca-cpp/trunk/components/webservice/webservice-listener.cpp b/sca-cpp/trunk/components/webservice/webservice-listener.cpp
index e3347fa186..29ebef4bcb 100644
--- a/sca-cpp/trunk/components/webservice/webservice-listener.cpp
+++ b/sca-cpp/trunk/components/webservice/webservice-listener.cpp
@@ -47,7 +47,7 @@ extern "C" {
const value redirectToAxis2(const string& uri, request_rec* r, const value& relay) {
const failable<request_rec*, int> nr = httpd::internalRedirectRequest(uri, r);
if (!hasContent(nr))
- return value(reason(nr));
+ return value(reason(nr), rcode(nr));
ap_set_module_config(content(nr)->request_config, &axis2_module, const_cast<void*>((const void*)&relay));
return value(httpd::internalRedirect(content(nr)));
}
diff --git a/sca-cpp/trunk/kernel/dynlib.hpp b/sca-cpp/trunk/kernel/dynlib.hpp
index 9f55dc4a49..484de3d666 100644
--- a/sca-cpp/trunk/kernel/dynlib.hpp
+++ b/sca-cpp/trunk/kernel/dynlib.hpp
@@ -80,7 +80,7 @@ private:
*/
template<typename S> const failable<lambda<S> > dynlambda(const string& name, const lib& l) {
if (!hasContent(l.h))
- return mkfailure<lambda<S> >(reason(l.h));
+ return mkfailure<lambda<S>>(l.h);
const void* s = dlsym(content(l.h), c_str(name));
if (s == NULL)
return mkfailure<lambda<S> >(string("Could not load symbol: ") + name);
diff --git a/sca-cpp/trunk/kernel/fstream.hpp b/sca-cpp/trunk/kernel/fstream.hpp
index 6afec8bd35..5ea9df2d62 100644
--- a/sca-cpp/trunk/kernel/fstream.hpp
+++ b/sca-cpp/trunk/kernel/fstream.hpp
@@ -329,7 +329,17 @@ logfstream cdebug(stderr, "debug");
/**
* Return true if debug log is enabled.
*/
-#define debug_islogging() true
+bool debug_isLoggingSet = false;
+bool debug_isLoggingEnv = false;
+
+const bool debug_isLogging() {
+ if (debug_isLoggingSet)
+ return debug_isLoggingEnv;
+ debug_isLoggingEnv = getenv("TUSCANY_DEBUG_LOG") != NULL;
+ return debug_isLoggingEnv;
+}
+
+#define debug_islogging() debug_isLogging()
#endif
@@ -355,7 +365,16 @@ template<typename V> const bool debugLog(const V& v, const string& msg) {
return true;
}
-#define debug(...) if (debug_islogging()) tuscany::debugLog(__VA_ARGS__)
+/**
+ * Log a debug message and two values.
+ */
+template<typename V, typename W> const bool debugLog(const V& v, const W& w, const string& msg) {
+ gc_scoped_pool();
+ cdebug << msg << ": " << v << " : " << w << endl;
+ return true;
+}
+
+#define debug(...) do { if (debug_islogging()) tuscany::debugLog(__VA_ARGS__); } while(0)
#else
diff --git a/sca-cpp/trunk/kernel/gc.hpp b/sca-cpp/trunk/kernel/gc.hpp
index ed5482cfff..260688f4ff 100644
--- a/sca-cpp/trunk/kernel/gc.hpp
+++ b/sca-cpp/trunk/kernel/gc.hpp
@@ -26,6 +26,7 @@
* Garbage collected memory management, using APR memory pools.
*/
+#include "config.hpp"
#ifdef WANT_MALLOC_MMAP
#include <sys/mman.h>
#include <malloc.h>
@@ -36,7 +37,6 @@
#include <apr_strings.h>
#include <assert.h>
#include <new>
-#include "config.hpp"
#ifdef WANT_THREADS
#include <pthread.h>
#endif
@@ -267,7 +267,7 @@ public:
}
private:
- gc_scoped_pool(const unused gc_scoped_pool& pool) : gc_pool(pool.apr_pool), prev(NULL), owner(false) {
+ gc_scoped_pool(const gc_scoped_pool& pool) : gc_pool(pool.apr_pool), prev(NULL), owner(false) {
}
apr_pool_t* prev;
diff --git a/sca-cpp/trunk/kernel/kernel-test.cpp b/sca-cpp/trunk/kernel/kernel-test.cpp
index 9b87397b96..7bde4fb526 100644
--- a/sca-cpp/trunk/kernel/kernel-test.cpp
+++ b/sca-cpp/trunk/kernel/kernel-test.cpp
@@ -501,13 +501,23 @@ const failable<int> failableH(const int v) {
bool testFailableMonad() {
const failable<int> m(2);
assert(m >> failableF == failableF(2));
- assert((m >> success<int, string>()) == m);
+ assert((m >> success<int, string, int>()) == m);
assert(m >> failableF >> failableG == m >> failableH);
cout << "Failable monad test... " << endl;
- failable<int> ooops = mkfailure<int>("test");
+ const failable<int> ooops = mkfailure<int>("test", 500);
assert(reason(ooops) == "test");
+ assert(rcode(ooops) == 500);
assert(ooops >> failableF >> failableG == ooops);
+
+ const failable<value> vooops = mkfailure<value>(ooops);
+ assert(reason(vooops) == "test");
+ assert(rcode(vooops) == 500);
+
+ const value v = value(vooops);
+ assert(car<value>(v) == value());
+ assert(cadr<value>(v) == string("test"));
+ assert(caddr<value>(v) == value((double)500));
return true;
}
diff --git a/sca-cpp/trunk/kernel/monad.hpp b/sca-cpp/trunk/kernel/monad.hpp
index b1bef7996c..657a809c1c 100644
--- a/sca-cpp/trunk/kernel/monad.hpp
+++ b/sca-cpp/trunk/kernel/monad.hpp
@@ -203,59 +203,63 @@ template<typename R, typename V> const maybe<R> operator>>(const maybe<V>& m, co
* To get the value in the monad, just cast it to the value type.
* To get the failure in the monad, cast it to the failure type.
*/
-template<typename V, typename F = string> class failable {
+template<typename V, typename F = string, typename C = int> class failable {
public:
- failable() : hasv(false) {
+ failable() : hasv(false), c(-1) {
}
- failable(const V& v) : hasv(true), v(v) {
+ failable(const V& v) : hasv(true), v(v), c(-1) {
}
- failable(const failable<V, F>& m) : hasv(m.hasv), v(m.v), f(m.f) {
+ failable(const failable<V, F, C>& m) : hasv(m.hasv), v(m.v), f(m.f), c(m.c) {
}
- const failable<V, F>& operator=(const failable<V, F>& m) {
+ const failable<V, F, C>& operator=(const failable<V, F, C>& m) {
if (&m == this)
return *this;
hasv = m.hasv;
v = m.v;
f = m.f;
+ c = m.c;
return *this;
}
- const bool operator!=(const failable<V, F>& m) const {
+ const bool operator!=(const failable<V, F, C>& m) const {
return !this->operator==(m);
}
- const bool operator==(const failable<V, F>& m) const {
+ const bool operator==(const failable<V, F, C>& m) const {
if (this == &m)
return true;
if (!hasv)
- return !m.hasv && f == m.f;
+ return !m.hasv && f == m.f && c == m.c;
return m.hasv && v == m.v;
}
private:
- failable(const bool hasv, const F& f) : hasv(hasv), f(f) {
+ failable(const bool hasv, const F& f, const C& c) : hasv(hasv), f(f), c(c) {
}
- template<typename A, typename B> friend const bool hasContent(const failable<A, B>& m);
- template<typename A, typename B> friend const A content(const failable<A, B>& m);
- template<typename A, typename B> friend const B reason(const failable<A, B>& m);
- template<typename A, typename B> friend const failable<A, B> mkfailure(const B& f, const bool log);
- template<typename A> friend const failable<A, string> mkfailure();
+ template<typename A, typename B, typename R> friend const bool hasContent(const failable<A, B, R>& m);
+ template<typename A, typename B, typename R> friend const A content(const failable<A, B, R>& m);
+ template<typename A, typename B, typename R> friend const B reason(const failable<A, B, R>& m);
+ template<typename A, typename B, typename R> friend const R rcode(const failable<A, B, R>& m);
+ template<typename A, typename B, typename R> friend const failable<A, B, R> mkfailure(const B& f, const R& c, const bool log);
+ template<typename A, typename B> friend const failable<A, B> mkfailure(const B& f, const int c, const bool log);
+ template<typename A> friend const failable<A> mkfailure();
bool hasv;
V v;
F f;
+ C c;
};
/**
* Write a failable monad to a stream.
*/
-template<typename V, typename F> ostream& operator<<(ostream& out, const failable<V, F>& m) {
+template<typename V, typename F, typename C> ostream& operator<<(ostream& out, const failable<V, F, C>& m) {
if (!hasContent(m)) {
- out << reason(m);
+ out << reason(m) << " : " << rcode(m);
return out;
}
out << content(m);
@@ -265,18 +269,18 @@ template<typename V, typename F> ostream& operator<<(ostream& out, const failabl
/**
* Returns a failable monad with a success value in it.
*/
-template<typename V, typename F> const failable<V, F> mksuccess(const V& v) {
- return failable<V, F>(v);
+template<typename V, typename F, typename C> const failable<V, F, C> mksuccess(const V& v) {
+ return failable<V, F, C>(v);
}
-template<typename V, typename F> const lambda<failable<V, F>(const V)> success() {
- return mksuccess<V, F>;
+template<typename V, typename F, typename C> const lambda<failable<V, F, C>(const V)> success() {
+ return mksuccess<V, F, C>;
}
/**
* Returns a failable monad with a failure in it.
*/
-template<typename V, typename F> const failable<V, F> mkfailure(const F& f, const bool log = true) {
+template<typename V, typename F, typename C> const failable<V, F, C> mkfailure(const F& f, const C& c, const bool log = true) {
#ifdef WANT_MAINTAINER_LOG
if (!log)
debug(f, "failable::mkfailure");
@@ -285,57 +289,85 @@ template<typename V, typename F> const failable<V, F> mkfailure(const F& f, cons
ostringstream os;
os << f;
if (length(str(os)) != 0)
- cfailure << "failable::mkfailure" << ": " << f << endl;
+ cfailure << "failable::mkfailure" << ": " << f << " : " << c << endl;
}
- return failable<V, F>(false, f);
+ return failable<V, F, C>(false, f, c);
}
-template<typename V> const failable<V> mkfailure(const char* f, const bool log = true) {
- return mkfailure<V, string>(string(f), log);
+template<typename V, typename F> const failable<V, F> mkfailure(const F& f, const int c = -1, const bool log = true) {
+#ifdef WANT_MAINTAINER_LOG
+ if (!log)
+ debug(f, c, "failable::mkfailure");
+#endif
+ if (log) {
+ ostringstream os;
+ os << f;
+ if (length(str(os)) != 0)
+ cfailure << "failable::mkfailure: " << str(os) << " : " << c << endl;
+ }
+ return failable<V, F>(false, f, c);
+}
+
+template<typename V> const failable<V> mkfailure(const char* f, const int c = -1, const bool log = true) {
+ return mkfailure<V, string>(string(f), c, log);
}
template<typename V> const failable<V> mkfailure() {
- return failable<V, string>(false, string());
+ return failable<V, string>(false, string(), -1);
+}
+
+template<typename V, typename F, typename C> const lambda<failable<V, F, C>(const V)> failure() {
+ return mkfailure<V, F, C>;
}
-template<typename V, typename F> const lambda<failable<V, F>(const V)> failure() {
- return mkfailure<V, F>;
+/**
+ * Convert a failable of a given type to a failable of another type.
+ */
+template<typename V, typename F, typename C, typename X> const failable<V, F, C> mkfailure(const failable<X, F, C>& f, const bool log = true) {
+ return mkfailure<V, F, C>(reason(f), rcode(f), log);
}
/**
* Returns true if the monad contains a content.
*/
-template<typename V, typename F> const bool hasContent(const failable<V, F>& m) {
+template<typename V, typename F, typename C> const bool hasContent(const failable<V, F, C>& m) {
return m.hasv;
}
/**
* Returns the content of a failable monad.
*/
-template<typename V, typename F> const V content(const failable<V, F>& m) {
+template<typename V, typename F, typename C> const V content(const failable<V, F, C>& m) {
return m.v;
}
/**
* Returns the reason for failure of a failable monad.
*/
-template<typename V, typename F> const F reason(const failable<V, F>& m) {
+template<typename V, typename F, typename C> const F reason(const failable<V, F, C>& m) {
return m.f;
}
/**
+ * Returns the reason code for failure of a failable monad.
+ */
+template<typename V, typename F, typename C> const C rcode(const failable<V, F, C>& m) {
+ return m.c;
+}
+
+/**
* Bind a function to a failable monad. Passes the success value in the monad to the function
* if present, or does nothing if there's no value and a failure instead.
*/
-template<typename R, typename FR, typename V, typename FV>
-const failable<R, FR> operator>>(const failable<V, FV>& m, const lambda<failable<R, FR>(const V)>& f) {
+template<typename R, typename FR, typename XR, typename V, typename FV, typename XV>
+const failable<R, FR, XR> operator>>(const failable<V, FV, XV>& m, const lambda<failable<R, FR, XR>(const V)>& f) {
if (!hasContent(m))
return m;
return f(content(m));
}
-template<typename R, typename FR, typename V, typename FV>
-const failable<R, FR> operator>>(const failable<V, FV>& m, const failable<R, FR> (* const f)(const V)) {
+template<typename R, typename FR, typename XR, typename V, typename FV, typename XV>
+const failable<R, FR, XR> operator>>(const failable<V, FV, XV>& m, const failable<R, FR, XR> (* const f)(const V)) {
if (!hasContent(m))
return m;
return f(content(m));
diff --git a/sca-cpp/trunk/kernel/value.hpp b/sca-cpp/trunk/kernel/value.hpp
index 3b0e9beb73..206fe8b32b 100644
--- a/sca-cpp/trunk/kernel/value.hpp
+++ b/sca-cpp/trunk/kernel/value.hpp
@@ -193,7 +193,7 @@ public:
}
value(const failable<value>& m) : type(value::List),
- data(vdata(result(hasContent(m)? mklist<value>(content(m)) : mklist<value>(value(), reason(m))))) {
+ data(vdata(result(hasContent(m)? mklist<value>(content(m)) : rcode(m) == 1? mklist<value>(value(), reason(m)) : mklist<value>(value(), reason(m), rcode(m))))) {
debug_inc(countValues);
debug_inc(countVValues);
debug_watchValue();
diff --git a/sca-cpp/trunk/kernel/xml.hpp b/sca-cpp/trunk/kernel/xml.hpp
index b53093201d..14549e5dfc 100644
--- a/sca-cpp/trunk/kernel/xml.hpp
+++ b/sca-cpp/trunk/kernel/xml.hpp
@@ -321,7 +321,7 @@ const failable<bool> writeList(const list<value>& l, const xmlTextWriterPtr xml)
const failable<bool> write(const list<value>& l, const xmlTextWriterPtr xml, bool xmlTag) {
if (xmlTag) {
if (xmlTextWriterStartDocument(xml, NULL, encoding, NULL) < 0)
- return mkfailure<bool>(string("xmlTextWriterStartDocument failed"));
+ return mkfailure<bool>("xmlTextWriterStartDocument failed");
}
const failable<bool> w = writeList(l, xml);
@@ -371,7 +371,7 @@ template<typename R> const failable<R> writeXML(const lambda<R(const string&, co
const failable<bool> w = write(l, xml, xmlTag);
xmlFreeTextWriter(xml);
if (!hasContent(w)) {
- return mkfailure<R>(reason(w));
+ return mkfailure<R>(w);
}
return cx.accum;
}
diff --git a/sca-cpp/trunk/modules/http/Makefile.am b/sca-cpp/trunk/modules/http/Makefile.am
index 161279a73f..4fd7cc0818 100644
--- a/sca-cpp/trunk/modules/http/Makefile.am
+++ b/sca-cpp/trunk/modules/http/Makefile.am
@@ -76,7 +76,7 @@ if WANT_MODSECURITY
modsecurity.prefix: $(top_builddir)/config.status
echo ${MODSECURITY_PREFIX} >modsecurity.prefix
-dist_modsecurity_SCRIPTS = mod-security-conf
+dist_modsecurity_SCRIPTS = mod-security-conf mod-security-audit-conf
modsecurity_DATA = modsecurity.prefix
modsecuritydir = $(prefix)/modules/http
diff --git a/sca-cpp/trunk/modules/http/http-test b/sca-cpp/trunk/modules/http/http-test
index 73cfe700a6..956b13a516 100755
--- a/sca-cpp/trunk/modules/http/http-test
+++ b/sca-cpp/trunk/modules/http/http-test
@@ -18,6 +18,7 @@
# under the License.
# Setup
+rm -rf tmp
./httpd-conf tmp localhost 8090 htdocs
./httpd-event-conf tmp
./httpd-start tmp
diff --git a/sca-cpp/trunk/modules/http/http.hpp b/sca-cpp/trunk/modules/http/http.hpp
index eb7a8d506f..e8c88f8a83 100644
--- a/sca-cpp/trunk/modules/http/http.hpp
+++ b/sca-cpp/trunk/modules/http/http.hpp
@@ -371,7 +371,7 @@ template<typename R> const failable<list<R> > apply(const list<list<string> >& h
// Setup the CURL session
const failable<CURL*> fch = setup(url, cs);
if (!hasContent(fch))
- return mkfailure<list<R>>(reason(fch));
+ return mkfailure<list<R>>(fch);
CURL* ch = content(fch);
// Set the request headers
@@ -440,19 +440,19 @@ const failable<value> evalExpr(const value& expr, const string& url, const CURLS
js::JSContext cx;
const failable<list<string> > jsreq = json::jsonRequest(1, car<value>(expr), cdr<value>(expr), cx);
if (!hasContent(jsreq))
- return mkfailure<value>(reason(jsreq));
+ return mkfailure<value>(jsreq);
// POST it to the URL
const list<string> h = mklist<string>("Content-Type: application/json-rpc");
const failable<list<list<string> > > res = apply<list<string> >(mklist<list<string> >(h, content(jsreq)), rcons<string>, list<string>(), url, "POST", cs);
if (!hasContent(res))
- return mkfailure<value>(reason(res));
+ return mkfailure<value>(res);
// Parse and return JSON-RPC result
const failable<value> rval = json::jsonResultValue(cadr<list<string> >(content(res)), cx);
debug(rval, "http::evalExpr::result");
if (!hasContent(rval))
- return mkfailure<value>(reason(rval));
+ return mkfailure<value>(rval);
return content(rval);
}
@@ -513,7 +513,7 @@ const failable<value> getcontent(const string& url, const CURLSession& cs) {
// Get the contents of the resource at the given URL
const failable<list<list<string> > > res = get<list<string>>(rcons<string>, list<string>(), url, cs);
if (!hasContent(res))
- return mkfailure<value>(reason(res));
+ return mkfailure<value>(res);
const list<string> ls(reverse(cadr(content(res))));
// Return the content as a list of values
@@ -597,7 +597,7 @@ const failable<value> get(const string& url, const CURLSession& cs) {
// Get the contents of the resource at the given URL
const failable<list<list<string> > > res = get<list<string> >(rcons<string>, list<string>(), url, cs);
if (!hasContent(res))
- return mkfailure<value>(reason(res));
+ return mkfailure<value>(res);
// Parse the returned content
return responseValue(content(res));
@@ -608,7 +608,7 @@ const failable<value> get(const string& url, const CURLSession& cs) {
*/
const failable<list<list<string> > > writeRequest(const failable<list<string> >& ls, const string& ct) {
if (!hasContent(ls))
- return mkfailure<list<list<string> > >(reason(ls));
+ return mkfailure<list<list<string> > >(ls);
const list<list<string> > req = mklist<list<string> >(mklist<string>(string("Content-Type: ") + ct), content(ls));
debug(req, "http::writeRequest::req");
return req;
@@ -695,13 +695,13 @@ const failable<value> post(const value& val, const string& url, const CURLSessio
// Convert value to a content request
const failable<list<list<string> > > req = contentRequest(val, url);
if (!hasContent(req))
- return mkfailure<value>(reason(req));
+ return mkfailure<value>(req);
debug(content(req), "http::post::input");
// POST it to the URL
const failable<list<list<string> > > res = apply<list<string>>(content(req), rcons<string>, list<string>(), url, "POST", cs);
if (!hasContent(res))
- return mkfailure<value>(reason(res));
+ return mkfailure<value>(res);
// Return the new entry id from the HTTP location header, if any
const string loc = location(car(content(res)));
@@ -724,13 +724,13 @@ const failable<value> put(const value& val, const string& url, const CURLSession
// Convert value to a content request
const failable<list<list<string> > > req = contentRequest(val, url);
if (!hasContent(req))
- return mkfailure<value>(reason(req));
+ return mkfailure<value>(req);
debug(content(req), "http::put::input");
// PUT it to the URL
const failable<list<list<string> > > res = apply<list<string> >(content(req), rcons<string>, list<string>(), url, "PUT", cs);
if (!hasContent(res))
- return mkfailure<value>(reason(res));
+ return mkfailure<value>(res);
debug(true, "http::put::result");
return value(true);
@@ -745,13 +745,13 @@ const failable<value> patch(const value& val, const string& url, const CURLSessi
// Convert value to a content request
const failable<list<list<string> > > req = contentRequest(val, url);
if (!hasContent(req))
- return mkfailure<value>(reason(req));
+ return mkfailure<value>(req);
debug(content(req), "http::patch::input");
// PATCH it to the URL
const failable<list<list<string> > > res = apply<list<string> >(content(req), rcons<string>, list<string>(), url, "PATCH", cs);
if (!hasContent(res))
- return mkfailure<value>(reason(res));
+ return mkfailure<value>(res);
debug(true, "http::patch::result");
return value(true);
@@ -766,7 +766,7 @@ const failable<value, string> del(const string& url, const CURLSession& cs) {
const list<list<string> > req = mklist(list<string>(), list<string>());
const failable<list<list<string> > > res = apply<list<string> >(req, rcons<string>, list<string>(), url, "DELETE", cs);
if (!hasContent(res))
- return mkfailure<value>(reason(res));
+ return mkfailure<value>(res);
debug(true, "http::delete::result");
return value(true);
@@ -805,7 +805,7 @@ const failable<bool> connect(const string& url, CURLSession& cs) {
// Setup the CURL session
const failable<CURL*> fch = setup(url, cs);
if (!hasContent(fch))
- return mkfailure<bool>(reason(fch));
+ return mkfailure<bool>(fch);
CURL* ch = content(fch);
// Connect
diff --git a/sca-cpp/trunk/modules/http/httpd-test b/sca-cpp/trunk/modules/http/httpd-test
index 2b151d0e12..ab6ab5ad41 100755
--- a/sca-cpp/trunk/modules/http/httpd-test
+++ b/sca-cpp/trunk/modules/http/httpd-test
@@ -22,6 +22,7 @@ here=`echo "import os; print os.path.realpath('$0')" | python`; here=`dirname $h
curl_prefix=`cat $here/../http/curl.prefix`
# Setup
+rm -rf tmp
./httpd-conf tmp localhost 8090 htdocs
./httpd-event-conf tmp
./httpd-start tmp
diff --git a/sca-cpp/trunk/modules/http/httpd.hpp b/sca-cpp/trunk/modules/http/httpd.hpp
index 718ed6e52b..7147e8839c 100644
--- a/sca-cpp/trunk/modules/http/httpd.hpp
+++ b/sca-cpp/trunk/modules/http/httpd.hpp
@@ -402,7 +402,7 @@ const list<string> read(request_rec* r) {
*/
const failable<int> writeResult(const failable<list<string> >& ls, const string& ct, request_rec* r) {
if (!hasContent(ls))
- return mkfailure<int>(reason(ls));
+ return mkfailure<int>(ls);
ostringstream os;
write(content(ls), os);
const string ob(str(os));
@@ -437,8 +437,10 @@ const failable<int> writeResult(const failable<list<string> >& ls, const string&
*/
const int reportStatus(const failable<int>& rc) {
debug(rc, "httpd::reportStatus::rc");
- if (!hasContent(rc))
- return HTTP_INTERNAL_SERVER_ERROR;
+ if (!hasContent(rc)) {
+ const int r = rcode(rc);
+ return r == -1 ? HTTP_INTERNAL_SERVER_ERROR : r;
+ }
return content(rc);
}
@@ -725,7 +727,7 @@ const bool debugRequest(request_rec* r, const string& msg) {
return true;
}
-#define debug_httpdRequest(r, msg) if (debug_islogging()) httpd::debugRequest(r, msg)
+#define debug_httpdRequest(r, msg) do { if (debug_islogging()) httpd::debugRequest(r, msg); } while(0)
#else
diff --git a/sca-cpp/trunk/modules/http/mod-security-audit-conf b/sca-cpp/trunk/modules/http/mod-security-audit-conf
new file mode 100755
index 0000000000..5914bd1df4
--- /dev/null
+++ b/sca-cpp/trunk/modules/http/mod-security-audit-conf
@@ -0,0 +1,44 @@
+#!/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.
+
+# Generate a minimal mod-security audit configuration.
+here=`echo "import os; print os.path.realpath('$0')" | python`; here=`dirname $here`
+mkdir -p $1
+root=`echo "import os; print os.path.realpath('$1')" | python`
+
+mkdir -p $root/tmp
+
+cat >>$root/conf/mod-security.conf <<EOF
+# Generated by: mod-security-audit-conf $*
+# Enable mod-security audit log
+SecAuditEngine RelevantOnly
+SecAuditLogRelevantStatus "^(?:5|4(?!04))"
+SecAuditLogParts ABIJDEFHKZ
+SecAuditLogType Serial
+Include conf/mod-security-audit-log.conf
+
+EOF
+
+# Configure audit logging
+cat >$root/conf/mod-security-audit-log.conf <<EOF
+# Generated by: mod-security-audit-conf $*
+SecAuditLog $root/logs/secaudit_log
+
+EOF
+
diff --git a/sca-cpp/trunk/modules/http/mod-security-conf b/sca-cpp/trunk/modules/http/mod-security-conf
index fdc4d8e24d..4d978a01cb 100755
--- a/sca-cpp/trunk/modules/http/mod-security-conf
+++ b/sca-cpp/trunk/modules/http/mod-security-conf
@@ -81,8 +81,8 @@ IH %{MULTIPART_FILE_LIMIT_EXCEEDED}'"
SecRule MULTIPART_UNMATCHED_BOUNDARY "!@eq 0" "phase:2,t:none,log,deny,status:44,msg:'Multipart parser detected a possible unmatched boundary.'"
# Avoid a potential RegEx DoS condition
-SecPcreMatchLimit 10000
-SecPcreMatchLimitRecursion 10000
+SecPcreMatchLimit 50000
+SecPcreMatchLimitRecursion 50000
SecRule TX:/^MSC_/ "!@streq 0" "phase:2,t:none,deny,msg:'ModSecurity internal error flagged: %{MATCHED_VAR_NAME}'"
# Detect slow DoS attacks
@@ -100,13 +100,6 @@ SecResponseBodyLimitAction ProcessPartial
SecTmpDir $root/tmp/
SecDataDir $root/tmp/
-# Enable mod-security audit log
-SecAuditEngine RelevantOnly
-SecAuditLogRelevantStatus "^(?:5|4(?!04))"
-SecAuditLogParts ABIJDEFHKZ
-SecAuditLogType Serial
-Include conf/mod-security-log.conf
-
# Use & as application/x-www-form-urlencoded parameter separator
SecArgumentSeparator &
@@ -120,8 +113,8 @@ setvar:tx.critical_anomaly_score=5, \
setvar:tx.error_anomaly_score=4, \
setvar:tx.warning_anomaly_score=3, \
setvar:tx.notice_anomaly_score=2"
-SecAction "phase:1,id:'981208',t:none,nolog,pass,setvar:tx.inbound_anomaly_score_level=5"
-SecAction "phase:1,id:'981209',t:none,nolog,pass,setvar:tx.outbound_anomaly_score_level=4"
+SecAction "phase:1,id:'981208',t:none,nolog,pass,setvar:tx.inbound_anomaly_score_level=10"
+SecAction "phase:1,id:'981209',t:none,nolog,pass,setvar:tx.outbound_anomaly_score_level=8"
# Paranoid mode
SecAction "phase:1,id:'981210',t:none,nolog,pass,setvar:tx.paranoid_mode=0"
@@ -186,12 +179,6 @@ Include ${modsecurity_prefix}/optional_rules/modsecurity_crs_25_cc_known.conf
Include ${modsecurity_prefix}/optional_rules/modsecurity_crs_42_comment_spam.conf
Include ${modsecurity_prefix}/optional_rules/modsecurity_crs_47_skip_outbound_checks.conf
Include ${modsecurity_prefix}/optional_rules/modsecurity_crs_55_application_defects.conf
-EOF
-
-# Configure audit logging
-cat >$root/conf/mod-security-log.conf <<EOF
-# Generated by: mod-security-conf $*
-SecAuditLog $root/logs/modsec_audit_log
EOF
diff --git a/sca-cpp/trunk/modules/http/proxy-test b/sca-cpp/trunk/modules/http/proxy-test
index 9f3d248fdf..0333dd280b 100755
--- a/sca-cpp/trunk/modules/http/proxy-test
+++ b/sca-cpp/trunk/modules/http/proxy-test
@@ -18,6 +18,7 @@
# under the License.
# Setup
+rm -rf tmp
./httpd-conf tmp localhost 8091/8090 htdocs
./httpd-event-conf tmp
./httpd-start tmp
diff --git a/sca-cpp/trunk/modules/java/mod-java.cpp b/sca-cpp/trunk/modules/java/mod-java.cpp
index 8c25f6f8ef..d96861cc6d 100644
--- a/sca-cpp/trunk/modules/java/mod-java.cpp
+++ b/sca-cpp/trunk/modules/java/mod-java.cpp
@@ -73,6 +73,8 @@ const failable<lambda<value(const list<value>&)> > evalImplementation(const stri
}
if (contains(itype, ".cpp"))
return modcpp::evalImplementation(path, impl, px);
+ if (contains(itype, ".widget"))
+ return mkfailure<lambda<value(const list<value>&)> >(string("Unsupported implementation type: ") + itype, -1, false);
return mkfailure<lambda<value(const list<value>&)> >(string("Unsupported implementation type: ") + itype);
}
diff --git a/sca-cpp/trunk/modules/java/mod-java.hpp b/sca-cpp/trunk/modules/java/mod-java.hpp
index e7da06e930..b68f17aa3f 100644
--- a/sca-cpp/trunk/modules/java/mod-java.hpp
+++ b/sca-cpp/trunk/modules/java/mod-java.hpp
@@ -52,7 +52,7 @@ struct applyImplementation {
const value expr = append<value>(params, px);
debug(expr, "modeval::java::applyImplementation::input");
const failable<value> res = java::evalClass(jr, expr, impl);
- const value val = !hasContent(res)? mklist<value>(value(), reason(res)) : mklist<value>(content(res));
+ const value val = !hasContent(res)? mklist<value>(value(), reason(res), rcode(res)) : mklist<value>(content(res));
debug(val, "modeval::java::applyImplementation::result");
return val;
}
@@ -66,7 +66,7 @@ const failable<lambda<value(const list<value>&)> > evalImplementation(const stri
const string cn(attributeValue("class", impl));
const failable<java::JavaClass> jc = java::readClass(jr, path, cn);
if (!hasContent(jc))
- return mkfailure<lambda<value(const list<value>&)> >(reason(jc));
+ return mkfailure<lambda<value(const list<value>&)> >(jc);
return lambda<value(const list<value>&)>(applyImplementation(content(jc), px, jr));
}
diff --git a/sca-cpp/trunk/modules/java/server-test b/sca-cpp/trunk/modules/java/server-test
index 40e52d7153..0b45649ace 100755
--- a/sca-cpp/trunk/modules/java/server-test
+++ b/sca-cpp/trunk/modules/java/server-test
@@ -18,6 +18,7 @@
# under the License.
# Setup
+rm -rf tmp
../http/httpd-conf tmp localhost 8090 ../server/htdocs
../server/server-conf tmp
./java-conf tmp
diff --git a/sca-cpp/trunk/modules/java/wiring-test b/sca-cpp/trunk/modules/java/wiring-test
index 941a75bc32..dd865c4c66 100755
--- a/sca-cpp/trunk/modules/java/wiring-test
+++ b/sca-cpp/trunk/modules/java/wiring-test
@@ -22,6 +22,7 @@ here=`echo "import os; print os.path.realpath('$0')" | python`; here=`dirname $h
curl_prefix=`cat $here/../http/curl.prefix`
# Setup
+rm -rf tmp
../http/httpd-conf tmp localhost 8090 ../server/htdocs
../server/server-conf tmp
./java-conf tmp
diff --git a/sca-cpp/trunk/modules/js/eval.hpp b/sca-cpp/trunk/modules/js/eval.hpp
index 149716e4ca..21fa274d2c 100644
--- a/sca-cpp/trunk/modules/js/eval.hpp
+++ b/sca-cpp/trunk/modules/js/eval.hpp
@@ -36,7 +36,7 @@
#ifdef WANT_MAINTAINER_WARNINGS
#pragma GCC diagnostic warning "-Wunused-parameter"
#pragma GCC diagnostic warning "-Wsign-compare"
-#pragma GCC diagnostic ignored "-Wredundant-decls"
+#pragma GCC diagnostic warning "-Wredundant-decls"
#endif
#include "string.hpp"
#include "list.hpp"
diff --git a/sca-cpp/trunk/modules/json/json.hpp b/sca-cpp/trunk/modules/json/json.hpp
index 39c56b6863..85579c1b28 100644
--- a/sca-cpp/trunk/modules/json/json.hpp
+++ b/sca-cpp/trunk/modules/json/json.hpp
@@ -72,7 +72,7 @@ const failable<list<value> > readJSON(const list<string>& ilist, const js::JSCon
if(!JS_FinishJSONParse(cx, parser, JSVAL_NULL))
return mkfailure<list<value> >("JS_FinishJSONParse failed");
if(!hasContent(consumed))
- return mkfailure<list<value> >(reason(consumed));
+ return mkfailure<list<value> >(consumed);
return list<value>(js::jsValToValue(val, cx));
}
@@ -149,7 +149,7 @@ const failable<list<string> > jsonResult(const value& id, const value& val, js::
const failable<value> jsonResultValue(const list<string>& s, js::JSContext& cx) {
const failable<list<value> > jsres = json::readJSON(s, cx);
if (!hasContent(jsres))
- return mkfailure<value>(reason(jsres));
+ return mkfailure<value>(jsres);
const list<value> rval(cadr<value>(elementsToValues(content(jsres))));
const value val = cadr(rval);
if (isList(val) && !js::isJSArray(val))
diff --git a/sca-cpp/trunk/modules/oauth/mod-oauth1.cpp b/sca-cpp/trunk/modules/oauth/mod-oauth1.cpp
index b927315393..eb23443491 100644
--- a/sca-cpp/trunk/modules/oauth/mod-oauth1.cpp
+++ b/sca-cpp/trunk/modules/oauth/mod-oauth1.cpp
@@ -235,7 +235,7 @@ const failable<int> authorize(const list<list<value> >& args, request_rec* r, co
// Store the request token in memcached
const failable<bool> prc = memcache::put(mklist<value>("tuscanyOAuth1Token", cadr(tv)), cadr(sv), mc);
if (!hasContent(prc))
- return mkfailure<int>(reason(prc));
+ return mkfailure<int>(prc);
// Redirect to the authorize URI
const string authuri = httpd::unescape(cadr(auth)) + string("?") + http::queryString(mklist<list<value> >(tv));
@@ -327,7 +327,7 @@ const failable<int> accessToken(const list<list<value> >& args, request_rec* r,
// Retrieve the request token from memcached
const failable<value> sv = memcache::get(mklist<value>("tuscanyOAuth1Token", cadr(tv)), mc);
if (!hasContent(sv))
- return mkfailure<int>(reason(sv));
+ return mkfailure<int>(sv);
// Build and sign access token request URI
const string tokuri = httpd::unescape(cadr(tok)) + string("?") + http::queryString(mklist<list<value> >(vv));
@@ -374,13 +374,13 @@ const failable<int> accessToken(const list<list<value> >& args, request_rec* r,
// Retrieve the user info from the profile
const failable<list<value> > iv = profileUserInfo(cadr(cid), profres);
if (!hasContent(iv))
- return mkfailure<int>(reason(iv));
+ return mkfailure<int>(iv);
// Store user info in memcached keyed by session ID
const value sid = string("OAuth1_") + mkrand();
const failable<bool> prc = memcache::put(mklist<value>("tuscanyOAuth1", sid), content(iv), mc);
if (!hasContent(prc))
- return mkfailure<int>(reason(prc));
+ return mkfailure<int>(prc);
// Send session ID to the client in a cookie
debug(c_str(openauth::cookie("TuscanyOAuth1", sid, httpd::hostName(r))), "modoauth1::access_token::setcookie");
diff --git a/sca-cpp/trunk/modules/oauth/mod-oauth2.cpp b/sca-cpp/trunk/modules/oauth/mod-oauth2.cpp
index 05ad77d646..cbece191aa 100644
--- a/sca-cpp/trunk/modules/oauth/mod-oauth2.cpp
+++ b/sca-cpp/trunk/modules/oauth/mod-oauth2.cpp
@@ -222,7 +222,7 @@ const failable<int> accessToken(const list<list<value> >& args, request_rec* r,
const value tval = mklist<value>(string("application/x-www-form-urlencoded;charset=UTF-8"), mklist<value>(tqs));
const failable<value> ftr = http::post(tval, turi, *(cs));
if (!hasContent(ftr))
- return mkfailure<int>(reason(ftr));
+ return mkfailure<int>(ftr);
const value tr = content(ftr);
debug(tr, "modoauth2::access_token::response");
if (!isList(tr) || isNil(tr))
@@ -247,13 +247,13 @@ const failable<int> accessToken(const list<list<value> >& args, request_rec* r,
// Retrieve the user info from the profile
const failable<list<value> > iv = profileUserInfo(cadr(cid), content(profres));
if (!hasContent(iv))
- return mkfailure<int>(reason(iv));
+ return mkfailure<int>(iv);
// Store user info in memcached keyed by session ID
const value sid = string("OAuth2_") + mkrand();
const failable<bool> prc = memcache::put(mklist<value>("tuscanyOAuth2", sid), content(iv), mc);
if (!hasContent(prc))
- return mkfailure<int>(reason(prc));
+ return mkfailure<int>(prc);
// Send session ID to the client in a cookie
debug(c_str(openauth::cookie("TuscanyOAuth2", sid, httpd::hostName(r))), "modoauth2::access_token::setcookie");
diff --git a/sca-cpp/trunk/modules/oauth/start-mixed-test b/sca-cpp/trunk/modules/oauth/start-mixed-test
index 11bba42ef0..e5a8837354 100755
--- a/sca-cpp/trunk/modules/oauth/start-mixed-test
+++ b/sca-cpp/trunk/modules/oauth/start-mixed-test
@@ -24,6 +24,7 @@
here=`echo "import os; print os.path.realpath('$0')" | python`; here=`dirname $here`
# Setup
+rm -rf tmp
../../components/cache/memcached-start tmp 11212
../../components/cache/memcached-start tmp 11213
diff --git a/sca-cpp/trunk/modules/oauth/start-test b/sca-cpp/trunk/modules/oauth/start-test
index 21e1e005bd..8fc41cdb9a 100755
--- a/sca-cpp/trunk/modules/oauth/start-test
+++ b/sca-cpp/trunk/modules/oauth/start-test
@@ -21,6 +21,7 @@
# 127.0.0.1 www.example.com
# Setup
+rm -rf tmp
#../../ubuntu/ip-redirect-all 80 8090
#../../ubuntu/ip-redirect-all 443 8453
diff --git a/sca-cpp/trunk/modules/opencl/eval.hpp b/sca-cpp/trunk/modules/opencl/eval.hpp
index 82706ff0f2..5606b2f57a 100644
--- a/sca-cpp/trunk/modules/opencl/eval.hpp
+++ b/sca-cpp/trunk/modules/opencl/eval.hpp
@@ -475,7 +475,7 @@ const failable<list<OpenCLBuffer>> valuesToKernelArgsListHelper(const list<value
return list<OpenCLBuffer>();
const failable<OpenCLBuffer> a = valueToKernelArg(car(v), i, kernel, cl, cq);
if (!hasContent(a))
- return mkfailure<list<OpenCLBuffer>>(reason(a));
+ return mkfailure<list<OpenCLBuffer>>(a);
const failable<list<OpenCLBuffer>> al = valuesToKernelArgsListHelper(cdr(v), i + 1, kernel, cl, cq);
if (!hasContent(al))
return al;
@@ -600,7 +600,7 @@ const failable<value> evalKernel(const failable<OpenCLKernel>& fkernel, const va
#endif
if (!hasContent(fkernel))
- return mkfailure<value>(reason(fkernel));
+ return mkfailure<value>(fkernel);
const OpenCLKernel kernel = content(fkernel);
// Get a command queue for the specified device type
@@ -609,7 +609,7 @@ const failable<value> evalKernel(const failable<OpenCLKernel>& fkernel, const va
// Set the kernel input args
const failable<list<OpenCLBuffer>> args = valuesToKernelArgs(cdr<value>(expr), kernel, cl, cq);
if (!hasContent(args)) {
- return mkfailure<value>(reason(args));
+ return mkfailure<value>(args);
}
// Allocate result buffer in device memory
@@ -618,13 +618,13 @@ const failable<value> evalKernel(const failable<OpenCLKernel>& fkernel, const va
const size_t rsize = rtype.n * rtype.size;
const failable<OpenCLBuffer> rbuf = writeOnlyBuffer(rsize, cl);
if (!hasContent(rbuf))
- return mkfailure<value>(reason(rbuf));
+ return mkfailure<value>(rbuf);
// Set it as a kernel output arg
const cl_mem rmem = content(rbuf).mem;
const failable<OpenCLBuffer> rarg = valueToKernelArg((cl_uint)length(cdr<value>(expr)), sizeof(cl_mem), &rmem, rbuf, kernel);
if (!hasContent(rarg))
- return mkfailure<value>(reason(rarg));
+ return mkfailure<value>(rarg);
// Enqueue the kernel, to be executed after all the writes complete
cl_event wevt[32];
@@ -715,7 +715,7 @@ const failable<OpenCLProgram> readProgram(const string& path, istream& is, const
const failable<value> evalKernel(const value& expr, istream& is, const OpenCLContext& cl) {
failable<OpenCLProgram> clprog = readProgram("program.cl", is, cl);
if (!hasContent(clprog))
- return mkfailure<value>(reason(clprog));
+ return mkfailure<value>(clprog);
return evalKernel(createKernel(expr, content(clprog)), expr, 1, value::Nil, 0, cl);
}
diff --git a/sca-cpp/trunk/modules/opencl/server-test b/sca-cpp/trunk/modules/opencl/server-test
index e623599b39..c103c45487 100755
--- a/sca-cpp/trunk/modules/opencl/server-test
+++ b/sca-cpp/trunk/modules/opencl/server-test
@@ -18,6 +18,7 @@
# under the License.
# Setup
+rm -rf tmp
../http/httpd-conf tmp localhost 8090 ../server/htdocs
../server/server-conf tmp
./opencl-conf tmp
diff --git a/sca-cpp/trunk/modules/openid/start-test b/sca-cpp/trunk/modules/openid/start-test
index 5cac1dbe14..f0d27d16be 100755
--- a/sca-cpp/trunk/modules/openid/start-test
+++ b/sca-cpp/trunk/modules/openid/start-test
@@ -18,6 +18,7 @@
# under the License.
# Setup
+rm -rf tmp
../../components/cache/memcached-start tmp 11212
../../components/cache/memcached-start tmp 11213
diff --git a/sca-cpp/trunk/modules/python/mod-python.cpp b/sca-cpp/trunk/modules/python/mod-python.cpp
index 89a2db1b33..956edf1059 100644
--- a/sca-cpp/trunk/modules/python/mod-python.cpp
+++ b/sca-cpp/trunk/modules/python/mod-python.cpp
@@ -73,6 +73,8 @@ const failable<lambda<value(const list<value>&)> > evalImplementation(const stri
}
if (contains(itype, ".cpp"))
return modcpp::evalImplementation(path, impl, px);
+ if (contains(itype, ".widget"))
+ return mkfailure<lambda<value(const list<value>&)> >(string("Unsupported implementation type: ") + itype, -1, false);
return mkfailure<lambda<value(const list<value>&)> >(string("Unsupported implementation type: ") + itype);
}
diff --git a/sca-cpp/trunk/modules/python/mod-python.hpp b/sca-cpp/trunk/modules/python/mod-python.hpp
index a4d77775a5..e6effb985b 100644
--- a/sca-cpp/trunk/modules/python/mod-python.hpp
+++ b/sca-cpp/trunk/modules/python/mod-python.hpp
@@ -52,7 +52,7 @@ struct applyImplementation {
const value expr = append<value>(params, px);
debug(expr, "modeval::python::applyImplementation::input");
const failable<value> res = python::evalScript(expr, impl, py);
- const value val = !hasContent(res)? mklist<value>(value(), reason(res)) : mklist<value>(content(res));
+ const value val = !hasContent(res)? mklist<value>(value(), reason(res), rcode(res)) : mklist<value>(content(res));
debug(val, "modeval::python::applyImplementation::result");
return val;
}
@@ -70,7 +70,7 @@ const failable<lambda<value(const list<value>&)> > evalImplementation(const stri
return mkfailure<lambda<value(const list<value>&)> >(string("Could not read implementation: ") + fpath);
const failable<PyObject*> script = python::readScript(python::moduleName(spath), fpath, is, py);
if (!hasContent(script))
- return mkfailure<lambda<value(const list<value>&)> >(reason(script));
+ return mkfailure<lambda<value(const list<value>&)> >(script);
return lambda<value(const list<value>&)>(applyImplementation(content(script), px, py));
}
diff --git a/sca-cpp/trunk/modules/python/server-test b/sca-cpp/trunk/modules/python/server-test
index ecde5ca8ad..6ab5823643 100755
--- a/sca-cpp/trunk/modules/python/server-test
+++ b/sca-cpp/trunk/modules/python/server-test
@@ -18,6 +18,7 @@
# under the License.
# Setup
+rm -rf tmp
../http/httpd-conf tmp localhost 8090 ../server/htdocs
../http/httpd-event-conf tmp
../server/server-conf tmp
diff --git a/sca-cpp/trunk/modules/python/wiring-test b/sca-cpp/trunk/modules/python/wiring-test
index 4dd3ca7228..899c3eb5a1 100755
--- a/sca-cpp/trunk/modules/python/wiring-test
+++ b/sca-cpp/trunk/modules/python/wiring-test
@@ -22,6 +22,7 @@ here=`echo "import os; print os.path.realpath('$0')" | python`; here=`dirname $h
curl_prefix=`cat $here/../http/curl.prefix`
# Setup
+rm -rf tmp
../http/httpd-conf tmp localhost 8090 ../server/htdocs
../http/httpd-event-conf tmp
../server/server-conf tmp
diff --git a/sca-cpp/trunk/modules/scheme/json-value.cpp b/sca-cpp/trunk/modules/scheme/json-value.cpp
index d7ffc2b37b..4bdf8bd37f 100644
--- a/sca-cpp/trunk/modules/scheme/json-value.cpp
+++ b/sca-cpp/trunk/modules/scheme/json-value.cpp
@@ -36,7 +36,7 @@ int jsonValue() {
const js::JSContext cx;
const failable<list<value> > lv = json::readJSON(streamList(cin), cx);
if (!hasContent(lv)) {
- cerr << reason(lv);
+ cerr << reason(lv) << " : " << rcode(lv);
return 1;
}
cout << writeValue(content(lv));
diff --git a/sca-cpp/trunk/modules/scheme/value-json.cpp b/sca-cpp/trunk/modules/scheme/value-json.cpp
index 5045226db9..a8c875fcc8 100644
--- a/sca-cpp/trunk/modules/scheme/value-json.cpp
+++ b/sca-cpp/trunk/modules/scheme/value-json.cpp
@@ -36,7 +36,7 @@ int valueJSON() {
const js::JSContext cx;
failable<list<string> > s = json::writeJSON(readValue(cin), cx);
if (!hasContent(s)) {
- cerr << reason(s);
+ cerr << reason(s) << " : " << rcode(s);
return 1;
}
write(content(s), cout);
diff --git a/sca-cpp/trunk/modules/scheme/value-xml.cpp b/sca-cpp/trunk/modules/scheme/value-xml.cpp
index 7091d5c8ba..ff785899c6 100644
--- a/sca-cpp/trunk/modules/scheme/value-xml.cpp
+++ b/sca-cpp/trunk/modules/scheme/value-xml.cpp
@@ -35,7 +35,7 @@ namespace scheme {
int valueXML() {
failable<list<string> > s = writeXML(readValue(cin));
if (!hasContent(s)) {
- cerr << reason(s);
+ cerr << reason(s) << " : " << rcode(s);
return 1;
}
write(content(s), cout);
diff --git a/sca-cpp/trunk/modules/server/httpd-test b/sca-cpp/trunk/modules/server/httpd-test
index 63b268d7b3..195caa4562 100755
--- a/sca-cpp/trunk/modules/server/httpd-test
+++ b/sca-cpp/trunk/modules/server/httpd-test
@@ -22,6 +22,7 @@ here=`echo "import os; print os.path.realpath('$0')" | python`; here=`dirname $h
curl_prefix=`cat $here/../http/curl.prefix`
# Setup
+rm -rf tmp
../http/httpd-conf tmp localhost 8090 htdocs
../http/httpd-event-conf tmp
./server-conf tmp
diff --git a/sca-cpp/trunk/modules/server/mod-eval.cpp b/sca-cpp/trunk/modules/server/mod-eval.cpp
index fcc4981ec0..3fd69c1fea 100644
--- a/sca-cpp/trunk/modules/server/mod-eval.cpp
+++ b/sca-cpp/trunk/modules/server/mod-eval.cpp
@@ -55,6 +55,8 @@ const failable<lambda<value(const list<value>&)> > evalImplementation(const stri
return modscheme::evalImplementation(path, impl, px);
if (contains(itype, ".cpp"))
return modcpp::evalImplementation(path, impl, px);
+ if (contains(itype, ".widget"))
+ return mkfailure<lambda<value(const list<value>&)> >(string("Unsupported implementation type: ") + itype, -1, false);
return mkfailure<lambda<value(const list<value>&)> >(string("Unsupported implementation type: ") + itype);
}
diff --git a/sca-cpp/trunk/modules/server/mod-eval.hpp b/sca-cpp/trunk/modules/server/mod-eval.hpp
index ef2a2f6575..ac5bf55698 100644
--- a/sca-cpp/trunk/modules/server/mod-eval.hpp
+++ b/sca-cpp/trunk/modules/server/mod-eval.hpp
@@ -151,7 +151,7 @@ public:
const failable<value> failableResult(const list<value>& v) {
if (isNil(cdr(v)))
return car(v);
- return mkfailure<value>(string(cadr(v)), false);
+ return mkfailure<value>(string(cadr(v)), isNil(cddr(v))? -1 : (int)caddr(v), false);
}
/**
@@ -191,7 +191,7 @@ public:
}
const value callImpl(const value& cname, const list<value>& aparams) const {
- debug(impls, "modeval::implProxy::callImpl::impls");
+ //debug(impls, "modeval::implProxy::callImpl::impls");
// Lookup the component implementation
const list<value> impl(assoctree<value>(cname, impls));
@@ -345,9 +345,11 @@ struct hostPropProxy {
hostPropProxy(const value& v) : v(v) {
}
const value operator()(unused const list<value>& params) const {
- const value r = httpd::hostName(currentRequest, v);
- debug(r, "modeval::hostPropProxy::value");
- return r;
+ if (currentRequest == NULL)
+ return http::hostName();
+ const value h = httpd::hostName(currentRequest, v);
+ debug(h, "modeval::hostPropProxy::value");
+ return h;
}
};
@@ -356,6 +358,8 @@ struct appPropProxy {
appPropProxy(const value& v) : v(v) {
}
const value operator()(unused const list<value>& params) const {
+ if (currentRequest == NULL)
+ return v;
const RequestConf& reqc = httpd::requestConf<RequestConf>(currentRequest, &mod_tuscany_eval);
const value a = isNil(reqc.vpath)? v : car(reqc.vpath);
debug(a, "modeval::appPropProxy::value");
@@ -364,23 +368,29 @@ struct appPropProxy {
};
struct pathPropProxy {
- pathPropProxy(unused const value& v) {
+ const value v;
+ pathPropProxy(const value& v) : v(v) {
}
const value operator()(unused const list<value>& params) const {
+ if (currentRequest == NULL)
+ return v;
const RequestConf& reqc = httpd::requestConf<RequestConf>(currentRequest, &mod_tuscany_eval);
- const value v = reqc.rpath;
- debug(v, "modeval::pathPropProxy::value");
- return v;
+ const value p = reqc.rpath;
+ debug(p, "modeval::pathPropProxy::value");
+ return p;
}
};
struct queryPropProxy {
- queryPropProxy(unused const value& v) {
+ const value v;
+ queryPropProxy(const value& v) : v(v) {
}
const value operator()(unused const list<value>& params) const {
- const value v = httpd::unescapeArgs(httpd::queryArgs(currentRequest));
- debug(v, "modeval::queryPropProxy::value");
- return v;
+ if (currentRequest == NULL)
+ return v;
+ const value q = httpd::unescapeArgs(httpd::queryArgs(currentRequest));
+ debug(q, "modeval::queryPropProxy::value");
+ return q;
}
};
@@ -390,10 +400,34 @@ struct envPropProxy {
envPropProxy(const string& name, const value& v) : name(name), v(v) {
}
const value operator()(unused const list<value>& params) const {
+ if (currentRequest == NULL)
+ return v;
const char* env = apr_table_get(currentRequest->subprocess_env, c_str(name));
if (env == NULL || *env == '\0')
return v;
- return string(env);
+ debug(name, "modeval::envPropProxy::name");
+ const value e = string(env);
+ debug(e, "modeval::envPropProxy::value");
+ return e;
+ }
+};
+
+struct realmPropProxy {
+ const value v;
+ realmPropProxy(const value& v) : v(v) {
+ }
+ const value operator()(unused const list<value>& params) const {
+ if (currentRequest == NULL)
+ return v;
+ const char* env = apr_table_get(currentRequest->subprocess_env, "REALM");
+ if (env == NULL)
+ return v;
+ const char* realm = strncmp(env, "www.", 4) == 0? env + 4 : env;
+ if (*realm == '\0')
+ return v;
+ const value r = string(realm);
+ debug(r, "modeval::realmPropProxy::value");
+ return r;
}
};
@@ -402,9 +436,13 @@ struct userPropProxy {
userPropProxy(const value& v) : v(v) {
}
const value operator()(unused const list<value>& params) const {
+ if (currentRequest == NULL)
+ return v;
if (currentRequest->user == NULL)
return v;
- return string(currentRequest->user);
+ const value u = string(currentRequest->user);
+ debug(u, "modeval::userPropProxy::value");
+ return u;
}
};
@@ -422,7 +460,7 @@ const value mkpropProxy(const value& prop) {
if (n == "user")
return lambda<value(const list<value>&)>(userPropProxy(v));
if (n == "realm")
- return lambda<value(const list<value>&)>(envPropProxy("REALM", v));
+ return lambda<value(const list<value>&)>(realmPropProxy(v));
if (n == "email")
return lambda<value(const list<value>&)>(envPropProxy("EMAIL", v));
if (n == "nickname")
@@ -508,13 +546,13 @@ const failable<list<value> > readComponents(const string& path) {
const failable<list<value> > getComponents(const lambda<value(const list<value>&)>& provider, const string& name) {
const failable<value> val = failableResult(provider(cons<value>("get", mklist<value>(mklist<value>(name)))));
if (!hasContent(val))
- return mkfailure<list<value> >(reason(val));
+ return mkfailure<list<value> >(val);
const list<value> c = assoc<value>(value("content"), (list<list<value> >)cdr<value>(content(val)));
if (isNil(c))
return mkfailure<list<value> >(string("Could not get composite: ") + name);
const failable<list<string> > x = writeXML(car<value>(valuesToElements(mklist<value>(mklist<value>(cadr(c))))));
if (!hasContent(x))
- return mkfailure<list<value> >(reason(x));
+ return mkfailure<list<value> >(x);
return scdl::components(readXML(content(x)));
}
@@ -530,7 +568,7 @@ const failable<list<value> > applyLifecycleExpr(const list<value>& impls, const
const lambda<value(const list<value>&)> l = cadr<value>(car(impls));
const failable<value> r = failableResult(l(expr));
if (!hasContent(r))
- return mkfailure<list<value> >(reason(r));
+ return mkfailure<list<value> >(r);
const lambda<value(const list<value>&)> rl = content(r);
// Use the returned lambda function, if any, from now on
@@ -604,7 +642,7 @@ const failable<Composite> confComponents(const string& contribPath, const string
readComponents(scdl::resourcePath(length(vhost) != 0? contribPath + vhost + "/" : contribPath, composName)) :
getComponents(provider, vhost);
if (!hasContent(fcomps))
- return mkfailure<Composite>(reason(fcomps));
+ return mkfailure<Composite>(fcomps);
const list<value> comps = content(fcomps);
debug(comps, "modeval::confComponents::comps");
@@ -630,7 +668,7 @@ const failable<list<value> > startComponents(const list<value>& impls) {
debug(flatten(impls), "modeval::startComponents::impls");
const failable<list<value> > fsimpls = applyLifecycleExpr(flatten(impls), mklist<value>("start"));
if (!hasContent(fsimpls))
- return mkfailure<list<value> >(reason(fsimpls));
+ return mkfailure<list<value> >(fsimpls);
const list<value> simpls = content(fsimpls);
debug(impls, "modeval::startComponents::simpls");
@@ -667,7 +705,7 @@ const failable<int> get(const list<value>& rpath, request_rec* r, const lambda<v
// Apply the requested function
const failable<value> val = failableResult(impl(cons(func, json::queryParams(args))));
if (!hasContent(val))
- return mkfailure<int>(reason(val));
+ return mkfailure<int>(val);
// Return JSON result
js::JSContext cx;
@@ -678,7 +716,7 @@ const failable<int> get(const list<value>& rpath, request_rec* r, const lambda<v
const list<value> params(cddr(rpath));
const failable<value> val = failableResult(impl(cons<value>("get", mklist<value>(params))));
if (!hasContent(val))
- return mkfailure<int>(reason(val));
+ return mkfailure<int>(val);
const value c = content(val);
debug(c, "modeval::get::content");
@@ -776,7 +814,7 @@ const failable<int> post(const list<value>& rpath, request_rec* r, const lambda<
// Evaluate the request expression
const failable<value> val = failableResult(impl(cons<value>(func, params)));
if (!hasContent(val))
- return mkfailure<int>(reason(val));
+ return mkfailure<int>(val);
// Return JSON result
return httpd::writeResult(json::jsonResult(id, content(val), cx), "application/json-rpc; charset=utf-8", r);
@@ -796,7 +834,7 @@ const failable<int> post(const list<value>& rpath, request_rec* r, const lambda<
// Evaluate the POST expression
const failable<value> val = failableResult(impl(cons<value>("post", mklist<value>(cddr(rpath), aval))));
if (!hasContent(val))
- return mkfailure<int>(reason(val));
+ return mkfailure<int>(val);
// Return the created resource location
debug(content(val), "modeval::post::location");
@@ -809,7 +847,7 @@ const failable<int> post(const list<value>& rpath, request_rec* r, const lambda<
// the component implementation function
const failable<value> val = failableResult(impl(cons<value>("handle", mklist<value>(httpd::requestValue(r)))));
if (!hasContent(val))
- return mkfailure<int>(reason(val));
+ return mkfailure<int>(val);
return (int)content(val);
}
@@ -830,7 +868,7 @@ const failable<int> put(const list<value>& rpath, request_rec* r, const lambda<v
// Evaluate the PUT expression and update the corresponding resource
const failable<value> val = failableResult(impl(cons<value>("put", mklist<value>(cddr(rpath), aval))));
if (!hasContent(val))
- return mkfailure<int>(reason(val));
+ return mkfailure<int>(val);
if (val == value(false))
return HTTP_NOT_FOUND;
return OK;
@@ -845,7 +883,7 @@ const failable<int> del(const list<value>& rpath, request_rec* r, const lambda<v
// Evaluate an ATOM delete request
const failable<value> val = failableResult(impl(cons<value>("delete", mklist<value>(cddr(rpath)))));
if (!hasContent(val))
- return mkfailure<int>(reason(val));
+ return mkfailure<int>(val);
if (val == value(false))
return HTTP_NOT_FOUND;
return OK;
@@ -854,7 +892,12 @@ const failable<int> del(const list<value>& rpath, request_rec* r, const lambda<v
/**
* Proceed to handle a service component request.
*/
-int proceedToHandler(request_rec* r, const bool valias, const list<value>& rpath, const list<value>& vpath, const list<value>& impls) {
+int proceedToHandler(request_rec* r, const int rc) {
+ r->handler = "mod_tuscany_eval";
+ return rc;
+}
+
+int proceedToHandler(request_rec* r, const int rc, const bool valias, const list<value>& rpath, const list<value>& vpath, const list<value>& impls) {
r->handler = "mod_tuscany_eval";
r->filename = apr_pstrdup(r->pool, c_str(string("/redirect:") + r->uri));
@@ -864,7 +907,7 @@ int proceedToHandler(request_rec* r, const bool valias, const list<value>& rpath
reqc.rpath = rpath;
reqc.vpath = vpath;
reqc.impls = impls;
- return OK;
+ return rc;
}
/**
@@ -882,7 +925,7 @@ int translateComponent(request_rec *r, const list<value>& rpath, const list<valu
return HTTP_NOT_FOUND;
debug(impl, "modeval::translateComponent::impl");
- return proceedToHandler(r, false, rpath, vpath, impls);;
+ return proceedToHandler(r, OK, false, rpath, vpath, impls);;
}
/**
@@ -928,7 +971,7 @@ int translateReference(request_rec *r, const list<value>& rpath, const list<valu
const value tname = substr(target, 0, find(target, '/'));
const list<value> redir = cons<value>(string("c"), cons(tname, pathInfo));
debug(redir, "modeval::translateReference::redirect");
- return proceedToHandler(r, false, redir, vpath, impls);;
+ return proceedToHandler(r, OK, false, redir, vpath, impls);;
}
/**
@@ -973,7 +1016,7 @@ int translateService(request_rec *r, const list<value>& rpath, const list<value>
// / c / target component name / request path info
const list<value> redir = cons<value>(string("c"), cons<value>(cadr(svc), httpd::pathInfo(rpath, car(svc))));
debug(redir, "modeval::translateService::redirect");
- return proceedToHandler(r, false, redir, vpath, impls);
+ return proceedToHandler(r, OK, false, redir, vpath, impls);
}
/**
@@ -986,15 +1029,15 @@ const int translateRequest(request_rec* r, const list<value>& rpath, const list<
// Translate a component request
if ((prefix == string("components") || prefix == string("c")) && translateComponent(r, rpath, vpath, impls) == OK)
- return OK;
+ return proceedToHandler(r, OK);
// Translate a component reference request
if ((prefix == string("references") || prefix == string("r")) && translateReference(r, rpath, vpath, refs, impls) == OK)
- return OK;
+ return proceedToHandler(r, OK);
// Attempt to translate the request to a service request
if (translateService(r, rpath, vpath, svcs, impls) == OK)
- return OK;
+ return proceedToHandler(r, OK);
// Attempt to map a request targeting the main host to an actual file
if (isNil(vpath)) {
@@ -1019,15 +1062,14 @@ const int translateRequest(request_rec* r, const list<value>& rpath, const list<
if (isNil(rpath) && r->uri[strlen(r->uri) - 1] != '/') {
const string target = string(r->uri) + string("/") + (r->args != NULL? string("?") + string(r->args) : string(""));
debug(target, "modeval::translateRequest::location");
- r->handler = "mod_tuscany_eval";
- return httpd::externalRedirect(target, r);
+ return proceedToHandler(r, httpd::externalRedirect(target, r));
}
// If the request didn't match a service, reference or component,
// redirect it to / v / app / path. This will allow mapping to
// the actual app resource using HTTPD aliases.
debug(true, "modeval::translateRequest::valias");
- return proceedToHandler(r, true, rpath, vpath, impls);
+ return proceedToHandler(r, OK, true, rpath, vpath, impls);
}
return HTTP_NOT_FOUND;
@@ -1093,7 +1135,6 @@ int translate(request_rec *r) {
reqc.impls = vcompos.impls;
return translateRequest(r, cdr(rpath), mklist<value>(vname), vcompos.refs, vcompos.svcs, reqc.impls);
}
-
return DECLINED;
}
@@ -1129,15 +1170,18 @@ const int handleRequest(const list<value>& rpath, request_rec *r, const list<val
* HTTP request handler.
*/
int handler(request_rec *r) {
- if(r->method_number != M_GET && r->method_number != M_POST && r->method_number != M_PUT && r->method_number != M_DELETE)
+ if (r->handler != NULL && r->handler[0] != '\0')
return DECLINED;
+
+ // Attempt to translate the request
+ const int trc = translate(r);
+
+ // Pass if we couldn't translate the request
+ if(trc != OK)
+ return trc;
if(strcmp(r->handler, "mod_tuscany_eval"))
return DECLINED;
- // Nothing to do for an external redirect
- if (r->status == HTTP_MOVED_TEMPORARILY)
- return OK;
-
// Create a scoped memory pool and a scope for the current request
gc_scoped_pool pool(r->pool);
ScopedRequest sr(r);
@@ -1397,7 +1441,6 @@ void registerHooks(unused apr_pool_t *p) {
ap_hook_post_config(postConfig, NULL, NULL, APR_HOOK_MIDDLE);
ap_hook_child_init(childInit, NULL, NULL, APR_HOOK_MIDDLE);
ap_hook_handler(handler, NULL, NULL, APR_HOOK_MIDDLE);
- ap_hook_translate_name(translate, NULL, NULL, APR_HOOK_LAST);
}
}
diff --git a/sca-cpp/trunk/modules/server/server-test b/sca-cpp/trunk/modules/server/server-test
index 43557e7f7b..6b48d13e83 100755
--- a/sca-cpp/trunk/modules/server/server-test
+++ b/sca-cpp/trunk/modules/server/server-test
@@ -18,6 +18,7 @@
# under the License.
# Setup
+rm -rf tmp
../http/httpd-conf tmp localhost 8090 htdocs
../http/httpd-event-conf tmp
./server-conf tmp
diff --git a/sca-cpp/trunk/modules/server/wiring-test b/sca-cpp/trunk/modules/server/wiring-test
index 8bbcd684f2..7e1aea22b1 100755
--- a/sca-cpp/trunk/modules/server/wiring-test
+++ b/sca-cpp/trunk/modules/server/wiring-test
@@ -22,6 +22,7 @@ here=`echo "import os; print os.path.realpath('$0')" | python`; here=`dirname $h
curl_prefix=`cat $here/../http/curl.prefix`
# Setup
+rm -rf tmp
../http/httpd-conf tmp localhost 8090 htdocs
../http/httpd-event-conf tmp
./server-conf tmp
diff --git a/sca-cpp/trunk/modules/wsgi/gae-stop b/sca-cpp/trunk/modules/wsgi/gae-stop
index c0ff29cfaa..5bb2965515 100755
--- a/sca-cpp/trunk/modules/wsgi/gae-stop
+++ b/sca-cpp/trunk/modules/wsgi/gae-stop
@@ -26,4 +26,8 @@ python_prefix=`cat $here/../python/python.prefix`
gae_prefix=`cat $here/gae.prefix`
py="$python_prefix/bin/python $gae_prefix/dev_appserver.py -a 0.0.0.0 -p $port $root"
-kill `ps -ef | grep -v grep | grep "${py}" | awk '{ print $2 }'`
+k=`ps -ef | grep -v grep | grep "${py}" | awk '{ print $2 }'`
+if [ "$k" != "" ]; then
+ kill $k
+fi
+
diff --git a/sca-cpp/trunk/modules/wsgi/http-test b/sca-cpp/trunk/modules/wsgi/http-test
index aef76d47c4..d6c608571e 100755
--- a/sca-cpp/trunk/modules/wsgi/http-test
+++ b/sca-cpp/trunk/modules/wsgi/http-test
@@ -18,6 +18,7 @@
# under the License.
# Setup
+rm -rf tmp
mkdir -p tmp
./wsgi-start target 8090 2>/dev/null
sleep 2
@@ -25,6 +26,8 @@ sleep 2
# Test JSON-RPC
here=`echo "import os; print os.path.realpath('$0')" | python`; here=`dirname $here`
python_prefix=`cat $here/../python/python.prefix`
+export LD_LIBRARY_PATH=$python_prefix/lib:$LD_LIBRARY_PATH
+
$python_prefix/bin/python http-test.py
rc=$?
diff --git a/sca-cpp/trunk/modules/wsgi/util-test b/sca-cpp/trunk/modules/wsgi/util-test
index 184eb1c788..3bdfc018ff 100755
--- a/sca-cpp/trunk/modules/wsgi/util-test
+++ b/sca-cpp/trunk/modules/wsgi/util-test
@@ -20,6 +20,7 @@
# Run Python util test cases
here=`echo "import os; print os.path.realpath('$0')" | python`; here=`dirname $here`
python_prefix=`cat $here/../python/python.prefix`
+export LD_LIBRARY_PATH=$python_prefix/lib:$LD_LIBRARY_PATH
$python_prefix/bin/python stream-test.py
rc=$?
diff --git a/sca-cpp/trunk/modules/wsgi/wiring-test b/sca-cpp/trunk/modules/wsgi/wiring-test
index 35d96a3889..cbecc201e8 100755
--- a/sca-cpp/trunk/modules/wsgi/wiring-test
+++ b/sca-cpp/trunk/modules/wsgi/wiring-test
@@ -26,6 +26,7 @@ if [ "$uri" = "" ]; then
fi
# Setup
+rm -rf tmp
mkdir -p tmp
./wsgi-start target 8090 2>/dev/null
sleep 2
diff --git a/sca-cpp/trunk/modules/wsgi/wsgi-stop b/sca-cpp/trunk/modules/wsgi/wsgi-stop
index e47967e528..3d388ac313 100755
--- a/sca-cpp/trunk/modules/wsgi/wsgi-stop
+++ b/sca-cpp/trunk/modules/wsgi/wsgi-stop
@@ -25,4 +25,8 @@ port=$2
python_prefix=`cat $here/../python/python.prefix`
py="$python_prefix/bin/python composite.py $port"
-kill `ps -ef | grep -v grep | grep "${py}" | awk '{ print $2 }'`
+k=`ps -ef | grep -v grep | grep "${py}" | awk '{ print $2 }'`
+if [ "$k" != "" ]; then
+ kill $k
+fi
+
diff --git a/sca-cpp/trunk/modules/wsgi/wsgi-test b/sca-cpp/trunk/modules/wsgi/wsgi-test
index c17e29047d..f8334b33ad 100755
--- a/sca-cpp/trunk/modules/wsgi/wsgi-test
+++ b/sca-cpp/trunk/modules/wsgi/wsgi-test
@@ -22,6 +22,7 @@ here=`echo "import os; print os.path.realpath('$0')" | python`; here=`dirname $h
curl_prefix=`cat $here/../http/curl.prefix`
# Setup
+rm -rf tmp
mkdir -p tmp
./wsgi-start target 8090 2>/dev/null
sleep 2
diff --git a/sca-cpp/trunk/samples/store-cluster/start b/sca-cpp/trunk/samples/store-cluster/start
index 0aa6e42b03..dcc7e1e7a7 100755
--- a/sca-cpp/trunk/samples/store-cluster/start
+++ b/sca-cpp/trunk/samples/store-cluster/start
@@ -26,6 +26,7 @@ sudo ../../ubuntu/ip-redirect-all 80 8090
#sudo ../../ubuntu/ip-redirect-all 80 8091
# Start scribe logging
+rm -rf tmp
../../components/log/scribed-central-conf tmp/monitor
../../components/log/scribed-client-conf tmp/monitor localhost
../../components/log/scribed-central-start tmp/monitor
diff --git a/sca-cpp/trunk/samples/store-constdb/start b/sca-cpp/trunk/samples/store-constdb/start
index 972d7f9bd2..58b15c0ec3 100755
--- a/sca-cpp/trunk/samples/store-constdb/start
+++ b/sca-cpp/trunk/samples/store-constdb/start
@@ -17,6 +17,7 @@
# specific language governing permissions and limitations
# under the License.
+rm -rf tmp
../../modules/http/httpd-conf tmp localhost 8090 htdocs
../../modules/http/httpd-event-conf tmp
../../modules/server/server-conf tmp
diff --git a/sca-cpp/trunk/samples/store-cpp/start b/sca-cpp/trunk/samples/store-cpp/start
index 444a87c4eb..4ad506f7b5 100755
--- a/sca-cpp/trunk/samples/store-cpp/start
+++ b/sca-cpp/trunk/samples/store-cpp/start
@@ -17,6 +17,7 @@
# specific language governing permissions and limitations
# under the License.
+rm -rf tmp
../../modules/http/httpd-conf tmp localhost 8090 htdocs
../../modules/http/httpd-event-conf tmp
../../modules/server/server-conf tmp
diff --git a/sca-cpp/trunk/samples/store-gae/server-test b/sca-cpp/trunk/samples/store-gae/server-test
index 8dcb444418..2235811556 100755
--- a/sca-cpp/trunk/samples/store-gae/server-test
+++ b/sca-cpp/trunk/samples/store-gae/server-test
@@ -26,6 +26,7 @@ curl_prefix=`cat $here/../../modules/http/curl.prefix`
sleep 2
# Test HTTP GET (with authentication)
+rm -rf tmp
mkdir -p tmp
$curl_prefix/bin/curl -L -c tmp/cookies.txt -b tmp/cookies.txt "http://localhost:8090/_ah/login?email=test@example.com&action=Login&continue=http://localhost:8090/" 2>/dev/null >tmp/index.html
diff tmp/index.html htdocs/index.html
diff --git a/sca-cpp/trunk/samples/store-java/start b/sca-cpp/trunk/samples/store-java/start
index 6952771e3d..99a3f982b7 100755
--- a/sca-cpp/trunk/samples/store-java/start
+++ b/sca-cpp/trunk/samples/store-java/start
@@ -17,6 +17,7 @@
# specific language governing permissions and limitations
# under the License.
+rm -rf tmp
../../modules/http/httpd-conf tmp localhost 8090 htdocs
../../modules/server/server-conf tmp
../../modules/java/java-conf tmp
diff --git a/sca-cpp/trunk/samples/store-python/start b/sca-cpp/trunk/samples/store-python/start
index 2e509a1f2c..d52a41ec13 100755
--- a/sca-cpp/trunk/samples/store-python/start
+++ b/sca-cpp/trunk/samples/store-python/start
@@ -17,6 +17,7 @@
# specific language governing permissions and limitations
# under the License.
+rm -rf tmp
../../modules/http/httpd-conf tmp localhost 8090 htdocs
../../modules/http/httpd-event-conf tmp
../../modules/server/server-conf tmp
diff --git a/sca-cpp/trunk/samples/store-scheme/start b/sca-cpp/trunk/samples/store-scheme/start
index f3575db076..bef6f0372b 100755
--- a/sca-cpp/trunk/samples/store-scheme/start
+++ b/sca-cpp/trunk/samples/store-scheme/start
@@ -17,6 +17,7 @@
# specific language governing permissions and limitations
# under the License.
+rm -rf tmp
../../modules/http/httpd-conf tmp localhost 8090 htdocs
../../modules/http/httpd-event-conf tmp
../../modules/server/server-conf tmp
diff --git a/sca-cpp/trunk/samples/store-sql/start b/sca-cpp/trunk/samples/store-sql/start
index d4cf3c265b..f3d5e67a33 100755
--- a/sca-cpp/trunk/samples/store-sql/start
+++ b/sca-cpp/trunk/samples/store-sql/start
@@ -17,6 +17,7 @@
# specific language governing permissions and limitations
# under the License.
+rm -rf tmp
../../modules/http/httpd-conf tmp localhost 8090 htdocs
../../modules/http/httpd-event-conf tmp
../../modules/server/server-conf tmp
diff --git a/sca-cpp/trunk/samples/store-vhost/start b/sca-cpp/trunk/samples/store-vhost/start
index 9c76b6f748..fef691a058 100755
--- a/sca-cpp/trunk/samples/store-vhost/start
+++ b/sca-cpp/trunk/samples/store-vhost/start
@@ -17,6 +17,7 @@
# specific language governing permissions and limitations
# under the License.
+rm -rf tmp
../../modules/http/httpd-conf tmp example.com 8090 htdocs
../../modules/http/httpd-event-conf tmp
../../modules/http/vhost-conf tmp domains htdocs