PERFORCE change 181051 for review
Edward Tomasz Napierala
trasz at FreeBSD.org
Fri Jul 16 14:54:14 UTC 2010
http://p4web.freebsd.org/@@181051?ac=10
Change 181051 by trasz at trasz_victim on 2010/07/16 14:53:13
Straighten up the situation with pty accounting. Still not quite right,
but that will require some more thinking.
Affected files ...
.. //depot/projects/soc2009/trasz_limits/sys/kern/kern_resource.c#38 edit
.. //depot/projects/soc2009/trasz_limits/sys/kern/tty_pts.c#18 edit
Differences ...
==== //depot/projects/soc2009/trasz_limits/sys/kern/kern_resource.c#38 (text+ko) ====
@@ -1491,6 +1491,7 @@
return (1);
}
+#ifndef CONTAINERS
/*
* Change the count associated with number of pseudo-terminals
* a given user is using. When 'max' is 0, don't enforce a limit
@@ -1515,3 +1516,4 @@
}
return (1);
}
+#endif
==== //depot/projects/soc2009/trasz_limits/sys/kern/tty_pts.c#18 (text+ko) ====
@@ -576,6 +576,10 @@
tty_lock(tp);
tty_rel_gone(tp);
+#ifdef CONTAINERS
+ rusage_sub(td->td_proc, RUSAGE_PTY, 1);
+#endif
+
/*
* Open of /dev/ptmx or /dev/ptyXX changes the type of file
* from DTYPE_VNODE to DTYPE_PTS. vn_open() increases vnode
@@ -682,7 +686,9 @@
if (psc->pts_unit >= 0)
free_unr(pts_pool, psc->pts_unit);
+#ifndef CONTAINERS
chgptscnt(psc->pts_uidinfo, -1, 0);
+#endif
uifree(psc->pts_uidinfo);
knlist_destroy(&psc->pts_inpoll.si_note);
@@ -714,24 +720,18 @@
pts_alloc(int fflags, struct thread *td, struct file *fp)
{
int unit, ok;
-#ifdef CONTAINERS
- int error;
-#endif
struct tty *tp;
struct pts_softc *psc;
struct proc *p = td->td_proc;
struct uidinfo *uid = td->td_ucred->cr_ruidinfo;
/* Resource limiting. */
+#ifdef CONTAINERS
+ ok = !rusage_add(p, RUSAGE_PTY, 1);
+#else
PROC_LOCK(p);
ok = chgptscnt(uid, 1, lim_cur(p, RLIMIT_NPTS));
-#ifdef CONTAINERS
- error = rusage_add(p, RUSAGE_PTY, 1);
-#endif
PROC_UNLOCK(p);
-#ifdef CONTAINERS
- if (ok != !error)
- printf("pts_alloc: ok = %d, error = %d\n", ok, error);
#endif
if (!ok)
return (EAGAIN);
@@ -739,9 +739,10 @@
/* Try to allocate a new pts unit number. */
unit = alloc_unr(pts_pool);
if (unit < 0) {
- chgptscnt(uid, -1, 0);
#ifdef CONTAINERS
rusage_sub(p, RUSAGE_PTY, 1);
+#else
+ chgptscnt(uid, -1, 0);
#endif
return (EAGAIN);
}
@@ -773,24 +774,18 @@
struct cdev *dev, const char *name)
{
int ok;
-#ifdef CONTAINERS
- int error;
-#endif
struct tty *tp;
struct pts_softc *psc;
struct proc *p = td->td_proc;
struct uidinfo *uid = td->td_ucred->cr_ruidinfo;
/* Resource limiting. */
+#ifdef CONTAINERS
+ ok = !rusage_add(p, RUSAGE_PTY, 1);
+#else
PROC_LOCK(p);
ok = chgptscnt(uid, 1, lim_cur(p, RLIMIT_NPTS));
-#ifdef CONTAINERS
- error = rusage_add(p, RUSAGE_PTY, 1);
-#endif
PROC_UNLOCK(p);
-#ifdef CONTAINERS
- if (ok != !error)
- printf("pts_alloc: ok = %d, error = %d\n", ok, error);
#endif
if (!ok)
return (EAGAIN);
More information about the p4-projects
mailing list