Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Main
Synchronet
Commits
9299ff0c
Commit
9299ff0c
authored
Jul 22, 2003
by
rswindell
Browse files
Actually destroys/recreates JS context for looping static JS services
(forces immediate destruction of local objects).
parent
2087b2f2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
21 deletions
+17
-21
src/sbbs3/services.c
src/sbbs3/services.c
+17
-21
No files found.
src/sbbs3/services.c
View file @
9299ff0c
...
...
@@ -972,7 +972,6 @@ static void js_static_service_thread(void* arg)
SOCKET
socket
;
/* JavaScript-specific */
JSObject
*
js_glob
;
JSObject
*
js_scope
;
JSScript
*
js_script
;
JSRuntime
*
js_runtime
;
JSContext
*
js_cx
;
...
...
@@ -996,9 +995,8 @@ static void js_static_service_thread(void* arg)
service_client
.
branch
.
gc_freq
=
JAVASCRIPT_GC_FREQUENCY
;
service_client
.
branch
.
yield_freq
=
JAVASCRIPT_YIELD_FREQUENCY
;
if
((
js_runtime
=
JS_NewRuntime
(
startup
->
js_max_bytes
))
==
NULL
||
(
js_cx
=
js_initcx
(
js_runtime
,
service
->
socket
,
&
service_client
,
&
js_glob
))
==
NULL
)
{
lprintf
(
"%04d !%s ERROR initializing JavaScript context"
if
((
js_runtime
=
JS_NewRuntime
(
startup
->
js_max_bytes
))
==
NULL
)
{
lprintf
(
"%04d !%s ERROR initializing JavaScript runtime"
,
service
->
socket
,
service
->
protocol
);
close_socket
(
service
->
socket
);
service
->
socket
=
INVALID_SOCKET
;
...
...
@@ -1010,35 +1008,33 @@ static void js_static_service_thread(void* arg)
if
(
scfg
.
mods_dir
[
0
]
==
0
||
!
fexist
(
spath
))
sprintf
(
spath
,
"%s%s"
,
scfg
.
exec_dir
,
service
->
cmd
);
js_init_cmdline
(
js_cx
,
js_glob
,
spath
);
val
=
BOOLEAN_TO_JSVAL
(
JS_FALSE
);
JS_SetProperty
(
js_cx
,
js_glob
,
"logged_in"
,
&
val
);
JS_SetBranchCallback
(
js_cx
,
js_BranchCallback
);
do
{
JS_ClearPendingException
(
js_cx
);
if
((
js_scope
=
JS_NewObject
(
js_cx
,
NULL
,
NULL
,
js_glob
))
==
NULL
)
{
lprintf
(
"%04d !JavaScript FAILED to create scope object"
,
service
->
socket
);
if
((
js_cx
=
js_initcx
(
js_runtime
,
service
->
socket
,
&
service_client
,
&
js_glob
))
==
NULL
)
{
lprintf
(
"%04d !%s ERROR initializing JavaScript context"
,
service
->
socket
,
service
->
protocol
);
break
;
}
if
((
js_script
=
JS_CompileFile
(
js_cx
,
js_scope
,
spath
))
==
NULL
)
{
js_init_cmdline
(
js_cx
,
js_glob
,
spath
);
val
=
BOOLEAN_TO_JSVAL
(
JS_FALSE
);
JS_SetProperty
(
js_cx
,
js_glob
,
"logged_in"
,
&
val
);
JS_SetBranchCallback
(
js_cx
,
js_BranchCallback
);
if
((
js_script
=
JS_CompileFile
(
js_cx
,
js_glob
,
spath
))
==
NULL
)
{
lprintf
(
"%04d !JavaScript FAILED to compile script (%s)"
,
service
->
socket
,
spath
);
break
;
}
JS_ExecuteScript
(
js_cx
,
js_
scope
,
js_script
,
&
rval
);
JS_ExecuteScript
(
js_cx
,
js_
glob
,
js_script
,
&
rval
);
JS_DestroyScript
(
js_cx
,
js_script
);
JS_ClearScope
(
js_cx
,
js_scope
);
JS_
GC
(
js_cx
);
JS_
DestroyContext
(
js_cx
);
/* Free Context */
}
while
(
!
service
->
terminated
&&
service
->
options
&
SERVICE_OPT_STATIC_LOOP
);
JS_DestroyContext
(
js_cx
);
/* Free Context */
if
(
js_cx
!=
NULL
)
JS_DestroyContext
(
js_cx
);
/* Free Context */
JS_DestroyRuntime
(
js_runtime
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment