]> git.pond.sub.org Git - empserver/commit
Add sequence numbers to game state
authorMarkus Armbruster <armbru@pond.sub.org>
Sat, 17 May 2008 20:44:00 +0000 (22:44 +0200)
committerMarkus Armbruster <armbru@pond.sub.org>
Sat, 17 May 2008 20:50:30 +0000 (22:50 +0200)
commit536ef0b0a2c058a12ea5b2065f45291e12f0f879
tree749ec4dfd4aef75a2f3aaa87e3f04352e05247ab
parent087c0aae3658065556529c25af0c2bb8cc99887e
Add sequence numbers to game state

This oopses on output dependency violations, e.g. two threads doing a
read-modify-write without synchronization, or the one thread nesting
several read-modify-writes.  Such bugs are difficult to spot, and tend
to be abusable.  I figure we have quite a few of them.

New struct emptypedstr member seqno.  Make sure all members of unit
empobj_storage share it.  Initialize it in files: main() and
file_sct_init().  Set it in ef_blank() and new ef_set_uid() by calling
new get_seqno().  Use ef_set_uid() when copying objects: swaps(),
doland(), doship(), doplane(), dounit(), delete_old_news().  Step it
in ef_write() by calling new new_seqno().

Factor do_read() out of fillcache() to make it available for
get_seqno().
20 files changed:
include/commodity.h
include/empobj.h
include/file.h
include/game.h
include/land.h
include/loan.h
include/lost.h
include/nat.h
include/news.h
include/nuke.h
include/plane.h
include/sect.h
include/ship.h
include/trade.h
include/treaty.h
src/lib/commands/edit.c
src/lib/commands/swap.c
src/lib/common/file.c
src/lib/subs/nreport.c
src/util/files.c