+/* Time out a client because it's been idle for too long. */
+static void timeout_client(struct timeval *tv, void *p)
+{
+ struct client *c = p;
+ logmsg(&c->q, LOG_NOTICE, "timing out idle or stuck client");
+ sel_addtimer(&sel, &c->t, tv, timeout_client, 0);
+ disconnect_client(c);
+}
+
+/* Reset the client idle timer, as a result of activity. Set EXISTP if
+ * there is an existing timer which needs to be removed.
+ */
+static void reset_client_timer(struct client *c, int existp)
+{
+ struct timeval tv;
+
+ gettimeofday(&tv, 0);
+ tv.tv_sec += 30;
+ if (existp) sel_rmtimer(&c->t);
+ sel_addtimer(&sel, &c->t, &tv, timeout_client, c);
+}
+