mirror of
https://github.com/Llewellynvdm/conky.git
synced 2025-02-04 21:18:33 +00:00
Fixed crash caused by temporary virtual net interfaces (#479)
* Fixed crash caused by temporary virtual net interfaces * Restored original identation
This commit is contained in:
parent
128c8cce34
commit
1410bac6aa
@ -69,6 +69,7 @@ static conky::simple_config_setting<if_up_strictness_> if_up_strictness("if_up_s
|
||||
* global array of structs containing network statistics for each interface
|
||||
**/
|
||||
struct net_stat netstats[MAX_NET_INTERFACES];
|
||||
struct net_stat foo_netstats;
|
||||
|
||||
/**
|
||||
* Returns pointer to specified interface in netstats array.
|
||||
@ -105,8 +106,13 @@ struct net_stat *get_net_stat(const char *dev, void *free_at_crash1, void *free_
|
||||
}
|
||||
}
|
||||
|
||||
CRIT_ERR(free_at_crash1, free_at_crash2, "too many interfaces used (limit is %d)", MAX_NET_INTERFACES);
|
||||
return 0;
|
||||
clear_net_stats(&foo_netstats);
|
||||
foo_netstats.dev = strndup(dev, text_buffer_size.get(*state));
|
||||
/* initialize last_read_recv and last_read_trans to -1 denoting
|
||||
* that they were never read before */
|
||||
foo_netstats.last_read_recv = -1;
|
||||
foo_netstats.last_read_trans = -1;
|
||||
return &foo_netstats;
|
||||
}
|
||||
|
||||
void parse_net_stat_arg(struct text_object *obj, const char *arg, void *free_at_crash)
|
||||
@ -477,6 +483,20 @@ void clear_net_stats(void)
|
||||
memset(netstats, 0, sizeof(netstats));
|
||||
}
|
||||
|
||||
void clear_net_stats(net_stat *in) {
|
||||
#ifdef BUILD_IPV6
|
||||
struct v6addr *nextv6;
|
||||
#endif /* BUILD_IPV6 */
|
||||
free_and_zero(in->dev);
|
||||
#ifdef BUILD_IPV6
|
||||
while (in->v6addrs) {
|
||||
nextv6 = in->v6addrs;
|
||||
in->v6addrs = in->v6addrs->next;
|
||||
free_and_zero(nextv6);
|
||||
}
|
||||
#endif /* BUILD_IPV6 */
|
||||
}
|
||||
|
||||
void parse_if_up_arg(struct text_object *obj, const char *arg)
|
||||
{
|
||||
obj->data.opaque = strndup(arg, text_buffer_size.get(*state));
|
||||
|
@ -120,6 +120,7 @@ double wireless_link_barval(struct text_object *);
|
||||
#endif /* BUILD_WLAN */
|
||||
|
||||
void clear_net_stats(void);
|
||||
void clear_net_stats(net_stat*);
|
||||
|
||||
void parse_if_up_arg(struct text_object *, const char *);
|
||||
int interface_up(struct text_object *);
|
||||
|
Loading…
x
Reference in New Issue
Block a user