svn commit: samba r9504 - in branches/SAMBA_4_0/source: lib/appweb/ejs scripting/ejs web_server

tridge at samba.org tridge at samba.org
Tue Aug 23 05:21:05 GMT 2005


Author: tridge
Date: 2005-08-23 05:21:04 +0000 (Tue, 23 Aug 2005)
New Revision: 9504

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=9504

Log:

use some low level ejs hackery to give much better exception error messages in both
the web server and smbscript. We can now give backtraces for all internal asserts, not 
just high level errors

Modified:
   branches/SAMBA_4_0/source/lib/appweb/ejs/config.h
   branches/SAMBA_4_0/source/scripting/ejs/smbscript.c
   branches/SAMBA_4_0/source/web_server/http.c


Changeset:
Modified: branches/SAMBA_4_0/source/lib/appweb/ejs/config.h
===================================================================
--- branches/SAMBA_4_0/source/lib/appweb/ejs/config.h	2005-08-23 03:22:25 UTC (rev 9503)
+++ branches/SAMBA_4_0/source/lib/appweb/ejs/config.h	2005-08-23 05:21:04 UTC (rev 9504)
@@ -8,7 +8,7 @@
 #define BLD_APPWEB_CONFIG "normal.conf"
 #define BLD_APPWEB 0
 #define BLD_COMPANY "Mbedthis"
-#define BLD_DEBUG 1
+#define BLD_DEBUG 0
 #define BLD_DIRS "bootstrap include obj bin mpr ejs esp http doc appWeb appWebSamples images"
 #define BLD_HTTP_PORT 7777
 #define BLD_LIB_VERSION "1.0.0"

Modified: branches/SAMBA_4_0/source/scripting/ejs/smbscript.c
===================================================================
--- branches/SAMBA_4_0/source/scripting/ejs/smbscript.c	2005-08-23 03:22:25 UTC (rev 9503)
+++ branches/SAMBA_4_0/source/scripting/ejs/smbscript.c	2005-08-23 05:21:04 UTC (rev 9504)
@@ -24,17 +24,21 @@
 #include "includes.h"
 #include "dynconfig.h"
 #include "lib/appweb/ejs/ejs.h"
+#include "lib/appweb/ejs/ejsInternal.h"
 #include "scripting/ejs/smbcalls.h"
 
+static EjsId eid;
+
 void ejs_exception(const char *reason)
 {
-	fprintf(stderr, "smbscript exception: %s", reason);
+	Ejs *ep = ejsPtr(eid);
+	ejsSetErrorMsg(eid, "%s", reason);
+	fprintf(stderr, "%s", ep->error);
 	exit(127);
 }
 
  int main(int argc, const char **argv)
 {
-	EjsId eid;
 	EjsHandle handle = 0;
 	MprVar result;
 	char *emsg, *script;

Modified: branches/SAMBA_4_0/source/web_server/http.c
===================================================================
--- branches/SAMBA_4_0/source/web_server/http.c	2005-08-23 03:22:25 UTC (rev 9503)
+++ branches/SAMBA_4_0/source/web_server/http.c	2005-08-23 05:21:04 UTC (rev 9504)
@@ -29,6 +29,7 @@
 #include "system/iconv.h"
 #include "system/time.h"
 #include "lib/appweb/esp/esp.h"
+#include "lib/appweb/ejs/ejsInternal.h"
 #include "dlinklist.h"
 #include "lib/tls/tls.h"
 
@@ -43,17 +44,6 @@
 	struct session_data *session;
 };
 
-/* destroy a esp session */
-static int esp_destructor(void *ptr)
-{
-	struct esp_state *esp = talloc_get_type(ptr, struct esp_state);
-
-	if (esp->req) {
-		espDestroyRequest(esp->req);
-	}
-	return 0;
-}
-
 /*
   output the http headers
 */
@@ -338,7 +328,7 @@
 void http_error(struct websrv_context *web, int code, const char *info)
 {
 	char *s;
-	s = talloc_asprintf(web,"<HTML><HEAD><TITLE>Error %u</TITLE></HEAD><BODY><H1>Error %u</H1>%s<p></BODY></HTML>\r\n\r\n", 
+	s = talloc_asprintf(web,"<HTML><HEAD><TITLE>Error %u</TITLE></HEAD><BODY><H1>Error %u</H1><pre>%s</pre><p></BODY></HTML>\r\n\r\n", 
 			    code, code, info);
 	if (s == NULL) {
 		stream_terminate_connection(web->conn, "http_error: out of memory");
@@ -468,8 +458,14 @@
 
 void ejs_exception(const char *reason)
 {
-	exception_reason = reason;
-	DEBUG(0,("%s", reason));
+	Ejs *ep = ejsPtr(0);
+	if (ep) {
+		ejsSetErrorMsg(0, "%s", reason);
+		exception_reason = ep->error;
+	} else {
+		exception_reason = reason;
+	}
+	DEBUG(0,("%s", exception_reason));
 	longjmp(ejs_exception_buf, -1);
 }
 #else
@@ -797,8 +793,6 @@
 			   edata->application_data, MPR_DEEP_COPY);
 	}
 
-	talloc_set_destructor(esp, esp_destructor);
-
 	smb_setup_ejs_functions();
 
 	if (web->input.url == NULL) {



More information about the samba-cvs mailing list