aboutsummaryrefslogtreecommitdiff
path: root/ge.c
diff options
context:
space:
mode:
authorOmar Polo <op@omarpolo.com>2023-06-26 09:44:46 +0000
committerOmar Polo <op@omarpolo.com>2023-06-26 09:44:46 +0000
commited164e7221f75d3d7f48351e9427f2ce53ab284a (patch)
tree02b5682b5b239673ace2add072f4ea6d836e3194 /ge.c
parentda0821b6cb54a85bcbe76cdf0a9a16f8f1a14619 (diff)
call getnameinfo() only once per request
Diffstat (limited to 'ge.c')
-rw-r--r--ge.c12
1 files changed, 2 insertions, 10 deletions
diff --git a/ge.c b/ge.c
index dff3105..57a02af 100644
--- a/ge.c
+++ b/ge.c
@@ -42,16 +42,8 @@ static const struct option opts[] = {
void
log_request(struct client *c, char *meta, size_t l)
{
- char hbuf[NI_MAXHOST], sbuf[NI_MAXSERV], b[GEMINI_URL_LEN];
+ char b[GEMINI_URL_LEN];
const char *t;
- int ec;
-
- ec = getnameinfo((struct sockaddr*)&c->raddr, c->raddrlen,
- hbuf, sizeof(hbuf),
- sbuf, sizeof(sbuf),
- NI_NUMERICHOST | NI_NUMERICSERV);
- if (ec != 0)
- fatalx("getnameinfo: %s", gai_strerror(ec));
if (c->iri.schema != NULL) {
/* serialize the IRI */
@@ -81,7 +73,7 @@ log_request(struct client *c, char *meta, size_t l)
if ((t = memchr(meta, '\r', l)) == NULL)
t = meta + l;
- fprintf(stderr, "%s:%s GET %s %.*s\n", hbuf, sbuf, b,
+ fprintf(stderr, "%s:%s GET %s %.*s\n", c->rhost, c->rserv, b,
(int)(t-meta), meta);
}