Skip to content

Commit

Permalink
The first parameter (char *) of cherokee_gethostbyname() function
Browse files Browse the repository at this point in the history
has been replace by a much convenient cherokee_buffer_t* one.

git-svn-id: svn://cherokee-project.com/cherokee/trunk@6886 5dc97367-97f1-0310-9951-d761b3857238
  • Loading branch information
alobbs committed Oct 7, 2011
1 parent 231252b commit 4182717
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
2 changes: 1 addition & 1 deletion cherokee/resolv_cache.c
Expand Up @@ -97,7 +97,7 @@ entry_fill_up (cherokee_resolv_cache_entry_t *entry,
time_t eagain_at = 0;

while (true) {
ret = cherokee_gethostbyname (domain->buf, &entry->addr);
ret = cherokee_gethostbyname (domain, &entry->addr);
if (ret == ret_ok) {
break;

Expand Down
27 changes: 19 additions & 8 deletions cherokee/util.c
Expand Up @@ -757,7 +757,7 @@ cherokee_eval_formated_time (cherokee_buffer_t *buf)


ret_t
cherokee_gethostbyname (const char *hostname, struct addrinfo **addr)
cherokee_gethostbyname (cherokee_buffer_t *hostname, struct addrinfo **addr)
{
int n;
struct addrinfo hints;
Expand All @@ -768,21 +768,32 @@ cherokee_gethostbyname (const char *hostname, struct addrinfo **addr)

hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;

#ifdef AI_ADDRCONFIG
if ((strcmp(hostname, "127.0.0.1") != 0) &&
(strcmp(hostname, "localhost") != 0) &&
(strcmp(hostname, "localhost.localdomain") != 0) &&
(strcmp(hostname, "::1") != 0) &&
(strcmp(hostname, "localhost6") != 0) &&
(strcmp(hostname, "localhost6.localdomain6") != 0))
/* Workaround for loopback host addresses:
*
* If a computer does not have any outgoing IPv6 network
* interface, but its loopback network interface supports
* IPv6, a getaddrinfo call on "localhost" with AI_ADDRCONFIG
* won't return the IPv6 loopback address "::1", because
* getaddrinfo() thinks the computer cannot connect to any
* IPv6 destination, ignoring the remote vs. local/loopback
* distinction.
*/
if ((cherokee_buffer_cmp_str (hostname, "::1") == 0) ||
(cherokee_buffer_cmp_str (hostname, "127.0.0.1") == 0) ||
(cherokee_buffer_cmp_str (hostname, "localhost") == 0) ||
(cherokee_buffer_cmp_str (hostname, "localhost6") == 0) ||
(cherokee_buffer_cmp_str (hostname, "localhost.localdomain") == 0) ||
(cherokee_buffer_cmp_str (hostname, "localhost6.localdomain6") == 0))
{
hints.ai_flags = AI_ADDRCONFIG;
}
#endif

/* Resolve address
*/
n = getaddrinfo (hostname, NULL, &hints, addr);
n = getaddrinfo (hostname->buf, NULL, &hints, addr);
if (n < 0) {
return ret_error;
}
Expand Down
2 changes: 1 addition & 1 deletion cherokee/util.h
Expand Up @@ -161,7 +161,7 @@ int cherokee_open (const char *path, int oflag, int mode);
int cherokee_unlink (const char *path);
int cherokee_pipe (int fildes[2]);

ret_t cherokee_gethostbyname (const char *hostname, struct addrinfo **addr);
ret_t cherokee_gethostbyname (cherokee_buffer_t *hostname, struct addrinfo **addr);

ret_t cherokee_gethostname (cherokee_buffer_t *buf);
ret_t cherokee_syslog (int priority, cherokee_buffer_t *buf);
Expand Down

0 comments on commit 4182717

Please sign in to comment.