Compare commits

..
3 Commits
2 changed files with 12 additions and 6 deletions

No files matched your search

+5 -3
View File
@@ -456,19 +456,21 @@ int resolve_split_name(struct addrinfo **out, const char* ct_host, const char* s
struct addrinfo hint;
char *end;
int res;
char* host;
char* host, *host_base;
memset(&hint, 0, sizeof(hint));
hint.ai_family = PF_UNSPEC;
hint.ai_socktype = SOCK_STREAM;
/* Copy parameter so not to clobber data in libconfig */
res = asprintf(&host, "%s", ct_host);
res = asprintf(&host_base, "%s", ct_host);
if (res == -1) {
log_message(LOG_ERR, "asprintf: cannot allocate memory");
return -1;
}
host = host_base;
/* If it is a RFC-Compliant IPv6 address ("[1234::12]:443"), remove brackets
* around IP address */
if (host[0] == '[') {
@@ -483,7 +485,7 @@ int resolve_split_name(struct addrinfo **out, const char* ct_host, const char* s
res = getaddrinfo(host, serv, &hint, out);
if (res)
log_message(LOG_ERR, "%s `%s:%s'\n", gai_strerror(res), host, serv);
free(host);
free(host_base);
return res;
}
+7 -3
View File
@@ -150,11 +150,11 @@ void main_loop(int listen_sockets[], int num_addr_listen)
for (i = 0; i < num_addr_listen; i++) {
listener_pid[i] = fork();
switch(listener_pid[i]) {
case 0: break;
// Log if fork() fails for some reason
case -1: log_message(LOG_ERR, "fork failed: err %d: %s\n", errno, strerror(errno));
break;
default:
// We're in the child, we have work to do
case 0:
/* Listening process just accepts a connection, forks, and goes
* back to listening */
while (1)
@@ -178,6 +178,10 @@ void main_loop(int listen_sockets[], int num_addr_listen)
}
close(in_socket);
}
break;
// We're in the parent, we don't need to do anything
default:
break;
}
}