| 453 | } |
| 454 | |
| 455 | func (s *Server) drainWindow(rxFrames []*frame.Frame) time.Duration { |
| 456 | // Any non-empty client batch was a directed action (SYN, data, FIN, RST): |
| 457 | // the worker that posted it is blocked waiting for our response and has |
| 458 | // nothing else to do until we return. Use the short ActiveDrainWindow so |
| 459 | // these workers come back into the pool quickly and back-to-back |
| 460 | // connection setup/teardown cycles aren't gated on LongPollWindow (8s). |
| 461 | // Only truly empty polls (idle long-polls) keep the long window so the |
| 462 | // server can push downstream data without forcing constant repolling. |
| 463 | if len(rxFrames) > 0 { |
| 464 | return ActiveDrainWindow |
| 465 | } |
| 466 | return LongPollWindow |
| 467 | } |
| 468 | |
| 469 | // coalesceDuration picks the coalesce window for the current drain. Under |
| 470 | // high session fan-out we shrink the window: the next batch fills within |