mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
[quickjs] reference count in heartbeat.c
This commit is contained in:
parent
6629f34466
commit
d5787d46b4
@ -81,16 +81,23 @@ 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
|
||||
ses = interpreter->vs->doc_view->session;
|
||||
|
||||
hb = (struct heartbeat *)mem_alloc(sizeof(struct heartbeat));
|
||||
|
||||
if (!hb) return NULL;
|
||||
|
||||
hb->ttl = get_opt_int("ecmascript.max_exec_time", ses);
|
||||
hb->interpreter = interpreter;
|
||||
hb->ref_count = 1;
|
||||
add_to_list(heartbeats, hb);
|
||||
|
||||
#ifndef CONFIG_OS_DOS
|
||||
@ -115,6 +122,10 @@ done_heartbeat(struct heartbeat *hb)
|
||||
if (!hb) return; /* add_heartbeat returned NULL */
|
||||
assert(hb->interpreter);
|
||||
|
||||
if (--hb->ref_count > 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
#ifndef CONFIG_OS_DOS
|
||||
/* Stop the heartbeat timer if this heartbeat is the only one. */
|
||||
if (list_is_singleton(*hb)) {
|
||||
|
@ -15,6 +15,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