Skip to content

Conversation

mfncooper
Copy link

Per-connection data for an AGWPE connection was being cleaned up only when the client itself went away, rather than when each connection was terminated. This led to reuse of stale state machine instances, which in turn led to incorrect connection attempts and statistics.

The following changes have been made to address this:

  • Per-connection cleanup code from dl_client_cleanup has been moved to a new function, dl_connection_cleanup. dl_client_cleanup now calls this new function from within its existing loop, walking though all connections for the client being cleaned up.

  • A new function, dl_connection_terminated, encapsulates the removal of a single state machine instance from the list and the cleanup of that connection instance, calling dl_connection_cleanup for the latter.

  • Everywhere that server_link_terminated is being called, a new call to dl_connection_terminated has been added nearby, to ensure the connection is cleaned up. The call is "nearby" because invocations of server_link_terminated differ in their surrounding calls to other timer and state functions, and the order of those calls, so simply wrapping server_link_terminated is not appropriate.

    Many, but not all, existing calls to server_link_terminated have nearby calls to set the state machine state to disconnected. While this is also done in dl_connection_cleanup, the existing calls have been left to minimize disruption. (There is no real cost associated with changing state from disconnected to disconnected.)

These changes have been tested in as many situations as possible, with Direwolf started using '-d ac' to watch debug output for both AGWPE and connection / state machine related activity.

Fixes #534, Fixes #535

Per-connection data for an AGWPE connection was being cleaned up only
when the client itself went away, rather than when each connection
was terminated. This led to reuse of stale state machine instances,
which in turn led to incorrect connection attempts and statistics.

The following changes have been made to address this:

* Per-connection cleanup code from dl_client_cleanup has been moved
  to a new function, dl_connection_cleanup. dl_client_cleanup now
  calls this new function from within its existing loop, walking
  though all connections for the client being cleaned up.

* A new function, dl_connection_terminated, encapsulates the removal
  of a single state machine instance from the list and the cleanup of
  that connection instance, calling dl_connection_cleanup for the
  latter.

* Everywhere that server_link_terminated is being called, a new call
  to dl_connection_terminated has been added nearby, to ensure the
  connection is cleaned up. The call is "nearby" because invocations
  of server_link_terminated differ in their surrounding calls to
  other timer and state functions, and the order of those calls, so
  simply wrapping server_link_terminated is not appropriate.

  Many, but not all, existing calls to server_link_terminated have
  nearby calls to set the state machine state to disconnected. While
  this is also done in dl_connection_cleanup, the existing calls have
  been left to minimize disruption. (There is no real cost associated
  with changing state from disconnected to disconnected.)

These changes have been tested in as many situations as possible, with
Direwolf started using '-d ac' to watch debug output for both AGWPE
and connection / state machine related activity.

Fixes wb2osz#534, Fixes wb2osz#535
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant