Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
caddy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
caddy
Commits
01e05afa
Commit
01e05afa
authored
Jun 07, 2016
by
Matt Holt
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #870 from mholt/close-idle-conn
Close idle connections after graceful shutdown timeout
parents
e7fc26e3
37ae2100
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
0 deletions
+11
-0
caddyhttp/httpserver/server.go
caddyhttp/httpserver/server.go
+11
-0
No files found.
caddyhttp/httpserver/server.go
View file @
01e05afa
...
...
@@ -52,6 +52,16 @@ func NewServer(addr string, group []*SiteConfig) (*Server, error) {
connTimeout
:
GracefulTimeout
,
}
s
.
Server
.
Handler
=
s
// this is weird, but whatever
s
.
Server
.
ConnState
=
func
(
c
net
.
Conn
,
cs
http
.
ConnState
)
{
if
cs
==
http
.
StateIdle
{
s
.
listenerMu
.
Lock
()
// server stopped, close idle connection
if
s
.
listener
==
nil
{
c
.
Close
()
}
s
.
listenerMu
.
Unlock
()
}
}
// Disable HTTP/2 if desired
if
!
HTTP2
{
...
...
@@ -288,6 +298,7 @@ func (s *Server) Stop() (err error) {
s
.
listenerMu
.
Lock
()
if
s
.
listener
!=
nil
{
err
=
s
.
listener
.
Close
()
s
.
listener
=
nil
}
s
.
listenerMu
.
Unlock
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment