From 09db0fb6eec99a7be47945edd5530a11216bae49 Mon Sep 17 00:00:00 2001 From: jsdelfino Date: Tue, 20 Sep 2011 04:45:31 +0000 Subject: Fix stack overflow on Mac OS X. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1172977 13f79535-47bb-0310-9956-ffa450edef68 --- sca-cpp/trunk/configure.ac | 2 ++ sca-cpp/trunk/kernel/sstream.hpp | 23 ++++++++++++--------- sca-cpp/trunk/kernel/value.hpp | 31 +++++++++++++++++++++------- sca-cpp/trunk/modules/http/httpd-conf | 10 +++++++++ sca-cpp/trunk/modules/http/httpd-event-conf | 10 +++++++++ sca-cpp/trunk/modules/http/httpd-worker-conf | 10 +++++++++ 6 files changed, 68 insertions(+), 18 deletions(-) (limited to 'sca-cpp') 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 @@ -42,6 +42,18 @@ void* stream_memcpy(void* t, const void* s, const size_t n) { return memcpy(t, s, n); } +/** + * Write a list of strings into a buffer. + */ +const bool writeList(const list& 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. */ @@ -83,22 +95,13 @@ public: } private: - static const bool strHelper(const list 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 @@ -447,16 +447,31 @@ 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 <$root/conf/modules.conf <>$root/conf/mpm.conf <>$root/conf/mpm.conf <