Skip to content
Snippets Groups Projects
Commit 38b9bc8a authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Add UNIX domain FastCGI support

Resolves a long-standing todo comment and has made wiki.synchro.net page
rendering even faster.

PHP-FPM defaults to creating/listening on UNIX domain sockets.

This resolves gitlab issue #507
parent fe30acd5
No related branches found
No related tags found
1 merge request!463MRC mods by Codefenix (2024-10-20)
Pipeline #3729 failed
......@@ -30,8 +30,6 @@
*
* Add support for multipart/form-data
*
* Add support for UNIX-domain sockets for FastCGI
*
* Improved Win32 support for POST data... currently will read past Content-Length
*
*/
......@@ -3926,19 +3924,38 @@ static SOCKET fastcgi_connect(const char *orig_path, SOCKET client_sock)
{
int result;
char *path = strdup(orig_path);
char *port = split_port_part(path);
ulong val;
SOCKET sock;
struct addrinfo hints,*res,*cur;
// TODO: UNIX-domain sockets...
if (strncmp(path, "unix:", 5) == 0) {
lprintf(LOG_ERR, "%04d UNIX-domain FastCGI sockets not supported (yet)", client_sock);
// UNIX-domain socket
struct sockaddr_un addr;
socklen_t addr_len;
sock = socket(AF_UNIX, SOCK_STREAM, 0);
if (sock == INVALID_SOCKET) {
lprintf(LOG_ERR, "%04d ERROR creating UNIX domain FastCGI socket", client_sock);
free(path);
return INVALID_SOCKET;
return sock;
}
addr.sun_family = AF_UNIX;
SAFECOPY(addr.sun_path, path + 5);
#ifdef SUN_LEN
addr_len = SUN_LEN(&addr);
#else
addr_len = sizeof(addr);
#endif
if(connect(sock, (struct sockaddr*)&addr, addr_len) != 0) {
lprintf(LOG_ERR, "%04d ERROR %d connecting to UNIX domain FastCGI socket: %s"
,client_sock, ERROR_VALUE, addr.sun_path);
closesocket(sock);
sock = INVALID_SOCKET;
}
} else {
// TCP Socket
char *port = split_port_part(path);
struct addrinfo hints,*res,*cur;
memset(&hints, 0, sizeof(hints));
hints.ai_socktype = SOCK_STREAM;
hints.ai_flags = AI_ADDRCONFIG;
......@@ -3971,6 +3988,7 @@ static SOCKET fastcgi_connect(const char *orig_path, SOCKET client_sock)
}
freeaddrinfo(res);
}
if(sock == INVALID_SOCKET) {
lprintf(LOG_ERR, "%04d ERROR unable to make FastCGI connection to %s", client_sock, orig_path);
free(path);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment