mirror of
https://github.com/valyala/fasthttp.git
synced 2026-06-16 16:17:38 +03:00
Allow concurrent ServeTLS
This commit is contained in:
@@ -1566,11 +1566,14 @@ func (s *Server) ListenAndServeTLSEmbed(addr string, certData, keyData []byte) e
|
||||
// If the certFile or keyFile has not been provided the server structure,
|
||||
// the function will use previously added TLS configuration.
|
||||
func (s *Server) ServeTLS(ln net.Listener, certFile, keyFile string) error {
|
||||
s.mu.Lock()
|
||||
err := s.AppendCert(certFile, keyFile)
|
||||
if err != nil && err != errNoCertOrKeyProvided {
|
||||
s.mu.Unlock()
|
||||
return err
|
||||
}
|
||||
if s.tlsConfig == nil {
|
||||
s.mu.Unlock()
|
||||
return errNoCertOrKeyProvided
|
||||
}
|
||||
|
||||
@@ -1578,6 +1581,8 @@ func (s *Server) ServeTLS(ln net.Listener, certFile, keyFile string) error {
|
||||
// But since we also support older versions we'll keep this here.
|
||||
s.tlsConfig.BuildNameToCertificate() //nolint:staticcheck
|
||||
|
||||
s.mu.Unlock()
|
||||
|
||||
return s.Serve(
|
||||
tls.NewListener(ln, s.tlsConfig),
|
||||
)
|
||||
@@ -1590,11 +1595,15 @@ func (s *Server) ServeTLS(ln net.Listener, certFile, keyFile string) error {
|
||||
// If the certFile or keyFile has not been provided the server structure,
|
||||
// the function will use previously added TLS configuration.
|
||||
func (s *Server) ServeTLSEmbed(ln net.Listener, certData, keyData []byte) error {
|
||||
s.mu.Lock()
|
||||
|
||||
err := s.AppendCertEmbed(certData, keyData)
|
||||
if err != nil && err != errNoCertOrKeyProvided {
|
||||
s.mu.Unlock()
|
||||
return err
|
||||
}
|
||||
if s.tlsConfig == nil {
|
||||
s.mu.Unlock()
|
||||
return errNoCertOrKeyProvided
|
||||
}
|
||||
|
||||
@@ -1602,6 +1611,8 @@ func (s *Server) ServeTLSEmbed(ln net.Listener, certData, keyData []byte) error
|
||||
// But since we also support older versions we'll keep this here.
|
||||
s.tlsConfig.BuildNameToCertificate() //nolint:staticcheck
|
||||
|
||||
s.mu.Unlock()
|
||||
|
||||
return s.Serve(
|
||||
tls.NewListener(ln, s.tlsConfig),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user