summaryrefslogtreecommitdiff
path: root/protocols/Gadu-Gadu/src/libgadu/resolver.cpp
diff options
context:
space:
mode:
authorGoraf <22941576+Goraf@users.noreply.github.com>2018-01-18 17:57:36 +0100
committerGoraf <22941576+Goraf@users.noreply.github.com>2018-01-19 01:39:33 +0100
commitfb40ed2b6385b9e3a85b35ba27f3a42207d22234 (patch)
tree9de6415c9c28c68d2fe750abe2c95c3a89ba08ca /protocols/Gadu-Gadu/src/libgadu/resolver.cpp
parent97bb7e79c15952e7f9bf47caef4e3c09dd63c8df (diff)
Gadu-Gadu: update libgadu to 1.11.4
Diffstat (limited to 'protocols/Gadu-Gadu/src/libgadu/resolver.cpp')
-rw-r--r--protocols/Gadu-Gadu/src/libgadu/resolver.cpp30
1 files changed, 17 insertions, 13 deletions
diff --git a/protocols/Gadu-Gadu/src/libgadu/resolver.cpp b/protocols/Gadu-Gadu/src/libgadu/resolver.cpp
index 065169007f..b8972f26d1 100644
--- a/protocols/Gadu-Gadu/src/libgadu/resolver.cpp
+++ b/protocols/Gadu-Gadu/src/libgadu/resolver.cpp
@@ -63,7 +63,6 @@ static void (*gg_global_resolver_cleanup)(void **private_data, int force);
#include <pthread.h>
-#ifdef GG_CONFIG_HAVE_GETHOSTBYNAME_R
/**
* \internal Funkcja pomocnicza zwalniająca zasoby po rozwiązywaniu nazwy
* w wątku.
@@ -79,7 +78,7 @@ static void gg_gethostbyname_cleaner(void *data)
*buf_ptr = NULL;
}
}
-#endif
+
#endif /* GG_CONFIG_HAVE_PTHREAD */
/**
@@ -244,7 +243,7 @@ int gg_gethostbyname_real(const char *hostname, struct in_addr **result, int *co
/* Kopiuj */
for (i = 0; he->h_addr_list[i] != NULL; i++)
- memcpy(&((*result)[i]), he->h_addr_list[0], sizeof(struct in_addr));
+ memcpy(&((*result)[i]), he->h_addr_list[i], sizeof(struct in_addr));
(*result)[i].s_addr = INADDR_NONE;
@@ -257,22 +256,24 @@ int gg_gethostbyname_real(const char *hostname, struct in_addr **result, int *co
/**
* \internal Rozwiązuje nazwę i zapisuje wynik do podanego desktyptora.
*
+ * \note Użycie logowania w tej funkcji może mieć negatywny wpływ na
+ * aplikacje jednowątkowe korzystające.
+ *
* \param fd Deskryptor
* \param hostname Nazwa serwera
*
* \return 0 jeśli się powiodło, -1 w przypadku błędu
*/
-int gg_resolver_run(int fd, const char *hostname)
+static int gg_resolver_run(int fd, const char *hostname)
{
struct in_addr addr_ip[2], *addr_list;
int addr_count;
int res = 0;
- gg_debug(GG_DEBUG_MISC, "// gg_resolver_run(%d, %s)\n", fd, hostname);
-
if ((addr_ip[0].s_addr = inet_addr(hostname)) == INADDR_NONE) {
if (gg_gethostbyname_real(hostname, &addr_list, &addr_count, 1) == -1) {
addr_list = addr_ip;
+ addr_count = 0;
/* addr_ip[0] już zawiera INADDR_NONE */
}
} else {
@@ -281,8 +282,6 @@ int gg_resolver_run(int fd, const char *hostname)
addr_count = 1;
}
- gg_debug(GG_DEBUG_MISC, "// gg_resolver_run() count = %d\n", addr_count);
-
if (write(fd, addr_list, (addr_count + 1) * sizeof(struct in_addr)) != (addr_count + 1) * sizeof(struct in_addr))
res = -1;
@@ -374,12 +373,17 @@ static int gg_resolver_fork_start(SOCKET *fd, void **priv_data, const char *host
}
if (data->pid == 0) {
+ int status;
+
gg_sock_close(pipes[0]);
- if (gg_resolver_run(pipes[1], hostname) == -1)
- exit(1);
- else
- exit(0);
+ status = (gg_resolver_run(pipes[1], hostname) == -1) ? 1 : 0;
+
+#ifdef HAVE__EXIT
+ _exit(status);
+#else
+ exit(status);
+#endif
}
gg_sock_close(pipes[1]);
@@ -411,7 +415,7 @@ cleanup:
* danych
* \param force Flaga usuwania zasobów przed zakończeniem działania
*/
-void gg_resolver_fork_cleanup(void **priv_data, int force)
+static void gg_resolver_fork_cleanup(void **priv_data, int force)
{
struct gg_resolver_fork_data *data;