svn commit: samba r9183 - in branches/SAMBA_4_0/source:
lib/appweb/ejs web_server
tridge at samba.org
tridge at samba.org
Sun Aug 7 15:46:00 GMT 2005
Author: tridge
Date: 2005-08-07 15:45:59 +0000 (Sun, 07 Aug 2005)
New Revision: 9183
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=9183
Log:
more workarounds for the global variables in ejs. I will discuss getting rid of these
with the mbedthis people.
Modified:
branches/SAMBA_4_0/source/lib/appweb/ejs/ejs.h
branches/SAMBA_4_0/source/lib/appweb/ejs/ejsLib.c
branches/SAMBA_4_0/source/web_server/http.c
Changeset:
Modified: branches/SAMBA_4_0/source/lib/appweb/ejs/ejs.h
===================================================================
--- branches/SAMBA_4_0/source/lib/appweb/ejs/ejs.h 2005-08-07 15:33:50 UTC (rev 9182)
+++ branches/SAMBA_4_0/source/lib/appweb/ejs/ejs.h 2005-08-07 15:45:59 UTC (rev 9183)
@@ -71,6 +71,9 @@
extern EjsId ejsOpenEngine(EjsHandle primaryHandle, EjsHandle altHandle);
extern void ejsCloseEngine(EjsId eid);
+void *ejs_save_state(void);
+void ejs_restore_state(void *ptr);
+
/*
* Evaluation functions
*/
Modified: branches/SAMBA_4_0/source/lib/appweb/ejs/ejsLib.c
===================================================================
--- branches/SAMBA_4_0/source/lib/appweb/ejs/ejsLib.c 2005-08-07 15:33:50 UTC (rev 9182)
+++ branches/SAMBA_4_0/source/lib/appweb/ejs/ejsLib.c 2005-08-07 15:45:59 UTC (rev 9183)
@@ -58,6 +58,33 @@
#define ejsUnlock()
#endif
+
+/*
+ save/restore global ejs state - used to cope with simultaneous ejs requests
+ this is a workaround for the use of global variables in ejs
+*/
+struct ejs_state_ctx {
+ struct MprVar master;
+ struct MprArray *ejsList;
+};
+
+void *ejs_save_state(void)
+{
+ struct ejs_state_ctx *ctx = talloc(talloc_autofree_context(), struct ejs_state_ctx);
+ ctx->master = master;
+ ctx->ejsList = ejsList;
+ return ctx;
+}
+
+void ejs_restore_state(void *ptr)
+{
+ struct ejs_state_ctx *ctx = talloc_get_type(ptr, struct ejs_state_ctx);
+ master = ctx->master;
+ ejsList = ctx->ejsList;
+ talloc_free(ctx);
+}
+
+
/****************************** Forward Declarations **************************/
static char *getNextVarToken(char **next, char *tokBuf, int tokBufLen);
Modified: branches/SAMBA_4_0/source/web_server/http.c
===================================================================
--- branches/SAMBA_4_0/source/web_server/http.c 2005-08-07 15:33:50 UTC (rev 9182)
+++ branches/SAMBA_4_0/source/web_server/http.c 2005-08-07 15:45:59 UTC (rev 9183)
@@ -752,6 +752,7 @@
struct esp_data *edata = talloc_get_type(web->task->private, struct esp_data);
char *p;
void *save_mpr_ctx = mprMemCtx();
+ void *ejs_save = ejs_save_state();
int i;
const char *file_type = NULL;
BOOL esp_enable = False;
@@ -802,6 +803,7 @@
if (web->input.url == NULL) {
http_error(web, 400, "You must specify a GET or POST request");
mprSetCtx(save_mpr_ctx);
+ ejs_restore_state(ejs_save);
return;
}
@@ -811,6 +813,7 @@
if (!NT_STATUS_IS_OK(status)) {
http_error(web, 400, "Malformed POST data");
mprSetCtx(save_mpr_ctx);
+ ejs_restore_state(ejs_save);
return;
}
}
@@ -819,6 +822,7 @@
if (!NT_STATUS_IS_OK(status)) {
http_error(web, 400, "Malformed GET data");
mprSetCtx(save_mpr_ctx);
+ ejs_restore_state(ejs_save);
return;
}
}
@@ -899,6 +903,7 @@
talloc_free(esp);
mprSetCtx(save_mpr_ctx);
+ ejs_restore_state(ejs_save);
return;
internal_error:
@@ -906,6 +911,7 @@
talloc_free(esp);
http_error(web, 500, "Internal server error");
mprSetCtx(save_mpr_ctx);
+ ejs_restore_state(ejs_save);
}
More information about the samba-cvs
mailing list