Kill unused globals and swap the POLLIN and POLLOUT handler for the
authorclaudio <claudio@openbsd.org>
Tue, 6 Apr 2021 12:28:56 +0000 (12:28 +0000)
committerclaudio <claudio@openbsd.org>
Tue, 6 Apr 2021 12:28:56 +0000 (12:28 +0000)
pipe to the main process.
OK job@

usr.sbin/rpki-client/http.c

index 137f05f..bf86d8a 100644 (file)
@@ -1,4 +1,4 @@
-/*      $OpenBSD: http.c,v 1.15 2021/04/02 17:10:12 claudio Exp $  */
+/*      $OpenBSD: http.c,v 1.16 2021/04/06 12:28:56 claudio Exp $  */
 /*
  * Copyright (c) 2020 Nils Fisher <nils_fisher@hotmail.com>
  * Copyright (c) 2020 Claudio Jeker <claudio@openbsd.org>
@@ -124,10 +124,6 @@ struct tls_config *tls_config;
 uint8_t *tls_ca_mem;
 size_t tls_ca_size;
 
-char *resp_buf[MAX_CONNECTIONS];
-size_t resp_bsz[MAX_CONNECTIONS];
-size_t resp_idx;
-
 /*
  * Return a string that can be used in error message to identify the
  * connection.
@@ -1191,7 +1187,14 @@ proc_http(char *bind_addr, int fd)
 
                if (pfds[MAX_CONNECTIONS].revents & POLLHUP)
                        break;
-
+               if (pfds[MAX_CONNECTIONS].revents & POLLOUT) {
+                       switch (msgbuf_write(&msgq)) {
+                       case 0:
+                               errx(1, "write: connection closed");
+                       case -1:
+                               err(1, "write");
+                       }
+               }
                if (pfds[MAX_CONNECTIONS].revents & POLLIN) {
                        struct http_connection *h;
                        size_t id;
@@ -1215,14 +1218,6 @@ proc_http(char *bind_addr, int fd)
                                }
                        }
                }
-               if (pfds[MAX_CONNECTIONS].revents & POLLOUT) {
-                       switch (msgbuf_write(&msgq)) {
-                       case 0:
-                               errx(1, "write: connection closed");
-                       case -1:
-                               err(1, "write");
-                       }
-               }
                for (i = 0; i < MAX_CONNECTIONS; i++) {
                        struct http_connection *conn = http_conns[i];