Angband.oook.cz
Angband.oook.cz
AboutVariantsLadderForumCompetitionComicScreenshotsFunniesLinks

Go Back   Angband Forums > Angband > Vanilla

Reply
 
Thread Tools Display Modes
Old April 23, 2010, 10:05   #21
takkaria
Veteran
 
takkaria's Avatar
 
Join Date: Apr 2007
Posts: 1,950
Donated: $40
takkaria is on a distinguished road
Quote:
Originally Posted by PowerDiver View Post
Would changing the procedure to (1) write to a temporary savefile and then (2) rename the tmp to replace the original be good enough? I'd think that ought to be fairly robust.
We already write to savefile.new, then move savefile to savefile.old, then move savefile.new to savefile, then delete savefile.(old|new), checking for errors and issues at each step. Windows is just an arse.
__________________
takkaria whispers something about options. -more-
takkaria is offline   Reply With Quote
Old April 23, 2010, 11:15   #22
LostTemplar
Knight
 
Join Date: Aug 2009
Posts: 670
LostTemplar is on a distinguished road
Without use of fsync() this did not help, atleast with ext4 filesystem, allmost any system crash or power down results in broken savefile. I never had any problems under windows.
LostTemplar is offline   Reply With Quote
Old April 23, 2010, 14:39   #23
d_m
Angband Devteam member
 
d_m's Avatar
 
Join Date: Aug 2008
Location: Philadelphia, PA, USA
Age: 42
Posts: 1,516
d_m is on a distinguished road
Quote:
Originally Posted by LostTemplar View Post
Without use of fsync() this did not help, atleast with ext4 filesystem, allmost any system crash or power down results in broken savefile. I never had any problems under windows.
Check out the "Disadvantages" section of this article on ext4:

http://en.wikipedia.org/wiki/Ext4
__________________
linux->xterm->screen->pmacs
d_m is offline   Reply With Quote
Old April 23, 2010, 16:08   #24
Tiburon Silverflame
Swordsman
 
Join Date: Feb 2010
Posts: 405
Tiburon Silverflame is on a distinguished road
The 2-tier approach I'm suggesting would use 2 completely separate *files*. So if I'm using Tiburon as my character, the level-switched save might be Tiburon.level, while the user-invoked or game-exit save might be Tiburon. That way, no matter what happens, you have 1 file that is no more than a single level old, which is safe.
Tiburon Silverflame is offline   Reply With Quote
Old April 23, 2010, 16:42   #25
Pete Mack
Prophet
 
Join Date: Apr 2007
Location: Seattle, WA
Posts: 6,726
Donated: $40
Pete Mack will become famous soon enough
Quote:
Originally Posted by LostTemplar View Post
Without use of fsync() this did not help, atleast with ext4 filesystem, allmost any system crash or power down results in broken savefile. I never had any problems under windows.
This is correct.
Before renaming the file, force a disk sync--standard practice for editor apps and databases. For a panic save file, it's a good idea to reopen it and verifying that it is valid before renaming.
Pete Mack is offline   Reply With Quote
Old April 23, 2010, 18:12   #26
Nemesis
Adept
 
Join Date: Jul 2009
Posts: 137
Nemesis is on a distinguished road
Quote:
Originally Posted by ramela View Post
What you consider questionable might differ from what others see as questionable and you shouldn't snap at other people for voicing their opinions.

Everyone gets to have their own opinion on what is a legimate win and what is not, even if you were hurt by your computer crash.
Try not to snap yourself when in this situation!
Nemesis is offline   Reply With Quote
Old April 23, 2010, 18:16   #27
Derakon
Prophet
 
Derakon's Avatar
 
Join Date: Dec 2009
Posts: 9,022
Derakon is on a distinguished road
Quote:
Originally Posted by Pete Mack View Post
This is correct.
Before renaming the file, force a disk sync--standard practice for editor apps and databases. For a panic save file, it's a good idea to reopen it and verifying that it is valid before renaming.
This sounds basically like what I suggested, right? Validate save, if it's good, replace old save with it, otherwise, use old save.
Derakon is offline   Reply With Quote
Old April 23, 2010, 18:54   #28
Tiburon Silverflame
Swordsman
 
Join Date: Feb 2010
Posts: 405
Tiburon Silverflame is on a distinguished road
I still see some issues...

First, some of this tends to be OS-specific, or at least the calls to implement the disk sync, are likely to be OS-specific.

Second, it still feels like the process that Pete/Derakon are mentioning, is potentially subject to crashes at the wrong time. It might be *safer*...but it's not safe.
Tiburon Silverflame is offline   Reply With Quote
Old April 23, 2010, 20:21   #29
ramela
Apprentice
 
Join Date: Jan 2008
Location: Finland
Age: 44
Posts: 55
ramela is on a distinguished road
Quote:
Originally Posted by Nemesis View Post
Try not to snap yourself when in this situation!
Well, this has happened to me twice. Both times I did snap, but in private.

Then I just started over.
ramela is offline   Reply With Quote
Old April 23, 2010, 20:28   #30
Derakon
Prophet
 
Derakon's Avatar
 
Join Date: Dec 2009
Posts: 9,022
Derakon is on a distinguished road
Tiburon: to my knowledge, moving a file is an atomic operation on all filesystems -- that is to say, it either succeeds, or it doesn't happen at all. So if you have two files "goodsave" and "panicsave" and you try to move panicsave over goodsave (having previously validated panicsave is a valid savefile), then there's nothing, that will corrupt panicsave that wouldn't also screw over your entire hard drive (i.e. catastrophic hardware failure).

Writing a file isn't an atomic operation, which is why panicsaves are not reliable in the first place.
Derakon is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
"Great" drops replaced by "good" drops in vaults: bug or feature? PowerWyrm Vanilla 14 February 27, 2010 15:54
Feature request: make "summon unique" do nothing when there are no uniques bron Vanilla 11 December 22, 2009 16:25
Feature request: change "Purification and Healing" prayer book. bron Vanilla 1 December 18, 2009 23:19
"repeat" Command just little bit "smarter" ClaytonAguiar Vanilla 8 June 17, 2009 15:01
Roguelike idea from "Lost Magic" DS game - Mr. @ teaches typing! ekolis Idle chatter 10 October 19, 2007 03:25


All times are GMT +1. The time now is 05:32.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2023, vBulletin Solutions Inc.