mirror of
				https://github.com/moby/moby.git
				synced 2022-11-09 12:21:53 -05:00 
			
		
		
		
	Replace Server.IsRunning with Engine.IsShutdown
Signed-off-by: Solomon Hykes <solomon@docker.com>
This commit is contained in:
		
							parent
							
								
									b4efcd53e0
								
							
						
					
					
						commit
						78f0a914ee
					
				
					 4 changed files with 4 additions and 23 deletions
				
			
		| 
						 | 
				
			
			@ -517,10 +517,9 @@ func (container *Container) monitor(callback execdriver.StartCallback) error {
 | 
			
		|||
	if container.daemon != nil && container.daemon.srv != nil {
 | 
			
		||||
		container.LogEvent("die")
 | 
			
		||||
	}
 | 
			
		||||
	if container.daemon != nil && container.daemon.srv != nil && container.daemon.srv.IsRunning() {
 | 
			
		||||
		// FIXME: here is race condition between two RUN instructions in Dockerfile
 | 
			
		||||
		// because they share same runconfig and change image. Must be fixed
 | 
			
		||||
		// in builder/builder.go
 | 
			
		||||
	// If the engine is shutting down, don't save the container state as stopped.
 | 
			
		||||
	// This will cause it to be restarted when the engine is restarted.
 | 
			
		||||
	if container.daemon != nil && container.daemon.eng != nil && !container.daemon.eng.IsShutdown() {
 | 
			
		||||
		if err := container.toDisk(); err != nil {
 | 
			
		||||
			utils.Errorf("Error dumping container %s state to disk: %s\n", container.ID, err)
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
package daemon
 | 
			
		||||
 | 
			
		||||
// FIXME: this shim interface is no longer needed, it can be removed
 | 
			
		||||
type Server interface {
 | 
			
		||||
	IsRunning() bool // returns true if the server is currently in operation
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -12,9 +12,6 @@ import (
 | 
			
		|||
 | 
			
		||||
func (srv *Server) handlerWrap(h engine.Handler) engine.Handler {
 | 
			
		||||
	return func(job *engine.Job) engine.Status {
 | 
			
		||||
		if !srv.IsRunning() {
 | 
			
		||||
			return job.Errorf("Server is not running")
 | 
			
		||||
		}
 | 
			
		||||
		srv.tasks.Add(1)
 | 
			
		||||
		defer srv.tasks.Done()
 | 
			
		||||
		return h(job)
 | 
			
		||||
| 
						 | 
				
			
			@ -53,7 +50,6 @@ func InitServer(job *engine.Job) engine.Status {
 | 
			
		|||
	if err := srv.daemon.Install(job.Eng); err != nil {
 | 
			
		||||
		return job.Error(err)
 | 
			
		||||
	}
 | 
			
		||||
	srv.SetRunning(true)
 | 
			
		||||
	return engine.StatusOK
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -28,25 +28,11 @@ import (
 | 
			
		|||
	"github.com/docker/docker/engine"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func (srv *Server) SetRunning(status bool) {
 | 
			
		||||
	srv.Lock()
 | 
			
		||||
	defer srv.Unlock()
 | 
			
		||||
 | 
			
		||||
	srv.running = status
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (srv *Server) IsRunning() bool {
 | 
			
		||||
	srv.RLock()
 | 
			
		||||
	defer srv.RUnlock()
 | 
			
		||||
	return srv.running
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type Server struct {
 | 
			
		||||
	sync.RWMutex
 | 
			
		||||
	daemon      *daemon.Daemon
 | 
			
		||||
	pullingPool map[string]chan struct{}
 | 
			
		||||
	pushingPool map[string]chan struct{}
 | 
			
		||||
	Eng         *engine.Engine
 | 
			
		||||
	running     bool
 | 
			
		||||
	tasks       sync.WaitGroup
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue