summaryrefslogtreecommitdiff
path: root/source4/lib
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-08-07 15:45:59 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:31:29 -0500
commita663d2110678b6c059737eecf7929cd5e5d46160 (patch)
tree3c97cdc3f2321d51e187812709124bd384ce90cd /source4/lib
parent9811a3981bcc466726567aea4188a44c9fb07752 (diff)
downloadsamba-a663d2110678b6c059737eecf7929cd5e5d46160.tar.gz
samba-a663d2110678b6c059737eecf7929cd5e5d46160.tar.bz2
samba-a663d2110678b6c059737eecf7929cd5e5d46160.zip
r9183: more workarounds for the global variables in ejs. I will discuss getting rid of these
with the mbedthis people. (This used to be commit a5b9e74a5c23e724ae4ee222e6f128133b175494)
Diffstat (limited to 'source4/lib')
-rw-r--r--source4/lib/appweb/ejs/ejs.h3
-rw-r--r--source4/lib/appweb/ejs/ejsLib.c27
2 files changed, 30 insertions, 0 deletions
diff --git a/source4/lib/appweb/ejs/ejs.h b/source4/lib/appweb/ejs/ejs.h
index 5efdb47192..c7b0c54d8e 100644
--- a/source4/lib/appweb/ejs/ejs.h
+++ b/source4/lib/appweb/ejs/ejs.h
@@ -71,6 +71,9 @@ extern void ejsClose(void);
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
*/
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);