xKiv
Active member
When I choose "exit kolmafia" from the menu, often time mafia doesn't perform logout actions correctly (obvious workaround: manual logout before quitting).
I noticed this because data in my data/xkiv_turns_spent.ser was obviously wrong (several hundreds of turns lower, or all zeroes).
Debugging only leaves me confused, because it looks like *every* thread is trying to quit and logout.
Part of it is probably that LogoutManager.logout only cares about logout running right now, when maybe it should care about whether I am logged in our out. Time it rightly wrong, and every thread does, effectively
And it's not even synchronized, so in a different wrong timing, all thread can finish the if(!isRunning), and *then* call doLogout in parallel. Even if isRunning was volatile (which I am not sure if it needs to be, if the test is in a synchronized block; maybe it should anyway? I don't know what the optimizer is allowed to break inside synchronized blocks ... it's definitely allowed to break things outside them)
So, for example, now I have seen my data/xkiv_turns_spent.ser being overwritten at least 8 times already, and most of them overwrote it with empty data (presumably because another thread already finished logging out and resetting everything).
I noticed this because data in my data/xkiv_turns_spent.ser was obviously wrong (several hundreds of turns lower, or all zeroes).
Debugging only leaves me confused, because it looks like *every* thread is trying to quit and logout.
Part of it is probably that LogoutManager.logout only cares about logout running right now, when maybe it should care about whether I am logged in our out. Time it rightly wrong, and every thread does, effectively
Code:
if (!LogoutManager.isRunning) {
LogoutManager.isRunning = true;
doLogout();
LogoutManager.isRunning = false;
}
So, for example, now I have seen my data/xkiv_turns_spent.ser being overwritten at least 8 times already, and most of them overwrote it with empty data (presumably because another thread already finished logging out and resetting everything).