本站源代码
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

41 lignes
1.0KB

  1. // +build !windows
  2. // Copyright 2019 The Gitea Authors. All rights reserved.
  3. // Use of this source code is governed by a MIT-style
  4. // license that can be found in the LICENSE file.
  5. package graceful
  6. import "sync"
  7. var cleanupWaitGroup sync.WaitGroup
  8. func init() {
  9. cleanupWaitGroup = sync.WaitGroup{}
  10. // There are three places that could inherit sockets:
  11. //
  12. // * HTTP or HTTPS main listener
  13. // * HTTP redirection fallback
  14. // * SSH
  15. //
  16. // If you add an additional place you must increment this number
  17. // and add a function to call InformCleanup if it's not going to be used
  18. cleanupWaitGroup.Add(3)
  19. // Wait till we're done getting all of the listeners and then close
  20. // the unused ones
  21. go func() {
  22. cleanupWaitGroup.Wait()
  23. // Ignore the error here there's not much we can do with it
  24. // They're logged in the CloseProvidedListeners function
  25. _ = CloseProvidedListeners()
  26. }()
  27. }
  28. // InformCleanup tells the cleanup wait group that we have either taken a listener
  29. // or will not be taking a listener
  30. func InformCleanup() {
  31. cleanupWaitGroup.Done()
  32. }
上海开阖软件有限公司 沪ICP备12045867号-1