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

Make Shutdown work correctly #74

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

RedFlames
Copy link
Collaborator

I wrote this based off the exceptions that happen when you call /api/shutdown

image

image

Somehow this error still gets logged, despite everything shutting down correctly...

(01/16/2023 17:12:07) [CRI] [netplus] Error in thread pool thread 3: System.Net.Sockets.SocketException (10004): A blocking operation was interrupted by a call to WSACancelBlockingCall.
   at System.Net.Sockets.Socket.ReceiveFrom(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags, EndPoint& remoteEP)
   at System.Net.Sockets.Socket.ReceiveFrom(Byte[] buffer, EndPoint& remoteEP)
   at Celeste.Mod.CelesteNet.Server.UDPReceiverRole.Worker.StartWorker(Socket socket, CancellationToken token) in C:\Program Files (x86)\Steam\steamapps\common\Celeste\Mods\CelesteNet_dev\CelesteNet.Server\ConPlus\UDPReceiverRole.cs:line 29
   at Celeste.Mod.CelesteNet.Server.MultipleSocketBinderRole.RoleWorker.StartWorker(CancellationToken token) in C:\Program Files (x86)\Steam\steamapps\common\Celeste\Mods\CelesteNet_dev\CelesteNet.Server\ConPlus\MultipleSocketBinderRole.cs:line 18
   at Celeste.Mod.CelesteNet.Server.NetPlusThread.ThreadLoop() in C:\Program Files (x86)\Steam\steamapps\common\Celeste\Mods\CelesteNet_dev\CelesteNet.Server\NetPlus\ThreadPool.cs:line 196

I have no idea if this breaks anything in how the server actually runs; I only went by testing /api/shutdown 🙂

  • moved the RWLock.Dispose calls outside of a use of the lock
  • made RWLock.Inner private because noone should be touching that directly anyways
  • properly cancel threads on shutdown(?)

…ck.Inner private, properly cancel threads on shutdown(?)
@RedFlames RedFlames added Server Shared CelesteNet.Shared labels Jan 18, 2023
@RedFlames RedFlames marked this pull request as draft January 23, 2023 13:50
try {
foreach (CelesteNetConnection con in SafeDisposeQueue.GetConsumingEnumerable(ShutdownTokenSrc.Token)) {
if (con.IsAlive) {
Logger.Log("main", $"Safe dispose triggered for connection {con}");
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made this PR the last time we had a catastrophic lock disposal situation, I guess. Some kinda really rare race... this may be good to merge and see what it does on the server 🤔
Anyways TODO this line needs changing because it shouldn't default to VVV log level (honestly nothing ever should? Why is that the implicit level?)

@RedFlames RedFlames added this to the server-next milestone Dec 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Server Shared CelesteNet.Shared
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant