Closed dgrr closed 6 years ago
This behaviour is explicitly described in the Shutdown doc. Use Close() if you want an immediate return.
@illotum no. This is not described in doc. The problem is that I must wait new connection to exit successfully
@themester on my linux and mac machines this works fine. What platform are you using? Are you doing any requests or do you press Ctrl+C immediately after starting?
Hello @erikdubbelboer
I see that works well if you make multiple requests. But if you make one or two the servers waits another connection after Shutdown call. I mean that does not work in all cases. I do not think that is an issue.
What platform are you using?
Gentoo (linux)
Can you write a test case or a program that always causes this issue? I can't seem to replicate it.
http://f.mester.pw/erik.mp4 here you can see the error.
Okay. I identified the problem. It can be fixed changing this line to case <-time.After(...):
But I don't know if it will affect the performance.
[edit]
I checked it and the server performance is not reduced by this change.
That impossible. I'm sure something else is going on. That is just a goroutine that periodically cleans up the worker pool. Nothing will block on that and when main exits the program will just quit no matter if this goroutine is still running.
I think your issue is that you still have a keep-alive connection open and the server won't terminate until this is closed. Sending another request forces the connection to close after this. One way to fix this is to set a read or keepalive timeout on the server.
Aghhh!! That's right. I have keep-alive connections but Chrome does not show Connection field in header and does not show active connections (unlike firefox)
Hello Erik,
I was testing new Shutdown function and I found that server shuts down after a request perform after Shutdown call. If I press Ctrl+C I must wait a new request to shutdown the server completly. I tried adding s.wg.Done() after this line and works well with the code below but the tests fails (as should do).