Skip to content

Commit

Permalink
Avoid using DNS lookup for base server if possible.
Browse files Browse the repository at this point in the history
The config can specify a hardcoded IP address now.

This means glibc doesn't have to load an extra shared library, reducing
 memory footprint by 192 kilobytes.
  • Loading branch information
icculus committed Oct 12, 2008
1 parent caed808 commit b535423
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
5 changes: 3 additions & 2 deletions nph-offload.c
Expand Up @@ -95,6 +95,7 @@
* -DGDEBUGDIR='"/home/icculus/offload2.icculus.org/logs"' \
* -DSHM_NAME='"mod-offload-offload2-icculus-org"' \
* -DGBASESERVER='"icculus.org"' \
* -DGBASESERVERIP='"67.106.77.212"' \
* -DGLISTENPORT=9090 \
* -DGLISTENDAEMONIZE=1 \
* -DGLISTENTRUSTFWD='"127.0.0.1", "66.33.209.154"' \
Expand Down Expand Up @@ -125,7 +126,7 @@
#include <netinet/in.h>
#include <arpa/inet.h>

#define GVERSION "1.1.5"
#define GVERSION "1.1.6"
#define GSERVERSTRING "nph-offload.c/" GVERSION

#include "offload_server_config.h"
Expand Down Expand Up @@ -1061,7 +1062,7 @@ static int doHttp(const char *method, list **headers)
hints.ai_flags = AI_NUMERICSERV | AI_V4MAPPED | AI_ALL | AI_ADDRCONFIG;

struct addrinfo *dns = NULL;
if ((rc = getaddrinfo(GBASESERVER, GBASESERVERPORTSTR, &hints, &dns)) != 0)
if ((rc = getaddrinfo(GBASESERVERIP, GBASESERVERPORTSTR, &hints, &dns)) != 0)
{
debugEcho("getaddrinfo failure: %s", gai_strerror(rc));
failure("503 Service Unavailable", "Offload base server hostname lookup failure.");
Expand Down
12 changes: 11 additions & 1 deletion offload_server_config.h
Expand Up @@ -69,11 +69,21 @@
#define GLOGFILE "/usr/local/apache/logs/access.log"
#endif

// This is a list of servers that you are offloading.
// This is the server that you are offloading's hostname.
#ifndef GBASESERVER
#define GBASESERVER "example.com"
#endif

// This is the server that you are offloading's IP address.
// We use this for DNS lookups (GBASESERVER is used for the "Host:" field in
// HTTP requests, etc). If you know the IP address will never change, you can
// save the several hundred kilobytes of address space that glibc uses...it
// loads a separate shared library for the DNS lookup, but it doesn't need
// to if GBASESERVERIP is an IP address in "xxx.xxx.xxx.xxx" format.
#ifndef GBASESERVERIP
#define GBASESERVERIP GBASESERVER
#endif

// This is the port on the base server to connect to (default for HTTP is 80).
#ifndef GBASESERVERPORT
#define GBASESERVERPORT 80
Expand Down

0 comments on commit b535423

Please sign in to comment.