diff options
Diffstat (limited to 'cmd/thoi/main.go')
| -rw-r--r-- | cmd/thoi/main.go | 25 |
1 files changed, 9 insertions, 16 deletions
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) } |
