Detect connections that have been silently closed by the remote end. An idle keep-alive connection should have no data pending in the socket. If poll(SELECT_READ, 0) returns true on such a connection, it means the server has sent a FIN (or RST), so the next request on this connection would fail with "No message received" (NoMessageException).
| 821 | /// server has sent a FIN (or RST), so the next request on this connection |
| 822 | /// would fail with "No message received" (NoMessageException). |
| 823 | static bool isStale(Session & connection) |
| 824 | { |
| 825 | try |
| 826 | { |
| 827 | return connection.socket().poll(Poco::Timespan(0), Poco::Net::Socket::SELECT_READ); |
| 828 | } |
| 829 | catch (Poco::IOException &) |
| 830 | { |
| 831 | return true; |
| 832 | } |
| 833 | } |
| 834 | |
| 835 | |
| 836 | ConnectionPtr prepareNewConnection(const ConnectionTimeouts & timeouts, UInt64 * connect_time) |