Projects STRLCPY prox5 Commits 157bc2d2
🤬
  • ■ ■ ■ ■ ■ ■
    daemons.go
    skipped 1 lines
    2 2   
    3 3  import (
    4 4   "errors"
     5 + "strconv"
    5 6   "sync"
    6 7   "sync/atomic"
     8 + "time"
    7 9  )
    8 10   
    9 11  func (s *Swamp) svcUp() {
    skipped 84 lines
    94 96  }
    95 97   
    96 98  func (s *Swamp) recycling() int {
     99 + s.mu.Lock()
     100 + defer s.mu.Unlock()
    97 101   if !s.GetRecyclingStatus() {
    98 102   return 0
    99 103   }
    skipped 13 lines
    113 117   return 0
    114 118   case s.Pending <- sock:
    115 119   count++
     120 + default:
    116 121   }
    117 122   }
    118 123   
    skipped 11 lines
    130 135   q := make(chan bool)
    131 136   
    132 137   go func() {
     138 + var count = 0
    133 139   for {
    134 140   select {
    135 141   case <-s.ctx.Done():
    skipped 3 lines
    139 145   case sock := <-s.Pending:
    140 146   if err := s.pool.Submit(sock.validate); err != nil {
    141 147   s.dbgPrint(ylw + err.Error() + rst)
     148 + }
     149 + 
     150 + default:
     151 + time.Sleep(25 * time.Millisecond)
     152 + if count == 0 {
     153 + time.Sleep(5 * time.Second)
     154 + }
     155 + count++
     156 + if count > 100 {
     157 + rcount := s.recycling()
     158 + if rcount > 0 {
     159 + s.dbgPrint(ylw + "recycled " + strconv.Itoa(rcount) + " proxies from our map" + rst)
     160 + }
     161 + count = 0
    142 162   }
    143 163   }
    144 164   }
    skipped 7 lines
Please wait...
Page is in error, reload to recover