Skip to content

Improve resource startup/shutdown handling and fix some edge cases in the checksum pipeline - #5135

Merged
Dutchman101 merged 1 commit into
multitheftauto:masterfrom
Dutchman101:server-resource-handling-fixes-1
Aug 2, 2026
Merged

Improve resource startup/shutdown handling and fix some edge cases in the checksum pipeline#5135
Dutchman101 merged 1 commit into
multitheftauto:masterfrom
Dutchman101:server-resource-handling-fixes-1

Conversation

@Dutchman101

Copy link
Copy Markdown
Member

A cleanup pass on how the server deals with resources that fail to start, plus some improvements to how file checksums are handled and a couple of smaller fixes.

Resource startup and shutdown

Start() had several spots where it could give up early, but most of them didn't clean up properly -- elements, the VM, storage, and the element group could be left behind depending on which thing failed. Now every failure path tears down whatever it already set up, and clients are told to remove the resource's elements so nothing gets left dangling on their side either. The timestamp that tracks when a resource last started is now properly reset when a start fails, and the failure reason string is cleared at the start of each load/start attempt so old errors don't stick around.

Stop() also had a problem where the final state change event was never actually reaching scripts because it ran after the resource element was already deleted. That's been moved so it fires at the right time.

Checksum handling

A few improvements around when and how file checksums are computed and stored. The main ones are making sure blocked files don't get their checksums saved (which could mess up change detection), doing a fresh check of the file on disk at start time instead of trusting whatever was computed during the earlier load, and double-checking the checksum right before copying a file to the HTTP cache in case the file changed in between.

Other fixes

  • Console commands would say a resource "is loaded, but has errors" when it actually wasn't loaded at all. Fixed the message.
  • The VM creation step now handles exceptions properly instead of letting them escape, and a few places that could pass around a null VM pointer are now guarded.
  • Some log calls were passing strings with % characters straight into printf-style functions, which could read garbage off the stack. Switched to using "%s" as the format.
  • The thread pool singleton could get destroyed too early during server shutdown in some edge cases. Changed it to a heap allocation that lives forever, which is a common pattern for this kind of thing.
  • A couple of gaps in how ChangeManager and Refresh handle reloading were tightened up.

Files

Server/mods/deathmatch/logic/CResource.cpp
Server/mods/deathmatch/logic/CResourceManager.cpp
Server/mods/deathmatch/logic/CConsoleCommands.cpp
Shared/sdk/SharedUtil.ThreadPool.h

@Dutchman101
Dutchman101 merged commit 484f0f5 into multitheftauto:master Aug 2, 2026
10 checks passed
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.

2 participants