Re: sysctl_proc calls handler twice

From: Bruce Evans (bde_at_zeta.org.au)
Date: 08/17/05

  • Next message: Max Laier: "Re: duplicate read/write locks in net/pfil.c and netinet/ip_fw2.c"
    Date: Wed, 17 Aug 2005 11:01:49 +1000 (EST)
    To: Pawel Jakub Dawidek <pjd@freebsd.org>
    
    

    On Tue, 16 Aug 2005, Pawel Jakub Dawidek wrote:

    > On Tue, Aug 16, 2005 at 11:17:21PM +1000, Bruce Evans wrote:
    > +> No, just don't call it twice like sysctl(8) if you know the size in advance
    > +> or from a previous call (and know that it won't change or handle the error
    > +> from it changing...).
    >
    > Thread's author, as I understand/guess it, represents kernel side.
    > He doesn't want his handler to be called twice and tools like sysctl(8)
    > are not able to know size of every sysctl, so he just has to be ready
    > that his handler will be called twice.

    [It turned out to be a race problem]

    Well, any handler may be called any number of times in any order,
    including possibly concurrently. All sysctls are still Giant-locked
    so concurent calls can't actually happen, but making a separate call
    to determine the size gives races anyway if the size can change.
    Applications should loop if the size that they got turns out to be
    insufficent. sysctl(8) doesn't do this -- it doubles the size but
    doesn't retry. Writing requires even more care.

    Bruce
    _______________________________________________
    freebsd-arch@freebsd.org mailing list
    http://lists.freebsd.org/mailman/listinfo/freebsd-arch
    To unsubscribe, send any mail to "freebsd-arch-unsubscribe@freebsd.org"


  • Next message: Max Laier: "Re: duplicate read/write locks in net/pfil.c and netinet/ip_fw2.c"