r7004: added support for exceptions generated in the esp library. If the OS
authorAndrew Tridgell <tridge@samba.org>
Fri, 27 May 2005 04:37:07 +0000 (04:37 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:17:05 +0000 (13:17 -0500)
supports setjmp/longjmp then the exception will generate a error in
the web page and the Samba log. If the OS doesn't support setjmp then
we will abort.
(This used to be commit 2614ace175a51cfb4b1e0e3ca3db405a19f7ab18)

source4/configure.in
source4/web_server/config.m4 [new file with mode: 0644]
source4/web_server/ejs/miniMpr.c
source4/web_server/http.c

index 68fddc99db69f3f747400538ea2266e4610423f2..370d1281c625d331db3d54a938ef3545600c851d 100644 (file)
@@ -28,6 +28,7 @@ SMB_INCLUDE_M4(scripting/config.m4)
 SMB_INCLUDE_M4(gtk/config.m4)
 SMB_INCLUDE_M4(ntvfs/posix/config.m4)
 SMB_INCLUDE_M4(lib/socket_wrapper/config.m4)
+SMB_INCLUDE_M4(web_server/config.m4)
 
 ALLLIBS_LIBS="$LIBS"
 ALLLIBS_CFLAGS="$CFLAGS"
diff --git a/source4/web_server/config.m4 b/source4/web_server/config.m4
new file mode 100644 (file)
index 0000000..4d8952b
--- /dev/null
@@ -0,0 +1 @@
+AC_CHECK_HEADERS(setjmp.h)
index 46d9579c7e9f7204b51ff9fdd2b5701487bbcca0..8e1689ac9da31d1358e832bedbfdc67c6791730c 100644 (file)
@@ -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 */
index d9d441f765bd49747bd8e5395b1f645da47140c5..6687ab7d16af2461aa238e1c8f5015567c942157 100644 (file)
@@ -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));