1
0
mirror of https://github.com/labstack/echo.git synced 2025-07-03 00:56:59 +02:00

Dropping mutex from ServeHTTP

Signed-off-by: Vishal Rana <vr@labstack.com>
This commit is contained in:
Vishal Rana
2017-05-13 14:12:35 -07:00
parent 0e134ee37c
commit 8f5fb6395a

11
echo.go
View File

@ -80,7 +80,7 @@ type (
Validator Validator
Renderer Renderer
AutoTLSManager autocert.Manager
Mutex sync.RWMutex
// Mutex sync.RWMutex
Logger Logger
}
@ -525,8 +525,8 @@ func (e *Echo) ReleaseContext(c Context) {
// ServeHTTP implements `http.Handler` interface, which serves HTTP requests.
func (e *Echo) ServeHTTP(w http.ResponseWriter, r *http.Request) {
// Acquire lock
e.Mutex.RLock()
defer e.Mutex.RUnlock()
// e.Mutex.RLock()
// defer e.Mutex.RUnlock()
// Acquire context
c := e.pool.Get().(*context)
@ -598,7 +598,6 @@ func (e *Echo) startTLS(address string) error {
}
// StartServer starts a custom http server.
func (e *Echo) StartServer(s *http.Server) (err error) {
// Setup
e.colorer.SetOutput(e.Logger.Output())
@ -620,7 +619,7 @@ func (e *Echo) StartServer(s *http.Server) (err error) {
}
}
if !e.HideBanner {
e.colorer.Printf("🚀 http server started on %s\n", e.colorer.Green(e.Listener.Addr()))
e.colorer.Printf(" http server started on %s\n", e.colorer.Green(e.Listener.Addr()))
}
return s.Serve(e.Listener)
}
@ -632,7 +631,7 @@ func (e *Echo) StartServer(s *http.Server) (err error) {
e.TLSListener = tls.NewListener(l, s.TLSConfig)
}
if !e.HideBanner {
e.colorer.Printf("🚀 https server started on %s\n", e.colorer.Green(e.TLSListener.Addr()))
e.colorer.Printf(" https server started on %s\n", e.colorer.Green(e.TLSListener.Addr()))
}
return s.Serve(e.TLSListener)
}