PERFORCE change 166919 for review
Edward Tomasz Napierala
trasz at FreeBSD.org
Sun Aug 2 11:10:36 UTC 2009
http://perforce.freebsd.org/chv.cgi?CH=166919
Change 166919 by trasz at trasz_anger on 2009/08/02 11:09:55
Fix rule inheritance.
Affected files ...
.. //depot/projects/soc2009/trasz_limits/sys/kern/kern_hrl.c#35 edit
.. //depot/projects/soc2009/trasz_limits/sys/kern/kern_resource.c#15 edit
.. //depot/projects/soc2009/trasz_limits/sys/sys/hrl.h#26 edit
Differences ...
==== //depot/projects/soc2009/trasz_limits/sys/kern/kern_hrl.c#35 (text+ko) ====
@@ -738,6 +738,22 @@
return (rule);
}
+struct hrl_rule *
+hrl_rule_duplicate(const struct hrl_rule *rule)
+{
+ struct hrl_rule *copy;
+
+ copy = hrl_rule_alloc();
+ copy->hr_subject = rule->hr_subject;
+ copy->hr_subject_id = rule->hr_subject_id;
+ copy->hr_per = rule->hr_per;
+ copy->hr_resource = rule->hr_resource;
+ copy->hr_action = rule->hr_action;
+ copy->hr_amount = rule->hr_amount;
+
+ return (copy);
+}
+
void
hrl_rule_acquire(struct hrl_rule *rule)
{
@@ -1384,6 +1400,7 @@
{
int i;
struct hrl_limit *limit;
+ struct hrl_rule *rule;
PROC_LOCK(parent);
PROC_LOCK(child);
@@ -1399,8 +1416,17 @@
/*
* XXX: What about locking the parent?
*/
- LIST_FOREACH(limit, &parent->p_limits, hl_next)
- hrl_limit_add(&child->p_limits, limit->hl_rule);
+ LIST_FOREACH(limit, &parent->p_limits, hl_next) {
+ if (limit->hl_rule->hr_subject == HRL_SUBJECT_PROCESS) {
+ rule = hrl_rule_duplicate(limit->hl_rule);
+ KASSERT(rule->hr_subject_id == parent->p_pid,
+ ("rule->hr_subject_id == parent->p_pid"));
+ rule->hr_subject_id = child->p_pid;
+ hrl_limit_add(&child->p_limits, rule);
+ hrl_rule_release(rule);
+ } else
+ hrl_limit_add(&child->p_limits, limit->hl_rule);
+ }
}
/*
==== //depot/projects/soc2009/trasz_limits/sys/kern/kern_resource.c#15 (text+ko) ====
@@ -716,13 +716,8 @@
rule->hr_amount = lim->rlim_cur;
hrl_rule_add(rule);
if (rule->hr_action != HRL_ACTION_DENY) {
- rule2 = hrl_rule_alloc();
- rule2->hr_subject = rule->hr_subject;
- rule2->hr_subject_id = rule->hr_subject_id;
- rule2->hr_per = rule->hr_per;
- rule2->hr_resource = rule->hr_resource;
+ rule2 = hrl_rule_duplicate(rule);
rule2->hr_action = HRL_ACTION_DENY;
- rule2->hr_amount = rule->hr_amount;
hrl_rule_add(rule2);
hrl_rule_release(rule2);
}
==== //depot/projects/soc2009/trasz_limits/sys/sys/hrl.h#26 (text+ko) ====
@@ -139,6 +139,7 @@
void hrl_proc_exiting(struct proc *p);
struct hrl_rule *hrl_rule_alloc(void);
+struct hrl_rule *hrl_rule_duplicate(const struct hrl_rule *rule);
void hrl_rule_acquire(struct hrl_rule *rule);
void hrl_rule_release(struct hrl_rule *rule);
int hrl_rule_add(struct hrl_rule *rule);
More information about the p4-projects
mailing list