Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTP communication #174

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions keyserver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ type ConiksServer struct {
configFilePath string
reloadChan chan os.Signal
epochTimer *time.Timer
httpServer *http.Server
}

// LoadServerConfig loads the ServerConfig for the server from the
Expand Down Expand Up @@ -193,10 +192,15 @@ func (server *ConiksServer) Run(addrs []*Address) {
Handler: mux,
TLSConfig: tlsConfig,
}
server.httpServer = httpSrv
go func() {
httpSrv.Serve(ln)
}()
go func() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add server.waitStop.Add(1) before this routine and server.waitStop.Done() after httpSrv.Shutdown().

<-server.stop
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
defer cancel()
httpSrv.Shutdown(ctx)
}()
case "tcp", "unix":
ln, tlsConfig := resolveAndListen(addr)
server.waitStop.Add(1)
Expand Down Expand Up @@ -319,11 +323,6 @@ func updatePerms(addr *Address) map[int]bool {
// Shutdown closes all of the server's connections and shuts down the server.
func (server *ConiksServer) Shutdown() error {
close(server.stop)
if server.httpServer != nil {
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
server.httpServer.Shutdown(ctx)
}
server.waitStop.Wait()
return nil
}