Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 28 Jun 2010 10:38:29 +0200
From:      =?utf-8?Q?Dag-Erling_Sm=C3=B8rgrav?= <des@des.no>
To:        "M. Warner Losh" <imp@bsdimp.com>
Cc:        yanefbsd@gmail.com, freebsd-current@FreeBSD.org, pjd@FreeBSD.org, hselasky@c2i.net
Subject:   Re: Patch for rc.d/devd on FreeBSD 9-current
Message-ID:  <86eifr7dru.fsf@ds4.des.no>
In-Reply-To: <86iq537egy.fsf@ds4.des.no> ("Dag-Erling =?utf-8?Q?Sm=C3=B8rg?= =?utf-8?Q?rav=22's?= message of "Mon, 28 Jun 2010 10:23:25 %2B0200")
References:  <AANLkTilnYGNz7V6z6AkeKsqUvOMN8yLvO57GM1gOIsTD@mail.gmail.com> <20100627.160845.256787458594170652.imp@bsdimp.com> <AANLkTikI223vbyBdEqLuA6FjcBBeQcqFujOimP5horsv@mail.gmail.com> <20100627.201716.1108826596298620201.imp@bsdimp.com> <86iq537egy.fsf@ds4.des.no>

next in thread | previous in thread | raw e-mail | index | archive | help
Dag-Erling Sm=C3=B8rgrav <des@des.no> writes:

> "M. Warner Losh" <imp@bsdimp.com> writes:
>> Maybe the real problem is that devd locks the file, then dies.  The
>> file remains locked, so the flopen is failing with EWOULDBLOCK.
>
> The lock is released when the process that holds it terminates.
>
>> But I suspect the real real problem is the implicit assumption that
>> flock will release the lock when a process terminates...  That isn't
>> the case in BSD
> Yes it is.

Additional details:

 - Under POSIX semantics (fcntl(2) locks), the lock is released when
   *any* file descriptor the process holds for that file is closed.
   This is handled in fdfree().

 - Under flock semantics (flock(2) locks), the lock is released when
   *all* file descriptors the process holds for that file is closed.
   This is handled in vn_closefile().

 - In both cases, all locks a process holds are released when the
   process terminates.

Gotta love the following excerpt from VOP_OPEN(9), btw:

  The VOP_OPEN() entry point is called before a file is accessed by a
  process and the VOP_CLOSE() entry point is called after a file is fin=E2=
=80=90
  ished with by the process.

:)

DES
--=20
Dag-Erling Sm=C3=B8rgrav - des@des.no



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