Fixed resolver to not do any DNS resolution if dns_resolution == 0
This commit is contained in:
@@ -5,7 +5,8 @@ Attributions apply to all preceding items up to the next blank line.
|
||||
Unattributed items are by Paul Warren and Chris Lightfoot.
|
||||
|
||||
0.14
|
||||
|
||||
* Fixed DNS resolution so that no lookups are done if options.dns_resolution ==
|
||||
0
|
||||
* Configure/compilation fixes for Mac OS X
|
||||
|
||||
* MacOS interfaces to avoid by default
|
||||
|
||||
@@ -21,7 +21,7 @@ AC_CONFIG_AUX_DIR(config)
|
||||
AC_CANONICAL_SYSTEM
|
||||
|
||||
AM_CONFIG_HEADER(config.h)
|
||||
AM_INIT_AUTOMAKE(iftop, "0.13")
|
||||
AM_INIT_AUTOMAKE(iftop, "0.14pre2")
|
||||
|
||||
AC_DEFINE_UNQUOTED(IFTOP_VERSION, "$VERSION", [The iftop version number])
|
||||
|
||||
|
||||
50
resolver.c
50
resolver.c
@@ -19,6 +19,7 @@
|
||||
|
||||
#include "threadprof.h"
|
||||
|
||||
#include "options.h"
|
||||
|
||||
|
||||
#define RESOLVE_QUEUE_LENGTH 20
|
||||
@@ -33,6 +34,8 @@ hash_type* ns_hash;
|
||||
int head;
|
||||
int tail;
|
||||
|
||||
extern options_t options;
|
||||
|
||||
|
||||
/*
|
||||
* We have a choice of resolver methods. Real computers have getnameinfo or
|
||||
@@ -335,32 +338,35 @@ void resolve(struct in_addr* addr, char* result, int buflen) {
|
||||
char* hostname;
|
||||
int added = 0;
|
||||
|
||||
pthread_mutex_lock(&resolver_queue_mutex);
|
||||
if(options.dnsresolution == 1) {
|
||||
|
||||
if(hash_find(ns_hash, addr, (void**)&hostname) == HASH_STATUS_OK) {
|
||||
/* Found => already resolved, or on the queue */
|
||||
}
|
||||
else {
|
||||
hostname = strdup(inet_ntoa(*addr));
|
||||
hash_insert(ns_hash, addr, hostname);
|
||||
pthread_mutex_lock(&resolver_queue_mutex);
|
||||
|
||||
if(((head + 1) % RESOLVE_QUEUE_LENGTH) == tail) {
|
||||
/* queue full */
|
||||
if(hash_find(ns_hash, addr, (void**)&hostname) == HASH_STATUS_OK) {
|
||||
/* Found => already resolved, or on the queue */
|
||||
}
|
||||
else {
|
||||
resolve_queue[head] = *addr;
|
||||
head = (head + 1) % RESOLVE_QUEUE_LENGTH;
|
||||
added = 1;
|
||||
hostname = strdup(inet_ntoa(*addr));
|
||||
hash_insert(ns_hash, addr, hostname);
|
||||
|
||||
if(((head + 1) % RESOLVE_QUEUE_LENGTH) == tail) {
|
||||
/* queue full */
|
||||
}
|
||||
else {
|
||||
resolve_queue[head] = *addr;
|
||||
head = (head + 1) % RESOLVE_QUEUE_LENGTH;
|
||||
added = 1;
|
||||
}
|
||||
}
|
||||
pthread_mutex_unlock(&resolver_queue_mutex);
|
||||
|
||||
if(added == 1) {
|
||||
pthread_cond_signal(&resolver_queue_cond);
|
||||
}
|
||||
|
||||
if(result != NULL && buflen > 1) {
|
||||
strncpy(result, hostname, buflen - 1);
|
||||
result[buflen - 1] = '\0';
|
||||
}
|
||||
}
|
||||
pthread_mutex_unlock(&resolver_queue_mutex);
|
||||
|
||||
if(added == 1) {
|
||||
pthread_cond_signal(&resolver_queue_cond);
|
||||
}
|
||||
|
||||
if(result != NULL && buflen > 1) {
|
||||
strncpy(result, hostname, buflen - 1);
|
||||
result[buflen - 1] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user