smab / playhouse-web

GNU Affero General Public License v3.0
0 stars 2 forks source link

Prevent two users from becoming the same player #88

Closed arvidfm closed 10 years ago

arvidfm commented 10 years ago

The problem is potentially that one coroutine starts running before another one has finished; if so, take a look at locks with the toro library.

clid commented 10 years ago

Although I cannot reproduce this, I think I know what the problem is from examining the code.

When the game ends it tries to get two new players from the queue through the game API. During this reset there is a small amount of time where players contain one or two None values. If at the same time some other player joins the queue, the callback to on_queue will also try to add another player if there is free player slots. Since there is one or more free slots if this happens at the right moment another player will be added. One of these three players will then be overwritten by another.

Haven't been able to get a fix working yet though.

Zetro commented 10 years ago

ffe8fa68892644f364a4803cb3833d2fec116276 might fix this. Two clients can't become the same player but the queue might still be able tell both clients that they are both player 1. The false player 1 would still keep its place in the queue and regain spectator status when the queue is refreshed.