Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    DNS/DHCP and updating lease file

    Scheduled Pinned Locked Moved 2.3-RC Snapshot Feedback and Issues - ARCHIVED
    1 Posts 1 Posters 776 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • D Offline
      doejohn
      last edited by

      Hello,

      I just stumbled about Bug #4931, and am curious whether its solution addresses the whole story.

      The bug description states that:

      dhcpd changes the dhcpd.leases file as dhcp leases change, but once per hour it rewrites the file from scratch. When it rewrites it, the existing file is first moved out of the way and a new file created.

      Usually, doing it this way calls for race conditions. The consumer (dhcpleases) might try to access a partially-filled file (or even a non-existing one!)

      Wouldn't a better ordering be:

      1. create a new (temporary) file
      2. populate the new file with content
      3. close the file to ensure all buffers are flushed
      4. rename the new file, replacing the original file.

      This way, the replacement would be atomic. The consumer of the file would never have a chance to consume a partially populated file.

      1 Reply Last reply Reply Quote 0
      • First post
        Last post
      Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.