pid = Proc_Fork(s, pipefd, cbfunc, RESOLVER_TIMEOUT);
if (pid > 0) {
/* Main process */
-#ifdef DEBUG
Log( LOG_DEBUG, "Resolver for \"%s\" created (PID %d).", Host, pid );
-#endif
return true;
} else if( pid == 0 ) {
/* Sub process */
if (identsock < 0)
return;
-#ifdef DEBUG
Log_Subprocess(LOG_DEBUG, "Doing IDENT lookup on socket %d ...",
identsock);
-#endif
res = ident_id( identsock, 10 );
-#ifdef DEBUG
Log_Subprocess(LOG_DEBUG, "Ok, IDENT lookup on socket %d done: \"%s\"",
identsock, res ? res : "(NULL)");
-#endif
if (!res) /* no result */
return;
if (!array_cats(resolved_addr, res))
array_init(&resolved_addr);
ng_ipaddr_tostr_r(Addr, tmp_ip_str);
-#ifdef DEBUG
Log_Subprocess(LOG_DEBUG, "Now resolving %s ...", tmp_ip_str);
-#endif
if (!ReverseLookup(Addr, hostname, sizeof(hostname)))
goto dns_done;
Log_Forgery_NoIP(tmp_ip_str, hostname);
strlcpy(hostname, tmp_ip_str, sizeof(hostname));
}
-#ifdef DEBUG
Log_Subprocess(LOG_DEBUG, "Ok, translated %s to \"%s\".", tmp_ip_str, hostname);
-#endif
dns_done:
len = strlen(hostname);
hostname[len] = '\n';
* to parent. */
array IpAddrs;
int af;
-#ifdef DEBUG
ng_ipaddr_t *addr;
size_t len;
-#endif
Log_Subprocess(LOG_DEBUG, "Now resolving \"%s\" ...", Host);
array_init(&IpAddrs);
close(w_fd);
return;
}
-#ifdef DEBUG
len = array_length(&IpAddrs, sizeof(*addr));
assert(len > 0);
addr = array_start(&IpAddrs);
Log_Subprocess(LOG_DEBUG, "translated \"%s\" to %s.",
Host, ng_ipaddr_tostr(addr));
}
-#endif
/* Write result into pipe to parent */
ArrayWrite(w_fd, &IpAddrs);