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
This commit is contained in:
parent
c3eb9d1e20
commit
f278315081
111 changed files with 483 additions and 251 deletions
3
sca-cpp/trunk/components/cache/Makefile.am
vendored
3
sca-cpp/trunk/components/cache/Makefile.am
vendored
|
|
@ -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
|
||||
|
|
|
|||
2
sca-cpp/trunk/components/cache/datacache.cpp
vendored
2
sca-cpp/trunk/components/cache/datacache.cpp
vendored
|
|
@ -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
|
||||
|
|
|
|||
8
sca-cpp/trunk/components/cache/memcache.cpp
vendored
8
sca-cpp/trunk/components/cache/memcache.cpp
vendored
|
|
@ -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:
|
||||
|
|
|
|||
2
sca-cpp/trunk/components/cache/memcache.hpp
vendored
2
sca-cpp/trunk/components/cache/memcache.hpp
vendored
|
|
@ -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)));
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
# under the License.
|
||||
|
||||
# Setup
|
||||
rm -rf tmp
|
||||
./memcached-start tmp 11211
|
||||
./memcached-start tmp 11212
|
||||
./memcached-start tmp 11213
|
||||
|
|
|
|||
12
sca-cpp/trunk/components/cache/partitioner.cpp
vendored
12
sca-cpp/trunk/components/cache/partitioner.cpp
vendored
|
|
@ -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));
|
||||
|
|
|
|||
1
sca-cpp/trunk/components/cache/server-test
vendored
1
sca-cpp/trunk/components/cache/server-test
vendored
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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>&)>()));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
# under the License.
|
||||
|
||||
# Setup
|
||||
rm -rf tmp
|
||||
mkdir -p tmp
|
||||
./tinycdb -c -m tmp/test.cdb </dev/null
|
||||
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
# under the License.
|
||||
|
||||
# Setup
|
||||
rm -rf tmp
|
||||
mkdir -p tmp
|
||||
mkdir -p tmp/schemedb
|
||||
mkdir -p tmp/xmldb
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
# under the License.
|
||||
|
||||
# Setup
|
||||
rm -rf tmp
|
||||
mkdir -p tmp
|
||||
./tinycdb -c -m tmp/test.cdb </dev/null
|
||||
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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"/>
|
||||
|
|
|
|||
|
|
@ -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)));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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> const lambda<failable<V, F>(const V)> failure() {
|
||||
return mkfailure<V, F>;
|
||||
template<typename V, typename F, typename C> const lambda<failable<V, F, C>(const V)> failure() {
|
||||
return mkfailure<V, F, C>;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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));
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
# under the License.
|
||||
|
||||
# Setup
|
||||
rm -rf tmp
|
||||
./httpd-conf tmp localhost 8090 htdocs
|
||||
./httpd-event-conf tmp
|
||||
./httpd-start tmp
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
44
sca-cpp/trunk/modules/http/mod-security-audit-conf
Executable file
44
sca-cpp/trunk/modules/http/mod-security-audit-conf
Executable file
|
|
@ -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
|
||||
|
||||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
# under the License.
|
||||
|
||||
# Setup
|
||||
rm -rf tmp
|
||||
../../components/cache/memcached-start tmp 11212
|
||||
../../components/cache/memcached-start tmp 11213
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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,14 +1170,17 @@ 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)
|
||||
return DECLINED;
|
||||
if(strcmp(r->handler, "mod_tuscany_eval"))
|
||||
if (r->handler != NULL && r->handler[0] != '\0')
|
||||
return DECLINED;
|
||||
|
||||
// Nothing to do for an external redirect
|
||||
if (r->status == HTTP_MOVED_TEMPORARILY)
|
||||
return OK;
|
||||
// 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;
|
||||
|
||||
// Create a scoped memory pool and a scope for the current request
|
||||
gc_scoped_pool pool(r->pool);
|
||||
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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=$?
|
||||
|
||||
|
|
|
|||
|
|
@ -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=$?
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ if [ "$uri" = "" ]; then
|
|||
fi
|
||||
|
||||
# Setup
|
||||
rm -rf tmp
|
||||
mkdir -p tmp
|
||||
./wsgi-start target 8090 2>/dev/null
|
||||
sleep 2
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue