mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
[spidermonkey] ref_count in heartbeat
This commit is contained in:
parent
d5787d46b4
commit
17b288c935
@ -89,6 +89,11 @@ add_heartbeat(struct ecmascript_interpreter *interpreter)
|
||||
|
||||
assert(interpreter);
|
||||
|
||||
if (interpreter->heartbeat) {
|
||||
interpreter->heartbeat->ref_count++;
|
||||
return interpreter->heartbeat;
|
||||
}
|
||||
|
||||
if (!interpreter->vs || !interpreter->vs->doc_view)
|
||||
ses = NULL;
|
||||
else
|
||||
@ -99,6 +104,7 @@ add_heartbeat(struct ecmascript_interpreter *interpreter)
|
||||
|
||||
hb->ttl = get_opt_int("ecmascript.max_exec_time", ses);
|
||||
hb->interpreter = interpreter;
|
||||
hb->ref_count = 1;
|
||||
add_to_list(heartbeats, hb);
|
||||
|
||||
/* Update the heartbeat timer. */
|
||||
@ -122,6 +128,10 @@ done_heartbeat(struct heartbeat *hb)
|
||||
if (!hb) return; /* add_heartbeat returned NULL */
|
||||
assert(hb->interpreter);
|
||||
|
||||
if (--hb->ref_count > 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* Stop the heartbeat timer if this heartbeat is the only one. */
|
||||
if (list_is_singleton(*hb)) {
|
||||
heartbeat_timer.it_value.tv_sec = 0;
|
||||
|
@ -306,6 +306,7 @@ spidermonkey_put_interpreter(struct ecmascript_interpreter *interpreter)
|
||||
interpreter->backend_data = NULL;
|
||||
interpreter->ac = nullptr;
|
||||
interpreter->ar = nullptr;
|
||||
done_heartbeat(interpreter->heartbeat);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -13,6 +13,7 @@ struct heartbeat {
|
||||
* second. When it reaches 0, script execution is
|
||||
* terminated. */
|
||||
|
||||
int ref_count;
|
||||
struct ecmascript_interpreter *interpreter;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user