In the previous commit idle connections are reinserted onto the active list
authorclaudio <claudio@openbsd.org>
Tue, 30 Jan 2024 11:15:05 +0000 (11:15 +0000)
committerclaudio <claudio@openbsd.org>
Tue, 30 Jan 2024 11:15:05 +0000 (11:15 +0000)
when the connection is closed. Since active connections are processed after
idle ones this will trigger a "timeout, connection closed" warning.
Work around this by clearing io_time in the close case of idle connections
and checking for this in the active connection case.
Problem noticed and OK job@

usr.sbin/rpki-client/http.c

index 08dbaff..282487a 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: http.c,v 1.79 2024/01/30 10:16:13 claudio Exp $ */
+/*     $OpenBSD: http.c,v 1.80 2024/01/30 11:15:05 claudio Exp $ */
 /*
  * Copyright (c) 2020 Nils Fisher <nils_fisher@hotmail.com>
  * Copyright (c) 2020 Claudio Jeker <claudio@openbsd.org>
@@ -2160,8 +2160,10 @@ proc_http(char *bind_addr, int fd)
                LIST_FOREACH_SAFE(conn, &idle, entry, nc) {
                        if (conn->pfd != NULL && conn->pfd->revents != 0)
                                http_do(conn, http_handle);
-                       else if (conn->idle_time <= now)
+                       else if (conn->idle_time <= now) {
+                               conn->io_time = 0;
                                http_do(conn, http_close);
+                       }
 
                        if (conn->state == STATE_FREE)
                                http_free(conn);
@@ -2172,7 +2174,7 @@ proc_http(char *bind_addr, int fd)
                        /* check if event is ready */
                        if (conn->pfd != NULL && conn->pfd->revents != 0)
                                http_do(conn, http_handle);
-                       else if (conn->io_time <= now) {
+                       else if (conn->io_time != 0 && conn->io_time <= now) {
                                conn->io_time = 0;
                                if (conn->state == STATE_CONNECT) {
                                        warnx("%s: connect timeout",