summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbjj <bjj>1998-12-06 07:13:21 (GMT)
committerbjj <bjj>1998-12-06 07:13:21 (GMT)
commit430ab839df065fea3c990f34ec7dc7847868d915 (patch)
tree51946499732caf5f3bf0592cf6539771d7b4671e
parent5a3c4850b1ab672848d3cc6dced13fe99c561066 (diff)
downloadmoo-cvs-UNSAFE.OPTS.zip
moo-cvs-UNSAFE.OPTS.tar.gz
moo-cvs-UNSAFE.OPTS.tar.bz2
moo-cvs-UNSAFE.OPTS.tar.xz
Rationalize enqueue_forked_task interface and fix program_ref leak inUNSAFE.OPTS
the case where fork fails with E_QUOTA. Make .queued_task_limit=0 really enforce a limit of zero tasks (for old behavior set it to 1, that's the effect it used to have).
-rw-r--r--execute.c29
-rw-r--r--tasks.c49
-rw-r--r--tasks.h11
3 files changed, 50 insertions, 39 deletions
diff --git a/execute.c b/execute.c
index 01de27d..09e4f13 100644
--- a/execute.c
+++ b/execute.c
@@ -1515,23 +1515,12 @@ do { \
free_var(time);
RAISE_ERROR(E_INVARG);
} else {
- Var *copied_rt_env;
- Var task_id;
-
- copied_rt_env = copy_rt_env(RUN_ACTIV.rt_env,
- RUN_ACTIV.prog->num_var_names);
- task_id = enqueue_forked_task(program_ref(RUN_ACTIV.prog),
- RUN_ACTIV, copied_rt_env,
- f_index, time.v.num);
- if (task_id.type == TYPE_ERR) {
- free_rt_env(copied_rt_env, RUN_ACTIV.prog->num_var_names);
- RAISE_ERROR(task_id.v.err);
- } else if (op == OP_FORK_WITH_ID) {
- free_var(RUN_ACTIV.rt_env[id]);
- RUN_ACTIV.rt_env[id] = task_id;
- free_var(copied_rt_env[id]);
- copied_rt_env[id] = task_id;
- }
+ enum error e;
+
+ e = enqueue_forked_task2(RUN_ACTIV, f_index, time.v.num,
+ op == OP_FORK_WITH_ID ? id : -1);
+ if (e != E_NONE)
+ RAISE_ERROR(e);
}
}
break;
@@ -2874,6 +2863,12 @@ read_activ(activation * a, int which_vector)
char rcsid_execute[] = "$Id$";
/* $Log$
+/* Revision 1.6.2.4 1998/12/06 07:13:21 bjj
+/* Rationalize enqueue_forked_task interface and fix program_ref leak in
+/* the case where fork fails with E_QUOTA. Make .queued_task_limit=0 really
+/* enforce a limit of zero tasks (for old behavior set it to 1, that's the
+/* effect it used to have).
+/*
/* Revision 1.6.2.3 1997/09/09 07:01:17 bjj
/* Change bytecode generation so that x=f(x) calls f() without holding a ref
/* to the value of x in the variable slot. See the options.h comment for
diff --git a/tasks.c b/tasks.c
index 933986b..7997c4b 100644
--- a/tasks.c
+++ b/tasks.c
@@ -816,31 +816,36 @@ check_user_task_limit(Objid user)
if (limit < 0)
limit = server_int_option("queued_task_limit", -1);
- if (tq && limit >= 0 && tq->num_bg_tasks >= limit)
+ if (limit < 0)
+ return 1;
+ else if ((tq ? tq->num_bg_tasks : 0) >= limit)
return 0;
else
return 1;
}
-Var
-enqueue_forked_task(Program * program, activation a, Var * rt_env,
- int f_index, unsigned after_seconds)
+enum error
+enqueue_forked_task2(activation a, int f_index, unsigned after_seconds, int vid)
{
- int id = new_task_id();
- Var v;
+ int id;
+ Var *rt_env;
- if (check_user_task_limit(a.progr)) {
- a.verb = str_ref(a.verb);
- a.verbname = str_ref(a.verbname);
- enqueue_ft(program, a, rt_env, f_index, time(0) + after_seconds, id);
- v.type = TYPE_INT;
- v.v.num = id;
- } else {
- v.type = TYPE_ERR;
- v.v.err = E_QUOTA;
+ if (!check_user_task_limit(a.progr))
+ return E_QUOTA;
+
+ id = new_task_id();
+ a.verb = str_ref(a.verb);
+ a.verbname = str_ref(a.verbname);
+ a.prog = program_ref(a.prog);
+ if (vid >= 0) {
+ free_var(a.rt_env[vid]);
+ a.rt_env[vid].type = TYPE_INT;
+ a.rt_env[vid].v.num = id;
}
+ rt_env = copy_rt_env(a.rt_env, a.prog->num_var_names);
+ enqueue_ft(a.prog, a, rt_env, f_index, time(0) + after_seconds, id);
- return v;
+ return E_NONE;
}
enum error
@@ -1942,10 +1947,16 @@ register_tasks(void)
char rcsid_tasks[] = "$Id$";
/* $Log$
-/* Revision 1.3.2.2 1998/11/23 01:10:55 bjj
-/* Fix a server crash when force_input() fills the input queue of an
-/* unconnected object. No observable behavior has changed.
+/* Revision 1.3.2.3 1998/12/06 07:13:22 bjj
+/* Rationalize enqueue_forked_task interface and fix program_ref leak in
+/* the case where fork fails with E_QUOTA. Make .queued_task_limit=0 really
+/* enforce a limit of zero tasks (for old behavior set it to 1, that's the
+/* effect it used to have).
/*
+ * Revision 1.3.2.2 1998/11/23 01:10:55 bjj
+ * Fix a server crash when force_input() fills the input queue of an
+ * unconnected object. No observable behavior has changed.
+ *
* Revision 1.3.2.1 1997/05/21 03:41:34 bjj
* Fix a memleak when a forked task was killed before it ever started.
*
diff --git a/tasks.h b/tasks.h
index 5c4c88f..7e53177 100644
--- a/tasks.h
+++ b/tasks.h
@@ -36,9 +36,8 @@ extern int tasks_set_connection_option(task_queue, const char *,
Var);
extern void new_input_task(task_queue, const char *);
-extern Var enqueue_forked_task(Program * program, activation a,
- Var * rt_env, int f_index,
- unsigned after_seconds);
+extern enum error enqueue_forked_task2(activation a, int f_index,
+ unsigned after_seconds, int vid);
extern enum error enqueue_suspended_task(vm the_vm, void *data);
/* data == &(int after_seconds) */
extern enum error make_reading_task(vm the_vm, void *data);
@@ -110,6 +109,12 @@ extern db_verb_handle find_verb_for_programming(Objid player,
#endif /* !Tasks_H */
/* $Log$
+/* Revision 1.2.2.1 1998/12/06 07:13:23 bjj
+/* Rationalize enqueue_forked_task interface and fix program_ref leak in
+/* the case where fork fails with E_QUOTA. Make .queued_task_limit=0 really
+/* enforce a limit of zero tasks (for old behavior set it to 1, that's the
+/* effect it used to have).
+/*
/* Revision 1.2 1997/03/03 04:19:32 nop
/* GNU Indent normalization
/*