From 69235cac5b3da5ff0dc20310e7474cabd8e63ba3 Mon Sep 17 00:00:00 2001 From: historia <[not public]> Date: Tue, 15 Sep 2026 20:14:02 -0400 Subject: feat: route all html editor API mutations through single owner task --- cmd/thoi/main.go | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) (limited to 'cmd/thoi/main.go') diff --git a/cmd/thoi/main.go b/cmd/thoi/main.go index 2031cb6..a07fbcc 100644 --- a/cmd/thoi/main.go +++ b/cmd/thoi/main.go @@ -64,23 +64,16 @@ func main() { } g.SetHub(server.Hub()) - // Admin mutation callbacks execute on the game's owner goroutine: the - // admin HTTP goroutine must not touch live players or world state. - // MigrateRoomIDs is the complete room-ID migration (players, Hub - // membership, casino room keys, world state, mob instances). - adminRewriteRoomIDs := g.MigrateRoomIDs - adminRebuildCraftIndex := func() { - g.RunOnOwner(func() { g.RebuildCraftIndex() }) - } - adminEvictRoom := func(roomID int) { - g.RunOnOwner(func() { g.EvictCasinoRoom(roomID) }) - } - adminReloadCourses := func() { - g.RunOnOwner(func() { g.CourseStore.ReloadAll() }) - } + // The entire editor API request is one owner task, including file commits, + // runtime migration, undo history and reloads. These callbacks already run + // on the owner and MUST NOT redispatch (that would deadlock). + adminRewriteRoomIDs := g.MigrateRoomIDsOnOwner + adminRebuildCraftIndex := g.RebuildCraftIndex + adminEvictRoom := g.EvictCasinoRoom + adminReloadCourses := g.CourseStore.ReloadAll if cfg.AdminHTTP.Enabled { - adminSrv, err := admin.NewServer(cfg, false, g.AccountStore, g.World, g.ItemStore, g.ObjectStore, g.MobStore, dataDir, adminReloadCourses, adminRewriteRoomIDs, adminEvictRoom, adminRebuildCraftIndex, *configPath) + adminSrv, err := admin.NewServer(cfg, false, g.AccountStore, g.World, g.ItemStore, g.ObjectStore, g.MobStore, dataDir, adminReloadCourses, adminRewriteRoomIDs, adminEvictRoom, adminRebuildCraftIndex, *configPath, g.RunAdminOnOwner) if err != nil { log.Fatalf("failed to start admin HTTP server: %v", err) } @@ -93,7 +86,7 @@ func main() { } if cfg.AdminHTTPS.Enabled { - adminSrv, err := admin.NewServer(cfg, true, g.AccountStore, g.World, g.ItemStore, g.ObjectStore, g.MobStore, dataDir, adminReloadCourses, adminRewriteRoomIDs, adminEvictRoom, adminRebuildCraftIndex, *configPath) + adminSrv, err := admin.NewServer(cfg, true, g.AccountStore, g.World, g.ItemStore, g.ObjectStore, g.MobStore, dataDir, adminReloadCourses, adminRewriteRoomIDs, adminEvictRoom, adminRebuildCraftIndex, *configPath, g.RunAdminOnOwner) if err != nil { log.Fatalf("failed to start admin HTTPS server: %v", err) } -- cgit v1.2.3