gaim/gaim

Parents ef6ac96351d1
Children 654e33c9fb7c
This will prevent the connection process from hanging when the DNS lookup fails. We need to call the callback function regardless of whether the lookup succeeded. (This is in the DNS lookup functionality that is currently #ifdef _WIN32, but is actually portable),
  • +16 -12
    src/proxy.c
  • --- a/src/proxy.c Mon Jan 31 23:30:14 2005 -0500
    +++ b/src/proxy.c Mon Jan 31 23:54:25 2005 -0500
    @@ -650,8 +650,12 @@
    static gboolean dns_main_thread_cb(gpointer data) {
    dns_tdata *td = (dns_tdata*)data;
    + if (td->errmsg != NULL) {
    + gaim_debug_info("dns", "%s\n", td->errmsg);
    + }
    td->callback(td->hosts, td->data, td->errmsg);
    g_free(td->hostname);
    + g_free(td->errmsg);
    g_free(td);
    return FALSE;
    }
    @@ -661,22 +665,22 @@
    dns_tdata *td = (dns_tdata*)data;
    struct hostent *hp;
    - if(!(hp = gethostbyname(td->hostname)))
    - goto failure;
    - memset(&sin, 0, sizeof(struct sockaddr_in));
    - memcpy(&sin.sin_addr.s_addr, hp->h_addr, hp->h_length);
    - sin.sin_family = hp->h_addrtype;
    - sin.sin_port = htons(td->port);
    + if ((hp = gethostbyname(td->hostname))) {
    + memset(&sin, 0, sizeof(struct sockaddr_in));
    + memcpy(&sin.sin_addr.s_addr, hp->h_addr, hp->h_length);
    + sin.sin_family = hp->h_addrtype;
    + sin.sin_port = htons(td->port);
    - td->hosts = g_slist_append(td->hosts, GINT_TO_POINTER(sizeof(sin)));
    - td->hosts = g_slist_append(td->hosts, g_memdup(&sin, sizeof(sin)));
    + td->hosts = g_slist_append(td->hosts,
    + GINT_TO_POINTER(sizeof(sin)));
    + td->hosts = g_slist_append(td->hosts,
    + g_memdup(&sin, sizeof(sin)));
    + } else {
    + td->errmsg = g_strdup_printf("DNS error: %d", errno);
    + }
    /* back to main thread */
    g_idle_add(dns_main_thread_cb, td);
    return 0;
    - failure:
    - g_free(td->hostname);
    - g_free(td);
    - return 0;
    }
    int gaim_gethostbyname_async(const char *hostname, int port,