edit: Detect concurrent updates during interactive nation edit
Unlike other edits, editing a country modifies the object in-place. It has to, because editing may send bulletins, which updates nat_tgms, and writing back a copy would clobber these updates, triggering a seqno mismatch oops. However, the in-place editing neglects to detect concurrent updates. Fix that. Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
parent
9eec1a57e7
commit
0faceac070
1 changed files with 9 additions and 0 deletions
|
@ -93,6 +93,7 @@ edit(void)
|
||||||
np = natargp(player->argp[2], "Country? ");
|
np = natargp(player->argp[2], "Country? ");
|
||||||
if (!np)
|
if (!np)
|
||||||
return RET_SYN;
|
return RET_SYN;
|
||||||
|
item.nat = *np;
|
||||||
break;
|
break;
|
||||||
case 'p':
|
case 'p':
|
||||||
if ((num = onearg(player->argp[2], "Plane number? ")) < 0)
|
if ((num = onearg(player->argp[2], "Plane number? ")) < 0)
|
||||||
|
@ -158,11 +159,19 @@ edit(void)
|
||||||
|
|
||||||
switch (ewhat) {
|
switch (ewhat) {
|
||||||
case 'c':
|
case 'c':
|
||||||
|
if (!check_obj_ok(&item.gen))
|
||||||
|
return RET_FAIL;
|
||||||
|
/*
|
||||||
|
* edit_nat() may update the edited country by sending it
|
||||||
|
* bulletins. Writing back item.nat would trigger a seqno
|
||||||
|
* mismatch oops. Workaround: edit in-place.
|
||||||
|
*/
|
||||||
ret = edit_nat(np, key, ptr);
|
ret = edit_nat(np, key, ptr);
|
||||||
if (ret != RET_OK)
|
if (ret != RET_OK)
|
||||||
return ret;
|
return ret;
|
||||||
if (!putnat(np))
|
if (!putnat(np))
|
||||||
return RET_FAIL;
|
return RET_FAIL;
|
||||||
|
item.nat = *np;
|
||||||
break;
|
break;
|
||||||
case 'l':
|
case 'l':
|
||||||
if (!check_sect_ok(&item.sect))
|
if (!check_sect_ok(&item.sect))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue