* hammerTime forces the server to shutdown in a given timeout - whether it finished outstanding requests or not. if Read/WriteTimeout are not set or the max header size is very big a connection could hang... srv.Serve() will not return until all connections are served. this will unblock the srv.wg.
(d time.Duration)
| 396 | return. |
| 397 | */ |
| 398 | func (srv *endlessServer) hammerTime(d time.Duration) { |
| 399 | defer func() { |
| 400 | // we are calling srv.wg.Done() until it panics which means we called |
| 401 | // Done() when the counter was already at 0 and we're done. |
| 402 | // (and thus Serve() will return and the parent will exit) |
| 403 | if r := recover(); r != nil { |
| 404 | log.Println("WaitGroup at 0", r) |
| 405 | } |
| 406 | }() |
| 407 | if srv.getState() != STATE_SHUTTING_DOWN { |
| 408 | return |
| 409 | } |
| 410 | time.Sleep(d) |
| 411 | log.Println("[STOP - Hammer Time] Forcefully shutting down parent") |
| 412 | for { |
| 413 | if srv.getState() == STATE_TERMINATE { |
| 414 | break |
| 415 | } |
| 416 | srv.wg.Done() |
| 417 | runtime.Gosched() |
| 418 | } |
| 419 | } |
| 420 | |
| 421 | func (srv *endlessServer) fork() (err error) { |
| 422 | runningServerReg.Lock() |
no test coverage detected