Skip to content

Atomically reserve UUIDs during player admission #1364

Description

@HashimTheArab

Concurrent connections for the same UUID may both be admitted because finaliseConn checks Server.Player before sending to srv.incoming, while the UUID is only inserted into srv.p later by Accept.

A possible interleaving is:

  1. Two finaliseConn goroutines for the same UUID both observe no online player.
  2. Both call createPlayer and enqueue an incoming session, incrementing pwg twice.
  3. Accept processes both and the second assignment overwrites the first entry in srv.p.
  4. Session teardown can save the wrong session, skip one save, or fail to balance one pwg.Done(), depending on close timing.

The duplicate check and reservation need to be one atomic lifecycle transition. A likely fix is a per-UUID joining reservation protected by pmu, released on every failed load/start/enqueue path and transitioned to online when Accept admits the player.

This predates #1363 and should be fixed separately from that PR asynchronous-save changes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions