Subject: Re: FYI: ENVSYS 2 ready
To: Juan RP <juan@xtrarom.org>
From: Bill Stouder-Studenmund <wrstuden@netbsd.org>
List: tech-kern
Date: 06/21/2007 11:57:39
--NzB8fVQJ5HfG6fxh
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Thu, Jun 21, 2007 at 04:02:41PM +0200, Juan RP wrote:
> On Thu, 21 Jun 2007 14:53:20 +0100
> Andrew Doran <ad@netbsd.org> wrote:
>=20
> > 1. sysmon_envsys_find()
> >=20
> > 	mutex_enter(&sme_mtx);
> > 	LIST_FOREACH(sme, &sysmon_envsys_list, sme_list) {
> > 		if (strcmp(sme->sme_name, name) =3D=3D 0)
> > 			break;
> > 	}
> > 	mutex_exit(&sme_mtx);
> > 	return sme;
> >=20
> > How do you know the item is still there after you drop sme_mtx? Can it =
be
> > taken off the list as soon as you unlock?
>=20
> I check in the parts that use sysmon_envsys_find() if returned is NULL,
> isn't it enough? or are you talking about something else?

I think the concern is that sysmon_envsys_find can find something, but=20
since you don't do reference counting, as soon as you return it as found,=
=20
another thread can remove it from the list and presumably destroy it.

The mutex does a great job of protecting the list, but nothing protects=20
the entries after you take a reference.

Take care,

Bill

--NzB8fVQJ5HfG6fxh
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (NetBSD)

iD8DBQFGesojWz+3JHUci9cRAgaAAJ4g/l1cbBKoUpLMF4VqdOCkenZ4qwCfRxek
iTAWqgsYCfR9x1VNwyr6r6k=
=GgEH
-----END PGP SIGNATURE-----

--NzB8fVQJ5HfG6fxh--