summaryrefslogtreecommitdiff
path: root/source4/web_server
diff options
context:
space:
mode:
Diffstat (limited to 'source4/web_server')
-rw-r--r--source4/web_server/config.m41
-rw-r--r--source4/web_server/ejs/miniMpr.c8
-rw-r--r--source4/web_server/http.c28
3 files changed, 33 insertions, 4 deletions
diff --git a/source4/web_server/config.m4 b/source4/web_server/config.m4
new file mode 100644
index 0000000000..4d8952b775
--- /dev/null
+++ b/source4/web_server/config.m4
@@ -0,0 +1 @@
+AC_CHECK_HEADERS(setjmp.h)
diff --git a/source4/web_server/ejs/miniMpr.c b/source4/web_server/ejs/miniMpr.c
index 46d9579c7e..8e1689ac9d 100644
--- a/source4/web_server/ejs/miniMpr.c
+++ b/source4/web_server/ejs/miniMpr.c
@@ -160,10 +160,10 @@ void mprLog(int level, const char *fmt, ...)
void mprBreakpoint(const char *file, int line, const char *cond)
{
- /*
- * Optionally break into the debugger here
- */
- mprLog(0, "ASSERT at %s:%d, %s\n", file, line, cond);
+ char *buf;
+ mprAllocSprintf(&buf, MPR_MAX_STRING, "esp exception - ASSERT at %s:%d, %s\n",
+ file, line, cond);
+ http_exception(buf);
}
#endif /* !BLD_GOAHEAD_WEBSERVER */
diff --git a/source4/web_server/http.c b/source4/web_server/http.c
index d9d441f765..6687ab7d16 100644
--- a/source4/web_server/http.c
+++ b/source4/web_server/http.c
@@ -455,6 +455,28 @@ static void http_setup_arrays(struct esp_state *esp)
SETVAR(ESP_REQUEST_OBJ, "SCRIPT_FILENAME", web->input.url);
}
+#if HAVE_SETJMP_H
+/* the esp scripting lirary generates exceptions when
+ it hits a major error. We need to catch these and
+ report a internal server error via http
+*/
+#include <setjmp.h>
+static jmp_buf http_exception_buf;
+static const char *exception_reason;
+
+void http_exception(const char *reason)
+{
+ exception_reason = reason;
+ DEBUG(0,("%s", reason));
+ longjmp(http_exception_buf, -1);
+}
+#else
+void http_exception(const char *reason)
+{
+ DEBUG(0,("%s", reason));
+ smb_panic(reason);
+}
+#endif
/*
process a esp request
@@ -474,6 +496,12 @@ static void esp_request(struct esp_state *esp)
return;
}
+#if HAVE_SETJMP_H
+ if (setjmp(http_exception_buf) != 0) {
+ http_error(web, 500, exception_reason);
+ return;
+ }
+#endif
res = espProcessRequest(esp->req, url, buf, &emsg);
if (res != 0 && emsg) {
http_writeBlock(web, emsg, strlen(emsg));