On Wed, Nov 02, 2022 at 11:55:12AM +0100, Claudio Jeker wrote: > Job's diff made me realise that clearing the connection info (conn->res) > makes error reporting worse. It is not like we save lots of memory by > doing so. So do not call freeaddrinfo() in http_connect_done(), now > http_free() will free res0 before freeing conn.
Makes sense. We're always in STATE_CONNECT, so it's ok to call http_connect_failed(). ok tb > > -- > :wq Claudio > > Index: http.c > =================================================================== > RCS file: /cvs/src/usr.sbin/rpki-client/http.c,v > retrieving revision 1.70 > diff -u -p -r1.70 http.c > --- http.c 18 Oct 2022 14:03:39 -0000 1.70 > +++ http.c 2 Nov 2022 10:35:28 -0000 > @@ -802,10 +802,6 @@ http_do(struct http_connection *conn, en > static enum res > http_connect_done(struct http_connection *conn) > { > - freeaddrinfo(conn->res0); > - conn->res0 = NULL; > - conn->res = NULL; > - > if (proxy.proxyhost != NULL) > return proxy_connect(conn); > return http_tls_connect(conn); > @@ -889,21 +885,15 @@ http_finish_connect(struct http_connecti > len = sizeof(error); > if (getsockopt(conn->fd, SOL_SOCKET, SO_ERROR, &error, &len) == -1) { > warn("%s: getsockopt SO_ERROR", http_info(conn->req->uri)); > - goto fail; > + return http_connect_failed(conn); > } > if (error != 0) { > errno = error; > warn("%s: connect", http_info(conn->req->uri)); > - goto fail; > + return http_connect_failed(conn); > } > > return http_connect_done(conn); > - > -fail: > - close(conn->fd); > - conn->fd = -1; > - > - return http_connect(conn); > } > > /* >