[quagga-dev 10180] Why are we using flock for BGP dump files?

Christian Franke chris at opensourcerouting.org
Mon Jan 14 16:28:15 GMT 2013


commit b07458a055493dd37cb955ae90f11ae8bc334d3a
Author: Daniel Kozlowski <dkozlowski at sevone.com>
Date:   Wed Sep 26 12:01:24 2012 +0000

    bgpd: flock() dump files (BZ#742)

    flock()ing the BGP dump files helps consumers determine when they're
    safe to read.

    Signed-off-by: David Lamparter <equinox at opensourcerouting.org>

deploys flock(2) to allow consumers to ensure that it is safe to read
the BGP dumps. Unfortunately, flock(2) is not available on Solaris,
therefore, that commit breaks the build on Solaris.

Going through the commit and thinking about how to implement that in a
more portable way, I wondered if it would be possible to deploy the
common pattern to create a temporary file, write the dump and then move
the file in place. (rename is an atomic operation, there won't be any
time where the dump at the final destination is incomplete/broken)

That implementation would have the added benefit that consumers of dump
data cannot stall bgpd for the lock on the dump file, as this
implementation would not require any locking at all.


More information about the Quagga-dev mailing list