162 |
162 |
* if host is one of the local IP adresses the
|
163 |
163 |
* whole connection is local
|
164 |
164 |
*
|
165 |
|
* if tcp/ip should be used host AND port have
|
166 |
|
* to be specified
|
|
165 |
* if port is not 0, and host is not specified,
|
|
166 |
* "localhost" (INADDR_LOOPBACK) is assumed.
|
167 |
167 |
*
|
168 |
168 |
*/
|
169 |
169 |
buffer *host;
|
... | ... | |
823 |
823 |
fcgi_addr_in.sin_family = AF_INET;
|
824 |
824 |
|
825 |
825 |
if (buffer_is_empty(host->host)) {
|
826 |
|
fcgi_addr_in.sin_addr.s_addr = htonl(INADDR_ANY);
|
|
826 |
fcgi_addr_in.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
|
827 |
827 |
} else {
|
828 |
828 |
struct hostent *he;
|
829 |
829 |
|
830 |
830 |
/* set a useful default */
|
831 |
|
fcgi_addr_in.sin_addr.s_addr = htonl(INADDR_ANY);
|
|
831 |
fcgi_addr_in.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
|
832 |
832 |
|
833 |
833 |
|
834 |
834 |
if (NULL == (he = gethostbyname(host->host->ptr))) {
|
... | ... | |
858 |
858 |
fcgi_addr = (struct sockaddr *) &fcgi_addr_in;
|
859 |
859 |
|
860 |
860 |
buffer_copy_string(proc->connection_name, "tcp:");
|
861 |
|
buffer_append_string_buffer(proc->connection_name, host->host);
|
|
861 |
if (!buffer_is_empty(host->host)) {
|
|
862 |
buffer_append_string_buffer(proc->connection_name, host->host);
|
|
863 |
} else {
|
|
864 |
buffer_append_string(proc->connection_name, "localhost");
|
|
865 |
}
|
862 |
866 |
buffer_append_string(proc->connection_name, ":");
|
863 |
867 |
buffer_append_long(proc->connection_name, proc->port);
|
864 |
868 |
}
|
... | ... | |
1687 |
1691 |
#endif
|
1688 |
1692 |
} else {
|
1689 |
1693 |
fcgi_addr_in.sin_family = AF_INET;
|
1690 |
|
if (0 == inet_aton(host->host->ptr, &(fcgi_addr_in.sin_addr))) {
|
1691 |
|
log_error_write(srv, __FILE__, __LINE__, "sbs",
|
1692 |
|
"converting IP address failed for", host->host,
|
1693 |
|
"\nBe sure to specify an IP address here");
|
1694 |
|
|
1695 |
|
return -1;
|
|
1694 |
if (!buffer_is_empty(host->host)) {
|
|
1695 |
if (0 == inet_aton(host->host->ptr, &(fcgi_addr_in.sin_addr))) {
|
|
1696 |
log_error_write(srv, __FILE__, __LINE__, "sbs",
|
|
1697 |
"converting IP address failed for", host->host,
|
|
1698 |
"\nBe sure to specify an IP address here");
|
|
1699 |
|
|
1700 |
return -1;
|
|
1701 |
}
|
|
1702 |
} else {
|
|
1703 |
fcgi_addr_in.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
|
1696 |
1704 |
}
|
1697 |
1705 |
fcgi_addr_in.sin_port = htons(proc->port);
|
1698 |
1706 |
servlen = sizeof(fcgi_addr_in);
|
... | ... | |
1702 |
1710 |
if (buffer_is_empty(proc->connection_name)) {
|
1703 |
1711 |
/* on remote spawing we have to set the connection-name now */
|
1704 |
1712 |
buffer_copy_string(proc->connection_name, "tcp:");
|
1705 |
|
buffer_append_string_buffer(proc->connection_name, host->host);
|
|
1713 |
if (!buffer_is_empty(host->host)) {
|
|
1714 |
buffer_append_string_buffer(proc->connection_name, host->host);
|
|
1715 |
} else {
|
|
1716 |
buffer_append_string(proc->connection_name, "localhost");
|
|
1717 |
}
|
1706 |
1718 |
buffer_append_string(proc->connection_name, ":");
|
1707 |
1719 |
buffer_append_long(proc->connection_name, proc->port);
|
1708 |
1720 |
}
|
... | ... | |
2719 |
2731 |
|
2720 |
2732 |
int ret;
|
2721 |
2733 |
|
2722 |
|
/* sanity check */
|
|
2734 |
/* sanity check:
|
|
2735 |
* - host != NULL
|
|
2736 |
* - either:
|
|
2737 |
* - tcp socket (do not check host->host->uses, as it may be not set which means INADDR_LOOPBACK)
|
|
2738 |
* - unix socket
|
|
2739 |
*/
|
2723 |
2740 |
if (!host ||
|
2724 |
|
((!host->host->used || !host->port) && !host->unixsocket->used)) {
|
|
2741 |
(!host->port && !host->unixsocket->used)) {
|
2725 |
2742 |
log_error_write(srv, __FILE__, __LINE__, "sxddd",
|
2726 |
2743 |
"write-req: error",
|
2727 |
2744 |
host,
|