summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2011-09-20 04:45:31 +0000
committerjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2011-09-20 04:45:31 +0000
commit09db0fb6eec99a7be47945edd5530a11216bae49 (patch)
treec3567ea0080c34f251382428f11662f2ac920318
parentd96fc31da30e5d093862eeda6c94f625eb44449a (diff)
Fix stack overflow on Mac OS X.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1172977 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--sca-cpp/trunk/configure.ac2
-rw-r--r--sca-cpp/trunk/kernel/sstream.hpp23
-rw-r--r--sca-cpp/trunk/kernel/value.hpp31
-rwxr-xr-xsca-cpp/trunk/modules/http/httpd-conf10
-rwxr-xr-xsca-cpp/trunk/modules/http/httpd-event-conf10
-rwxr-xr-xsca-cpp/trunk/modules/http/httpd-worker-conf10
6 files changed, 68 insertions, 18 deletions
diff --git a/sca-cpp/trunk/configure.ac b/sca-cpp/trunk/configure.ac
index 7ac5c30e4d..116a71df4b 100644
--- a/sca-cpp/trunk/configure.ac
+++ b/sca-cpp/trunk/configure.ac
@@ -39,6 +39,8 @@ if test "${CXX}" = ""; then
else
AM_CONDITIONAL([WANT_LLVM], false)
fi
+else
+ AM_CONDITIONAL([WANT_LLVM], false)
fi
AC_PROG_CXX
AC_PROG_AWK
diff --git a/sca-cpp/trunk/kernel/sstream.hpp b/sca-cpp/trunk/kernel/sstream.hpp
index a638e2dcca..17fd28b48b 100644
--- a/sca-cpp/trunk/kernel/sstream.hpp
+++ b/sca-cpp/trunk/kernel/sstream.hpp
@@ -43,6 +43,18 @@ void* stream_memcpy(void* t, const void* s, const size_t n) {
}
/**
+ * Write a list of strings into a buffer.
+ */
+const bool writeList(const list<string>& l, char* buf) {
+ if (isNil(l))
+ return true;
+ const string c = car(l);
+ char* b = buf - length(c);
+ memcpy(b, c_str(c), length(c));
+ return writeList(cdr(l), b);
+}
+
+/**
* Output stream backed by a char buffer.
*/
class ostringstream : public ostream {
@@ -83,22 +95,13 @@ public:
}
private:
- static const bool strHelper(const list<string> l, char* buf) {
- if (isNil(l))
- return true;
- const string c = car(l);
- char* b = buf - length(c);
- memcpy(b, c_str(c), length(c));
- return strHelper(cdr(l), b);
- }
-
const string str() {
if (isNil(buf))
return string();
string s;
s.len = len;
s.buf = gc_cnew(s.len + 1);
- strHelper(buf, s.buf + len);
+ writeList(buf, s.buf + len);
s.buf[s.len] = '\0';
return s;
}
diff --git a/sca-cpp/trunk/kernel/value.hpp b/sca-cpp/trunk/kernel/value.hpp
index 3e0dd0002f..886897f20f 100644
--- a/sca-cpp/trunk/kernel/value.hpp
+++ b/sca-cpp/trunk/kernel/value.hpp
@@ -448,15 +448,30 @@ const string watchValue(const value& v) {
#endif
/**
+ * Write an escape string to a buffer.
+ */
+const char* escapestr(const char* s, char* buf) {
+ if (*s == '\0') {
+ *buf = '\0';
+ return buf;
+ }
+ if (*s == '\\' || *s == '"') {
+ *buf = '\\';
+ *(buf + 1) = *s;
+ return escapestr(s + 1, buf + 2);
+ }
+ *buf = *s;
+ return escapestr(s + 1, buf + 1);
+}
+
+/**
* Write an escaped string value to a stream.
*/
-ostream& escvwrite(const char* s, ostream& out) {
- if (*s == '\0')
- return out;
- if (*s == '\\' || *s == '"')
- out << '\\';
- out << *s;
- return escvwrite(s + 1, out);
+ostream& escvwrite(const string& str, ostream& out) {
+ char* buf = gc_cnew(length(str) * 2 + 1);
+ escapestr(c_str(str), buf);
+ out << buf;
+ return out;
}
/**
@@ -472,7 +487,7 @@ ostream& operator<<(ostream& out, const value& v) {
return out << v.str()();
case value::String:
out << '\"';
- escvwrite(c_str(v.str()()), out);
+ escvwrite(v.str()(), out);
return out << '\"';
case value::Number:
return out << v.num()();
diff --git a/sca-cpp/trunk/modules/http/httpd-conf b/sca-cpp/trunk/modules/http/httpd-conf
index ada4e0a713..44f3cc8586 100755
--- a/sca-cpp/trunk/modules/http/httpd-conf
+++ b/sca-cpp/trunk/modules/http/httpd-conf
@@ -183,6 +183,16 @@ LoadModule mpm_prefork_module ${modules_prefix}/modules/mod_mpm_prefork.so
EOF
+uname=`uname -s`
+if [ $uname = "Darwin" ]; then
+ cat >>$root/conf/mpm.conf <<EOF
+# Generated by: httpd-conf $*
+# Set thread stack size
+ThreadStackSize 2097152
+
+EOF
+fi
+
# Generate modules list
cat >$root/conf/modules.conf <<EOF
# Generated by: httpd-conf $*
diff --git a/sca-cpp/trunk/modules/http/httpd-event-conf b/sca-cpp/trunk/modules/http/httpd-event-conf
index 7bef30600b..e4c89356db 100755
--- a/sca-cpp/trunk/modules/http/httpd-event-conf
+++ b/sca-cpp/trunk/modules/http/httpd-event-conf
@@ -33,3 +33,13 @@ LoadModule mpm_event_module ${modules_prefix}/modules/mod_mpm_event.so
EOF
+uname=`uname -s`
+if [ $uname = "Darwin" ]; then
+ cat >>$root/conf/mpm.conf <<EOF
+# Generated by: httpd-event-conf $*
+# Set thread stack size
+ThreadStackSize 2097152
+
+EOF
+fi
+
diff --git a/sca-cpp/trunk/modules/http/httpd-worker-conf b/sca-cpp/trunk/modules/http/httpd-worker-conf
index 0d0c866688..74299085d8 100755
--- a/sca-cpp/trunk/modules/http/httpd-worker-conf
+++ b/sca-cpp/trunk/modules/http/httpd-worker-conf
@@ -33,3 +33,13 @@ LoadModule mpm_worker_module ${modules_prefix}/modules/mod_mpm_worker.so
EOF
+uname=`uname -s`
+if [ $uname = "Darwin" ]; then
+ cat >>$root/conf/mpm.conf <<EOF
+# Generated by: httpd-event-conf $*
+# Set thread stack size
+ThreadStackSize 2097152
+
+EOF
+fi
+