mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-16 13:22:09 +08:00
avoid zombie connection and goroutine leaked
This commit is contained in:
parent
3757142584
commit
b6d89bc972
9
gin.go
9
gin.go
@ -13,6 +13,7 @@ import (
|
||||
"path"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin/internal/bytesconv"
|
||||
"github.com/gin-gonic/gin/render"
|
||||
@ -375,7 +376,13 @@ func (engine *Engine) Run(addr ...string) (err error) {
|
||||
|
||||
address := resolveAddress(addr)
|
||||
debugPrint("Listening and serving HTTP on %s\n", address)
|
||||
err = http.ListenAndServe(address, engine.Handler())
|
||||
|
||||
server := &http.Server{
|
||||
Addr: address,
|
||||
Handler: engine.Handler(),
|
||||
ReadTimeout: 60 * time.Second,
|
||||
}
|
||||
err = server.ListenAndServe()
|
||||
return
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user