Misc mutex locking things to avoid data races
This commit is contained in:
@@ -104,7 +104,7 @@ type Server struct {
|
||||
// Defines the process configuration for the server instance. This is dynamically
|
||||
// fetched from the Pterodactyl Server instance each time the server process is
|
||||
// started, and then cached here.
|
||||
processConfiguration *api.ProcessConfiguration
|
||||
procConfig *api.ProcessConfiguration
|
||||
|
||||
// Tracks the installation process for this server and prevents a server from running
|
||||
// two installer processes at the same time. This also allows us to cancel a running
|
||||
@@ -153,6 +153,13 @@ type BuildSettings struct {
|
||||
Threads string `json:"threads"`
|
||||
}
|
||||
|
||||
func (s *Server) Id() string {
|
||||
s.RLock()
|
||||
defer s.RUnlock()
|
||||
|
||||
return s.Uuid
|
||||
}
|
||||
|
||||
// Converts the CPU limit for a server build into a number that can be better understood
|
||||
// by the Docker environment. If there is no limit set, return -1 which will indicate to
|
||||
// Docker that it has unlimited CPU quota.
|
||||
@@ -366,7 +373,10 @@ func (s *Server) SyncWithConfiguration(cfg *api.ServerConfigurationResponse) err
|
||||
return errors.WithStack(err)
|
||||
}
|
||||
|
||||
s.processConfiguration = cfg.ProcessConfiguration
|
||||
s.Lock()
|
||||
s.procConfig = cfg.ProcessConfiguration
|
||||
s.Unlock()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user