mirror of
https://github.com/zix99/traefik-lazyload.git
synced 2025-12-21 21:33:09 +01:00
Narrower locks for faster response times
This commit is contained in:
@@ -216,9 +216,6 @@ func (s *Core) pollThread(rate time.Duration) {
|
|||||||
// stopping idle containers
|
// stopping idle containers
|
||||||
// Will normally happen in the background with the pollThread
|
// Will normally happen in the background with the pollThread
|
||||||
func (s *Core) Poll() {
|
func (s *Core) Poll() {
|
||||||
s.mux.Lock()
|
|
||||||
defer s.mux.Unlock()
|
|
||||||
|
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
|
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
@@ -240,6 +237,10 @@ func (s *Core) checkForNewContainersSync(ctx context.Context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Lock
|
||||||
|
s.mux.Lock()
|
||||||
|
defer s.mux.Unlock()
|
||||||
|
|
||||||
// check for containers we think are running, but aren't (destroyed, error'd, stop'd via another process, etc)
|
// check for containers we think are running, but aren't (destroyed, error'd, stop'd via another process, etc)
|
||||||
for cid, cts := range s.active {
|
for cid, cts := range s.active {
|
||||||
if _, ok := runningContainers[cid]; !ok && !cts.pinned {
|
if _, ok := runningContainers[cid]; !ok && !cts.pinned {
|
||||||
@@ -259,6 +260,9 @@ func (s *Core) checkForNewContainersSync(ctx context.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *Core) watchForInactivitySync(ctx context.Context) {
|
func (s *Core) watchForInactivitySync(ctx context.Context) {
|
||||||
|
s.mux.Lock()
|
||||||
|
defer s.mux.Unlock()
|
||||||
|
|
||||||
for cid, cts := range s.active {
|
for cid, cts := range s.active {
|
||||||
shouldStop, err := s.checkContainerForInactivity(ctx, cid, cts)
|
shouldStop, err := s.checkContainerForInactivity(ctx, cid, cts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user