free(newproc->hostname);
}
newproc->hostname = strdup(hostname);
- if (lookup_hostname_list(hostname)) {
+ if (is_hostname_filtered(hostname)) {
add_filter_tid_list(tid, newproc);
}
}
}
if (hostname && !proc->hostname) {
proc->hostname = strdup(hostname);
- if (lookup_hostname_list(hostname)) {
+ if (is_hostname_filtered(hostname)) {
add_filter_tid_list(tid, proc);
}
}
return g_hash_table_lookup(tid_filter_list, (gpointer) &tid);
}
-char *lookup_hostname_list(const char *hostname)
+struct host *lookup_hostname_list(const char *hostname)
{
- if (!hostname || !hostname_filter_list)
+ if (!hostname || !global_host_list)
return NULL;
- return g_hash_table_lookup(hostname_filter_list, (gpointer) hostname);
+ return g_hash_table_lookup(global_host_list, (gpointer) hostname);
}
-void remove_hostname_list(const char *hostname)
+int is_hostname_filtered(const char *hostname)
{
- if (!hostname || !hostname_filter_list)
- return;
+ struct host *host;
- g_hash_table_remove(hostname_filter_list, (gpointer) hostname);
+ host = lookup_hostname_list(hostname);
+ if (host)
+ return host->filter;
+ return 0;
}
int *lookup_filter_tid_list(int tid)
GPtrArray *copies; /* struct lttngtop */
GHashTable *global_perf_liszt;
GHashTable *global_filter_list;
+GHashTable *global_host_list;
char *opt_tid;
char *opt_hostname;
char *opt_kprobes;
GHashTable *tid_filter_list;
-GHashTable *hostname_filter_list;
int toggle_filter;
int *lookup_filter_tid_list(int tid);
int *lookup_tid_list(int tid);
-char *lookup_hostname_list(const char *hostname);
void remove_hostname_list(const char *hostname);
void add_filter_tid_list(int tid, struct processtop *newproc);
void remove_filter_tid_list(int tid);
+struct host *lookup_hostname_list(const char *hostname);
+int is_hostname_filtered(const char *hostname);
#endif /* _COMMON_H */
copies = g_ptr_array_new();
global_perf_liszt = g_hash_table_new(g_str_hash, g_str_equal);
global_filter_list = g_hash_table_new(g_str_hash, g_str_equal);
+ global_host_list = g_hash_table_new(g_str_hash, g_str_equal);
sem_init(&goodtodisplay, 0, 0);
sem_init(&goodtoupdate, 0, 1);
break;
case OPT_HOSTNAME:
toggle_filter = 1;
- hostname_filter_list = g_hash_table_new(g_str_hash,
- g_str_equal);
tmp_str = strtok(opt_hostname, ",");
while (tmp_str) {
- char *new_str = strdup(tmp_str);
- g_hash_table_insert(hostname_filter_list,
- (gpointer) new_str,
- (gpointer) new_str);
+// char *new_str = strdup(tmp_str);
+ struct host *host;
+
+ host = g_new0(struct host, 1);
+ host->hostname = strdup(tmp_str);
+ host->filter = 1;
+ g_hash_table_insert(global_host_list,
+ (gpointer) host->hostname,
+ (gpointer) host);
tmp_str = strtok(NULL, ",");
}
break;
int count;
};
-struct hosts {
+struct host {
char *hostname;
+ int filter;
};
#endif /* LTTNGTOPTYPES_H */