Synchronet now requires the libarchive development package (e.g. libarchive-dev on Debian-based Linux distros, libarchive.org for more info) to build successfully.

Commit de422465 authored by rswindell's avatar rswindell

Implemented JS thread stack size limit support.

parent 99aa97e0
......@@ -860,7 +860,7 @@ js_ErrorReporter(JSContext *cx, const char *message, JSErrorReport *report)
}
}
bool sbbs_t::js_init()
bool sbbs_t::js_init(ulong* stack_frame)
{
char node[128];
......@@ -919,6 +919,20 @@ bool sbbs_t::js_init()
if(js_CreateConsoleObject(js_cx, js_glob)==NULL)
break;
if(startup->js.thread_stack) {
ulong stack_limit;
#if JS_STACK_GROWTH_DIRECTION > 0
stack_limit=((ulong)stack_frame)+startup->js.thread_stack;
#else
stack_limit=((ulong)stack_frame)-startup->js.thread_stack;
#endif
JS_SetThreadStackLimit(js_cx, stack_limit);
lprintf(LOG_DEBUG,"%s JavaScript: Thread stack limit: %lu bytes"
,node, startup->js.thread_stack);
}
success=true;
} while(0);
......@@ -1533,6 +1547,7 @@ void output_thread(void* arg)
void event_thread(void* arg)
{
ulong stack_frame;
char str[MAX_PATH+1];
char bat_list[MAX_PATH+1];
char semfile[MAX_PATH+1];
......@@ -1563,7 +1578,7 @@ void event_thread(void* arg)
#ifdef JAVASCRIPT
if(!(startup->options&BBS_OPT_NO_JAVASCRIPT)) {
if(!sbbs->js_init()) /* This must be done in the context of the node thread */
if(!sbbs->js_init(&stack_frame)) /* This must be done in the context of the event thread */
lprintf(LOG_ERR,"!JavaScript Initialization FAILURE");
}
#endif
......@@ -3268,6 +3283,7 @@ void sbbs_t::logoffstats()
void node_thread(void* arg)
{
ulong stack_frame;
char str[128];
char uname[LEN_ALIAS+1];
int file;
......@@ -3291,7 +3307,7 @@ void node_thread(void* arg)
#ifdef JAVASCRIPT
if(!(startup->options&BBS_OPT_NO_JAVASCRIPT)) {
if(!sbbs->js_init()) /* This must be done in the context of the node thread */
if(!sbbs->js_init(&stack_frame)) /* This must be done in the context of the node thread */
lprintf(LOG_ERR,"!Node %d !JavaScript Initialization FAILURE",sbbs->cfg.node_num);
}
#endif
......
......@@ -207,7 +207,7 @@ public:
JSObject* js_glob;
js_branch_t js_branch;
long js_execfile(const char *fname);
bool js_init(void);
bool js_init(ulong* stack_frame);
void js_create_user_objects(void);
#endif
......
......@@ -767,6 +767,7 @@ js_client_remove(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *r
static JSContext*
js_initcx(JSRuntime* js_runtime, SOCKET sock, service_client_t* service_client, JSObject** glob)
{
ulong stack_frame;
JSContext* js_cx;
JSObject* js_glob;
JSObject* server;
......@@ -876,6 +877,15 @@ js_initcx(JSRuntime* js_runtime, SOCKET sock, service_client_t* service_client,
if(glob!=NULL)
*glob=js_glob;
if(service_client->service->js.thread_stack) {
#if JS_STACK_GROWTH_DIRECTION > 0
stack_frame=((ulong)&stack_frame)+service_client->service->js.thread_stack;
#else
stack_frame=((ulong)&stack_frame)-service_client->service->js.thread_stack;
#endif
JS_SetThreadStackLimit(js_cx, stack_frame);
}
success=TRUE;
} while(0);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment