aboutsummaryrefslogtreecommitdiff
path: root/fcgi.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 /fcgi.c
parentda0821b6cb54a85bcbe76cdf0a9a16f8f1a14619 (diff)
call getnameinfo() only once per request
Diffstat (limited to 'fcgi.c')
-rw-r--r--fcgi.c14
1 files changed, 3 insertions, 11 deletions
diff --git a/fcgi.c b/fcgi.c
index eb22d38..e29c713 100644
--- a/fcgi.c
+++ b/fcgi.c
@@ -343,26 +343,18 @@ fcgi_error(struct bufferevent *bev, short err, void *d)
void
fcgi_req(struct client *c)
{
- char addr[NI_MAXHOST], buf[22];
+ char buf[22];
char *qs;
- int e;
time_t tim;
struct tm tminfo;
struct envlist *p;
- e = getnameinfo((struct sockaddr*)&c->raddr, c->raddrlen,
- addr, sizeof(addr),
- NULL, 0,
- NI_NUMERICHOST);
- if (e != 0)
- fatalx("getnameinfo failed: %s", gai_strerror(e));
-
fcgi_begin_request(c->cgibev);
fcgi_send_param(c->cgibev, "GATEWAY_INTERFACE", "CGI/1.1");
fcgi_send_param(c->cgibev, "GEMINI_URL_PATH", c->iri.path);
fcgi_send_param(c->cgibev, "QUERY_STRING", c->iri.query);
- fcgi_send_param(c->cgibev, "REMOTE_ADDR", addr);
- fcgi_send_param(c->cgibev, "REMOTE_HOST", addr);
+ fcgi_send_param(c->cgibev, "REMOTE_ADDR", c->rhost);
+ fcgi_send_param(c->cgibev, "REMOTE_HOST", c->rhost);
fcgi_send_param(c->cgibev, "REQUEST_METHOD", "");
fcgi_send_param(c->cgibev, "SERVER_NAME", c->iri.host);
fcgi_send_param(c->cgibev, "SERVER_PROTOCOL", "GEMINI");