Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/allinurl/goaccess into my…
Browse files Browse the repository at this point in the history
…allin
  • Loading branch information
abgit committed Aug 27, 2013
2 parents 8b5d9a7 + d4016d7 commit 13261f8
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 44 deletions.
29 changes: 0 additions & 29 deletions gdashboard.c
Original file line number Diff line number Diff line change
Expand Up @@ -1234,35 +1234,6 @@ sort_sub_list (GHolder * h, GSort sort)
}
}

void
load_host_to_holder (GHolder * h, char *ip)
{
int idx = get_item_idx_in_holder (h, ip);
if (idx == -1)
return;

int hits = 0;
unsigned long long bw;

gpointer value_ptr;
GSubList *sub_list;

bw = h->items[idx].bw;
hits = h->items[idx].hits;
sub_list = h->items[idx].sub_list;

if (sub_list == NULL)
sub_list = new_gsublist ();

value_ptr = g_hash_table_lookup (ht_hostnames, ip);

if (value_ptr != NULL) {
add_sub_item_back (sub_list, HOSTS, (char *) value_ptr, hits, bw);
h->items[idx].sub_list = sub_list;
h->sub_items_size++;
}
}

/* load raw hash table's data into holder */
void
load_data_to_holder (GRawData * raw_data, GHolder * h, GModule module,
Expand Down
6 changes: 3 additions & 3 deletions gdns.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ dns_resolver (char *addr)
if (!gqueue_full (gdns_queue) && !gqueue_find (gdns_queue, addr)) {
g_hash_table_replace (ht_hostnames, g_strdup (addr), NULL);
gqueue_enqueue (gdns_queue, addr);
pthread_cond_broadcast (&gdns_thread.not_empty);
}
pthread_mutex_unlock (&gdns_thread.mutex);
}
Expand Down Expand Up @@ -202,10 +203,9 @@ dns_worker (void GO_UNUSED (*ptr_data))
break;
}

if (host != NULL && active_gdns) {
if (host != NULL && active_gdns)
g_hash_table_replace (ht_hostnames, g_strdup (ip), host);
allocate_hosts_holder (ip);
}

pthread_cond_signal (&gdns_thread.not_full);
pthread_mutex_unlock (&gdns_thread.mutex);
}
Expand Down
20 changes: 9 additions & 11 deletions goaccess.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,11 +217,6 @@ allocate_holder (void)
raw_data = parse_raw_data (ht, ht_size, module);
load_data_to_holder (raw_data, holder + module, module, sort[module]);
}

if (!conf.output_html && !conf.skip_resolver) {
active_gdns = 1;
gdns_thread_create ();
}
}

/* allocate memory for an instance of dashboard */
Expand Down Expand Up @@ -318,12 +313,6 @@ allocate_data ()
}
}

void
allocate_hosts_holder (char *ip)
{
load_host_to_holder (holder + HOSTS, ip);
}

/* render all windows */
void
render_screens (GLog * logger)
Expand Down Expand Up @@ -462,8 +451,12 @@ get_keys (GLog * logger)
}
reset_scroll_offsets (&scrolling);
scrolling.expanded = 1;

free_holder (&holder);
free_dashboard (dash);
allocate_holder ();
allocate_data ();

display_content (main_win, logger, dash, &scrolling);
break;
case KEY_DOWN:
Expand Down Expand Up @@ -830,6 +823,11 @@ main (int argc, char *argv[])
allocate_holder ();
allocate_data ();

if (!conf.skip_resolver) {
active_gdns = 1;
gdns_thread_create ();
}

render_screens (logger);
get_keys (logger);

Expand Down
1 change: 0 additions & 1 deletion goaccess.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,5 @@

extern int active_gdns; /* kill dns pthread flag */
void render_screens (void);
void allocate_hosts_holder (char *ip);

#endif

0 comments on commit 13261f8

Please sign in to comment.