summarylogtreecommitdiffstats
path: root/evhttp-afunix.patch
blob: 34edc78b193b5b958e8b2a3d61d854d03c5db977 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
diff --git a/http.c b/http.c
index ecb12bbf..56ab0815 100644
--- a/http.c
+++ b/http.c
@@ -4421,11 +4421,16 @@ evhttp_get_request_connection(
 	char *hostname = NULL, *portname = NULL;
 	struct bufferevent* bev = NULL;
 
-	name_from_addr(sa, salen, &hostname, &portname);
-	if (hostname == NULL || portname == NULL) {
-		if (hostname) mm_free(hostname);
-		if (portname) mm_free(portname);
-		return (NULL);
+	if (sa->sa_family == AF_UNIX) {
+		hostname = (char *)"localhost";
+		portname = (char *)"0";
+	} else {
+		name_from_addr(sa, salen, &hostname, &portname);
+		if (hostname == NULL || portname == NULL) {
+			if (hostname) mm_free(hostname);
+			if (portname) mm_free(portname);
+			return (NULL);
+		}
 	}
 
 	event_debug(("%s: new request from %s:%s on "EV_SOCK_FMT"\n",
@@ -4437,8 +4442,10 @@ evhttp_get_request_connection(
 	}
 	evcon = evhttp_connection_base_bufferevent_new(
 		http->base, NULL, bev, hostname, atoi(portname));
-	mm_free(hostname);
-	mm_free(portname);
+	if (sa->sa_family != AF_UNIX) {
+		mm_free(hostname);
+		mm_free(portname);
+	}
 	if (evcon == NULL)
 		return (NULL);