[PLUG] fail safe programming question

Mike Cherba mcherba at gmail.com
Wed Jun 18 18:48:45 UTC 2014


Randall,

I've dealt with this in a slightly different context,  (saving things
remotely for failover)  I ended up using a date check and a checksum.I keep
two copies of the backup data including a flag that indicates a clean
shutdown has occurred.  You continuously swap which copy you write to,  so
save to A, then B on the next change, then A again and so forth.  At
bringup, you check both copies and restore from the newest one that has a
clean checksum. ( this way if you crash while writing a backup you simply
use the previous one and lose as little as possible)  If a clean shutdown
was performed, that data should be detected in the stored data and your
restoration should perform the object creation rather than the restoral.
It may be overkill for your case, but I know this works.
              -Mike



On Wed, Jun 18, 2014 at 11:36 AM, Ken Stephens <kens at cad2cam.com> wrote:

> website reader wrote:
> > Has anyone had expeience with C++ and writing fail-safe code?  My naive
> > approach is to copy object values to a folder on the hard drive, so that
> if
> > the program crashes, I can have key values saved.
> >
> > However, I am finding upon bringup, that naively creating the C++ objects
> > all over again is wiping the crucial saved data.
> >
> > I am curious if anyone has done this type of coding?
> >
> > I would like to get in touch.  Thanks
> >
> > Randall
> >
> Randall,
>
> Think about the way you are creating your backup.  Sounds like a logic
> problem that your could solve by setting a flag or ordering your backup
> data.
>
> Ken
> _______________________________________________
> PLUG mailing list
> PLUG at lists.pdxlinux.org
> http://lists.pdxlinux.org/mailman/listinfo/plug
>



-- 
“There are two ways of constructing a software design: One way is to make
it so simple that there are obviously no deficiencies, and the other way is
to make it so complicated that there are no obvious deficiencies. The first
method is far more difficult.” ― C.A.R. Hoare
<http://www.goodreads.com/author/show/266154.C_A_R_Hoare>



More information about the PLUG mailing list