svn commit: r199790 - user/ed/newcons/sys/dev/vt
Ed Schouten
ed at FreeBSD.org
Wed Nov 25 10:43:03 UTC 2009
Author: ed
Date: Wed Nov 25 10:43:03 2009
New Revision: 199790
URL: http://svn.freebsd.org/changeset/base/199790
Log:
Use atomic increments for vt_unit.
It's not likely that multiple allocations of vt devices will ever occur
at the same time, but if it would happen, the results are very scary.
Modified:
user/ed/newcons/sys/dev/vt/vt_core.c
Modified: user/ed/newcons/sys/dev/vt/vt_core.c
==============================================================================
--- user/ed/newcons/sys/dev/vt/vt_core.c Wed Nov 25 05:42:54 2009 (r199789)
+++ user/ed/newcons/sys/dev/vt/vt_core.c Wed Nov 25 10:43:03 2009 (r199790)
@@ -599,7 +599,7 @@ vtterm_cnprobe(struct terminal *tm, stru
return;
}
- vd->vd_unit = vt_unit++;
+ vd->vd_unit = atomic_fetchadd_int(&vt_unit, 1);
sprintf(cp->cn_name, "ttyv%r", VT_UNIT(vw));
if (!(vd->vd_flags & VDF_TEXTMODE))
@@ -1032,7 +1032,7 @@ vt_allocate(struct vt_driver *drv, void
vd = malloc(sizeof *vd, M_VT, M_WAITOK|M_ZERO);
vd->vd_driver = drv;
vd->vd_softc = softc;
- vd->vd_unit = vt_unit++;
+ vd->vd_unit = atomic_fetchadd_int(&vt_unit, 1);
vd->vd_flags = VDF_INVALID;
vd->vd_driver->vd_init(vd);
More information about the svn-src-user
mailing list