Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Kinnison/fix 879 #1043

Merged
merged 3 commits into from

2 participants

@kinnison
Collaborator

I believe this fixes #879.

The first patch corrects construction of ip_str_all in the resolv_cache entries.

The second brings in support for sources to iterate all the addresses returned from the resolv_cache.

The third causes interpreted sources to reset their address cycle if they spawn.

kinnison added some commits
@kinnison kinnison RESOLV_CACHE: Correct construction of ip_str_all
The construction of ip_str_all in the cache entries was incorrect,
repeating the first entry twice and failing to pass the correct family
in for subsequent entries.  This fixes both of these issues.

Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
222a0b6
@kinnison kinnison SOURCE: Cycle through addresses for a source
Since getaddrinfo() can return multiple addresses for a given name, this patch
allows a source to cycle through all of them should it get connection refused
errors.

Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
f8e90af
@kinnison kinnison SOURCE_INTERPRETER: Reset address cycle on spawn
If a source interpreter has to be spawned then reset the address cycle on the
source object so that it has a chance to try all possible addresses once more.

Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
ca0609f
@skinkie skinkie merged commit a94fbfd into cherokee:master
@kinnison kinnison deleted the kinnison:kinnison/fix_879 branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 27, 2013
  1. @kinnison

    RESOLV_CACHE: Correct construction of ip_str_all

    kinnison authored
    The construction of ip_str_all in the cache entries was incorrect,
    repeating the first entry twice and failing to pass the correct family
    in for subsequent entries.  This fixes both of these issues.
    
    Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
  2. @kinnison

    SOURCE: Cycle through addresses for a source

    kinnison authored
    Since getaddrinfo() can return multiple addresses for a given name, this patch
    allows a source to cycle through all of them should it get connection refused
    errors.
    
    Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
  3. @kinnison

    SOURCE_INTERPRETER: Reset address cycle on spawn

    kinnison authored
    If a source interpreter has to be spawned then reset the address cycle on the
    source object so that it has a chance to try all possible addresses once more.
    
    Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
This page is out of date. Refresh to see the latest.
View
4 cherokee/resolv_cache.c
@@ -135,9 +135,9 @@ entry_fill_up (cherokee_resolv_cache_entry_t *entry,
*/
cherokee_buffer_add_buffer (&entry->ip_str_all, &entry->ip_str);
- addr = entry->addr;
+ addr = entry->addr->ai_next;
while (addr != NULL) {
- ret = cherokee_ntop (entry->addr->ai_family, addr->ai_addr, tmp, sizeof(tmp));
+ ret = cherokee_ntop (addr->ai_family, addr->ai_addr, tmp, sizeof(tmp));
if (ret != ret_ok) {
return ret_error;
}
View
20 cherokee/source.c
@@ -79,9 +79,15 @@ cherokee_source_connect (cherokee_source_t *src, cherokee_socket_t *sock)
/* Short path: it's already connecting
*/
if (sock->socket >= 0) {
- return cherokee_socket_connect (sock);
+ ret = cherokee_socket_connect (sock);
+ if (ret != ret_deny || src->addr_current->ai_next == NULL)
+ return ret;
+ /* Fall through and attempt to try another address... */
+ cherokee_socket_close(sock);
+ src->addr_current = src->addr_current->ai_next;
}
+long_path:
/* Create the new socket and set the target IP info
*/
if (! cherokee_buffer_is_empty (&src->unix_socket)) {
@@ -195,7 +201,17 @@ cherokee_source_connect (cherokee_source_t *src, cherokee_socket_t *sock)
cherokee_fd_set_closexec (sock->socket);
cherokee_fd_set_reuseaddr (sock->socket);
- return cherokee_socket_connect (sock);
+ /* On the off-chance a connect completes early, handle a deny here
+ * in addition to at the top of this routine.
+ */
+ ret = cherokee_socket_connect (sock);
+ if (ret == ret_deny && src->addr_current->ai_next != NULL) {
+ src->addr_current = src->addr_current->ai_next;
+ cherokee_socket_close(sock);
+ goto long_path;
+ }
+
+ return ret;
}
View
5 cherokee/source_interpreter.c
@@ -681,6 +681,11 @@ cherokee_source_interpreter_spawn (cherokee_source_interpreter_t *src,
return ret;
}
+ /* Since we managed to spawn something, clear any current address
+ * in the source so that it can retry connecting from the top.
+ */
+ src->source.addr_current = NULL;
+
return ret_ok;
}
Something went wrong with that request. Please try again.