Opened 10 years ago

Closed 10 years ago

Last modified 8 years ago

#2346 closed defect (fixed)

Failing to write state file means you try every second

Reported by: arma Owned by:
Priority: Medium Milestone: Tor: 0.2.2.x-final
Component: Core Tor/Tor Version:
Severity: Keywords:
Cc: Actual Points:
Parent ID: Points:
Reviewer: Sponsor:


In or_state_save() we check

  if (global_state->next_write > now)
    return 0;

but in the case where the save fails, we don't reset next_write. So we end up back in this function on the next second, failing to write again. That can't be good.

I say we set next_write to now + 3600 in the normal case, or TIME_MAX if AvoidDiskWrites is true. That way if it was a temporary problem it will for sure get retried pretty soon, but not that soon, and sooner if some other event happens that marks our state dirty again.

Bug is on 0.2.1.x and earlier too, but I think we can get away just fine with fixing it in maint-0.2.2 and later.

Bug pointed out by 'special' while hunting down #2077.

Child Tickets

Change History (4)

comment:1 Changed 10 years ago by nickm

Status: newneeds_review

See branch bug2346 in my public repository against maint-0.2.2.

comment:2 Changed 10 years ago by arma

Looks good to me.

The only slight catch is that the changelog message is misleading. We're setting it up to try another write in an hour, unless something changes before then. See or_state_mark_dirty() in or.h

(My guess is most of the time something will change before then.)

As for specific fixes, you could change "wait an hour" to "wait up to an hour" in the changes file, and change "Try again in after" (sic) to "Try again in at most" in the comments.

comment:3 Changed 10 years ago by nickm

Resolution: fixed
Status: needs_reviewclosed

cleaned up & merged. thanks!

comment:4 Changed 8 years ago by nickm

Component: Tor ClientTor
Note: See TracTickets for help on using tickets.