diff --git a/src/sbbs3/websrvr.c b/src/sbbs3/websrvr.c index 238460b42859ea7df12fd9518b52826f29f96fbb..13c2f82df13b72fd6dbe692a51550fc6534dd9c6 100644 --- a/src/sbbs3/websrvr.c +++ b/src/sbbs3/websrvr.c @@ -3291,6 +3291,7 @@ static BOOL js_setup(http_session_t* session) { JSObject* argv; +#ifndef ONE_JS_RUNTIME if(session->js_runtime == NULL) { lprintf(LOG_INFO,"%04d JavaScript: Creating runtime: %lu bytes" ,session->socket,startup->js.max_bytes); @@ -3300,6 +3301,7 @@ static BOOL js_setup(http_session_t* session) return(FALSE); } } +#endif if(session->js_cx==NULL) { /* Context not yet created, create it now */ if(((session->js_cx=js_initcx(session))==NULL)) { @@ -3804,11 +3806,13 @@ void http_session_thread(void* arg) session.js_cx=NULL; } +#ifndef ONE_JS_RUNTIME if(session.js_runtime!=NULL) { lprintf(LOG_INFO,"%04d JavaScript: Destroying runtime",socket); JS_DestroyRuntime(session.js_runtime); session.js_runtime=NULL; } +#endif FREE_AND_NULL(session.subscan); @@ -4015,6 +4019,9 @@ void DLLCALL web_server(void* arg) http_session_t * session; struct timeval tv; startup=(web_startup_t*)arg; +#ifdef ONE_JS_RUNTIME + JSRuntime* js_runtime; +#endif web_ver(); /* get CVS revision */ @@ -4223,6 +4230,21 @@ void DLLCALL web_server(void* arg) _beginthread(http_logging_thread, 0, startup->logfile_base); } +#ifdef ONE_JS_RUNTIME + if(js_runtime == NULL) { + lprintf(LOG_INFO,"%04d JavaScript: Creating runtime: %lu bytes" + ,server_socket,startup->js.max_bytes); + + if((js_runtime=JS_NewRuntime(startup->js.max_bytes))==NULL) { + lprintf(LOG_ERR,"%04d !ERROR creating JavaScript runtime",server_socket); + /* Sleep 15 seconds then try again */ + /* ToDo: Something better should be used here. */ + SLEEP(15000); + continue; + } + } +#endif + /* Setup recycle/shutdown semaphore file lists */ shutdown_semfiles=semfile_list_init(scfg.ctrl_dir,"shutdown","web"); recycle_semfiles=semfile_list_init(scfg.ctrl_dir,"recycle","web"); @@ -4356,6 +4378,9 @@ void DLLCALL web_server(void* arg) session->js_branch.limit=startup->js.branch_limit; session->js_branch.gc_interval=startup->js.gc_interval; session->js_branch.yield_interval=startup->js.yield_interval; +#ifdef ONE_JS_RUNTIME + session->js_runtime=js_runtime; +#endif _beginthread(http_session_thread, 0, session); served++; @@ -4395,6 +4420,14 @@ void DLLCALL web_server(void* arg) } } +#ifdef ONE_JS_RUNTIME + if(session.js_runtime!=NULL) { + lprintf(LOG_INFO,"%04d JavaScript: Destroying runtime",server_socket); + JS_DestroyRuntime(js_runtime); + js_runtime=NULL; + } +#endif + cleanup(0); if(!terminate_server) {