Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Client disconnect on SIGINT #49

Merged
merged 5 commits into from
Mar 19, 2022
Merged

Client disconnect on SIGINT #49

merged 5 commits into from
Mar 19, 2022

Conversation

lcsmuller
Copy link
Collaborator

@lcsmuller lcsmuller commented Mar 18, 2022

What?

Disconnect client(s) from their on-going session if a SIGINT is received.

Why?

  • Abruptly ending the program means Discord would never be notified of the client's disconnect, thus keeping a lingering online status until it fails to receive a heartbeat payload.
  • Ensure full cleanup of the API resources so that users may catch up their memory leaks, or incorrect cleanup from concord's side.

How?

A ccord_has_sigint global is set once a SIGINT is detected, which will be checked against by all running clients and they will be prompted to call discord_shutdown().

Testing?

Removed now outdated test/async.c logic that had a custom SIGINT handler for gracefully disconnecting, with this PR Ctrl+C for a clean disconnect still works just fine.

Anything Else? (optional)

I haven't added any mutexes around the ccord_has_sigint global var, doing so is trivial but I couldn't think of a scenario where multiple SIGINT may be triggered in parallel.

@lcsmuller lcsmuller added the enhancement New feature or request label Mar 18, 2022
@lcsmuller lcsmuller merged commit b56983d into dev Mar 19, 2022
@lcsmuller lcsmuller deleted the sigint_disconnect branch March 19, 2022 13:56
lcsmuller added a commit to Cogmasters/cogmaster-bot that referenced this pull request Mar 19, 2022
lcsmuller added a commit that referenced this pull request Mar 20, 2022
#49 changes and fix carray bug
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant