@@ -640,6 +640,8 @@ func (s *DockerServer) topContainer(w http.ResponseWriter, r *http.Request) {
640
640
http .Error (w , err .Error (), http .StatusNotFound )
641
641
return
642
642
}
643
+ s .cMut .RLock ()
644
+ defer s .cMut .RUnlock ()
643
645
if ! container .State .Running {
644
646
w .WriteHeader (http .StatusInternalServerError )
645
647
fmt .Fprintf (w , "Container %s is not running" , id )
@@ -787,11 +789,13 @@ func (s *DockerServer) attachContainer(w http.ResponseWriter, r *http.Request) {
787
789
}()
788
790
}
789
791
outStream := stdcopy .NewStdWriter (conn , stdcopy .Stdout )
792
+ s .cMut .RLock ()
790
793
if container .State .Running {
791
794
fmt .Fprintf (outStream , "Container is running\n " )
792
795
} else {
793
796
fmt .Fprintf (outStream , "Container is not running\n " )
794
797
}
798
+ s .cMut .RUnlock ()
795
799
fmt .Fprintln (outStream , "What happened?" )
796
800
fmt .Fprintln (outStream , "Something happened" )
797
801
wg .Wait ()
@@ -919,11 +923,13 @@ func (s *DockerServer) logContainer(w http.ResponseWriter, r *http.Request) {
919
923
}
920
924
w .Header ().Set ("Content-Type" , "application/vnd.docker.raw-stream" )
921
925
w .WriteHeader (http .StatusOK )
926
+ s .cMut .RLock ()
922
927
if container .State .Running {
923
928
fmt .Fprintf (w , "Container is running\n " )
924
929
} else {
925
930
fmt .Fprintf (w , "Container is not running\n " )
926
931
}
932
+ s .cMut .RUnlock ()
927
933
fmt .Fprintln (w , "What happened?" )
928
934
fmt .Fprintln (w , "Something happened" )
929
935
if r .URL .Query ().Get ("follow" ) == "1" {
0 commit comments