mkstemp (equivalent?) and berkely dbopen

Ask a Question related to UNIX Programming, Design and Development.

  1. #1

    Default mkstemp (equivalent?) and berkely dbopen

    Hi,

    I would like to create a database using dbopen(3) with a random unused
    filename, and to copy that over the 'live' database once it's been
    completely flushed to disk, in an effort to always have the live
    database containing valid data.

    What is the safest way of achieving this? Obviously using mktemp(3) to
    generate a filename, and then opening that file contains a race
    condition and should be avoided.

    Any pointers in the right direction would be greatfully received. I'm
    programming in C on FreeBSD, but portable options would be preferred.

    Cheers,

    Ollie

    --
    Ollie Cook Systems Administrator, Claranet UK
    Ollie Cook Guest

  2. Similar Questions and Discussions

    1. PHP equivalent to MOD
      Hi, I need to see if a number is divisible by 2. I don't see the math function "mod" in my PHP Functions reference manual. Is there another way...
    2. equivalent to php_info()
      Hi again, is there an equivalent system plot like php_info() in asp? thanks, tom
    3. php equivalent of CGI.pm
      I'm translating several old cgi scripts (that use CGI.pm) to php. CGI.pm has a series of conventient function calls for generating HTML code on the...
    4. Is mkstemp() large file aware/compatible?
      Dragan Cvetkovic <me@privacy.net> writes: Yes on Solaris. (As documented in the manual page) Casper -- Expressed in this posting are...
    5. ACT! Equivalent for Mac?
      Does anyone know if there is a Macintosh program whose features are roughly equivalent? This PC software runs on VPC, but is fairly sluggish....
  3. #2

    Default Re: mkstemp (equivalent?) and berkely dbopen

    Ollie Cook <news@mutare.noc.clara.net> wrote
    in <slrnbgjgr4.310o.news@mutare.noc.clara.net>:
    # Hi,
    #
    # I would like to create a database using dbopen(3) with a random unused
    # filename, and to copy that over the 'live' database once it's been
    # completely flushed to disk, in an effort to always have the live
    # database containing valid data.
    #
    # What is the safest way of achieving this? Obviously using mktemp(3) to
    # generate a filename, and then opening that file contains a race
    # condition and should be avoided.

    What exactly is the race for your app?

    # Any pointers in the right direction would be greatfully received. I'm
    # programming in C on FreeBSD, but portable options would be preferred.

    Does mkstemp(3) solve your problem?

    Regards,

    Jens
    --
    Jens Schweikhardt [url]http://www.schweikhardt.net/[/url]
    SIGSIG -- signature too long (core dumped)
    Jens Schweikhardt Guest

  4. #3

    Default Re: mkstemp (equivalent?) and berkely dbopen

    On 8 Jul 2003 07:27:33 GMT, Jens Schweikhardt wrote:
    > What exactly is the race for your app?
    Overwriting a db file causes processes which want to read it to not be
    able to as the data obviously becomes inconsistent.

    The data has to always be available to client applications so the
    solution is to write to a temporary file and move that over the top
    atomically.
    > # Any pointers in the right direction would be greatfully received. I'm
    > # programming in C on FreeBSD, but portable options would be preferred.
    >
    > Does mkstemp(3) solve your problem?
    mkstemp is not suitable since it returns a file descriptor, not a DB
    pointer. dbopen(3) explains the interface to dbopen.

    Thanks for your reply.

    Ollie

    --
    Ollie Cook Systems Administrator, Claranet UK
    Ollie Cook Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139