Date: Thu, 28 Apr 2011 00:52:28 +0300 From: Kostik Belousov <kostikbel@gmail.com> To: Bartosz Fabianowski <freebsd@chillt.de> Cc: freebsd-hackers@freebsd.org, Hans Petter Selasky <hselasky@c2i.net> Subject: Re: Is there some implicit locking of device methods? Message-ID: <20110427215228.GY48734@deviant.kiev.zoral.com.ua> In-Reply-To: <4DB8873C.5020608@chillt.de> References: <4DB695DB.1080505@chillt.de> <201104271019.31844.jhb@freebsd.org> <4DB818A3.1020104@chillt.de> <201104271334.07170.jhb@freebsd.org> <4DB8873C.5020608@chillt.de>
next in thread | previous in thread | raw e-mail | index | archive | help
--AMNVzrRY61gDOMe/ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Apr 27, 2011 at 11:14:36PM +0200, Bartosz Fabianowski wrote: > >If you have some sort of state that needs to get created on first > >open and then removed on last close [...] I would still depend on the > >cdevpriv destructor and use a reference count between open() and the > >destructor to know when to cleanup shared state. >=20 > Yes, this is what I am doing. I am maintaining a list of all file=20 > descriptors open on the device. Once the length of that list reaches=20 > zero, I do global clean-up in the cdevpriv destructor. You are mixing things, and do repeat the work (probably buggy) that is already done by devfs. You should understand the relationship between basic concepts first. File descriptor !=3D opened file !=3D cdev node. Driver indeed may get notifications on all open(2) syscalls performed on the node, but is has absolutely no way to enumerate filedescriptors referencing that files. cdevpriv is per file, not per node. cdevpriv is cleaned automatically when last filedescriptor referencing the file is gone, not when the last file referencing the node is closed. The later is approximated by d_close(). --AMNVzrRY61gDOMe/ Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (FreeBSD) iEYEARECAAYFAk24kBwACgkQC3+MBN1Mb4iVHACguKtBZiISUM/bFpYerbzTCliT zzwAoMmnQszeDh27mxADSSmYx53Yfk2E =Zzpo -----END PGP SIGNATURE----- --AMNVzrRY61gDOMe/--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20110427215228.GY48734>