Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 25 Nov 2009 10:43:03 +0000 (UTC)
From:      Ed Schouten <ed@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-user@freebsd.org
Subject:   svn commit: r199790 - user/ed/newcons/sys/dev/vt
Message-ID:  <200911251043.nAPAh3g6046462@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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);
 	



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200911251043.nAPAh3g6046462>