summaryrefslogtreecommitdiff
path: root/source4/lib/appweb/ejs/ejsLib.c
diff options
context:
space:
mode:
Diffstat (limited to 'source4/lib/appweb/ejs/ejsLib.c')
-rw-r--r--source4/lib/appweb/ejs/ejsLib.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/source4/lib/appweb/ejs/ejsLib.c b/source4/lib/appweb/ejs/ejsLib.c
index b24b2b013c..f6c004592b 100644
--- a/source4/lib/appweb/ejs/ejsLib.c
+++ b/source4/lib/appweb/ejs/ejsLib.c
@@ -58,6 +58,33 @@ static void *lockData;
#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);