Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
IRMA
Github mirrors
irmago
Commits
4c02373c
Commit
4c02373c
authored
Mar 10, 2019
by
Sietse Ringers
Browse files
Make requestorserver.Stop() wait until stopping has succeeded or timed out
parent
9ee7a391
Pipeline
#19812
passed with stages
in 9 minutes and 56 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
server/requestorserver/server.go
View file @
4c02373c
...
...
@@ -32,6 +32,7 @@ type Server struct {
conf
*
Configuration
irmaserv
*
irmaserver
.
Server
stop
chan
struct
{}
stopped
chan
struct
{}
}
// Start the server. If successful then it will not return until Stop() is called.
...
...
@@ -57,6 +58,7 @@ func (s *Server) Start(config *Configuration) error {
}
done
:=
make
(
chan
error
,
count
)
s
.
stop
=
make
(
chan
struct
{})
s
.
stopped
=
make
(
chan
struct
{},
count
)
if
s
.
conf
.
separateClientServer
()
{
go
func
()
{
...
...
@@ -104,9 +106,12 @@ func (s *Server) startServer(handler http.Handler, name, addr string, port int,
go
func
()
{
<-
s
.
stop
if
err
:=
serv
.
Shutdown
(
context
.
Background
());
err
!=
nil
{
ctx
,
cancel
:=
context
.
WithTimeout
(
context
.
Background
(),
1
*
time
.
Second
)
defer
cancel
()
if
err
:=
serv
.
Shutdown
(
ctx
);
err
!=
nil
{
_
=
server
.
LogError
(
err
)
}
s
.
stopped
<-
struct
{}{}
}()
if
tlsConf
!=
nil
{
...
...
@@ -129,6 +134,10 @@ func filterStopError(err error) error {
func
(
s
*
Server
)
Stop
()
{
s
.
irmaserv
.
Stop
()
s
.
stop
<-
struct
{}{}
<-
s
.
stopped
if
s
.
conf
.
separateClientServer
()
{
<-
s
.
stopped
}
}
func
New
(
config
*
Configuration
)
(
*
Server
,
error
)
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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