diff options
author | Natanael Copa <ncopa@alpinelinux.org> | 2012-03-12 22:17:11 +0100 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2012-03-12 22:17:11 +0100 |
commit | b29539a9bbe9f328ec0dedfad2cc8efe8b344550 (patch) | |
tree | 0b892633a8754bda8db508e3eb5ec7cec85949f3 /pingu_ping.c | |
parent | 87c79f99b6b2ce6895116c3bf9e5a8d28ff5b322 (diff) | |
download | pingu-b29539a9bbe9f328ec0dedfad2cc8efe8b344550.tar.bz2 pingu-b29539a9bbe9f328ec0dedfad2cc8efe8b344550.tar.xz |
pingu_ping: always stop ev_timer when free
This should fix a memory leak
Diffstat (limited to 'pingu_ping.c')
-rw-r--r-- | pingu_ping.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/pingu_ping.c b/pingu_ping.c index 43a25ab..3eb413d 100644 --- a/pingu_ping.c +++ b/pingu_ping.c @@ -29,15 +29,21 @@ static int pingu_ping_get_seq(void) return seq; } +static void pingu_ping_free(struct ev_loop *loop, struct pingu_ping *ping) +{ + list_del(&ping->ping_list_entry); + ev_timer_stop(loop, &ping->timeout_watcher); + pingu_host_verify_status(loop, ping->host); + free(ping); +} + static void pingu_ping_timeout_cb(struct ev_loop *loop, ev_timer *w, int revents) { struct pingu_ping *ping = container_of(w, struct pingu_ping, timeout_watcher); log_debug("%s: seq %i (%i/%i) timed out", ping->host->label, ping->seq, ping->host->burst.pings_sent, ping->host->max_retries); - list_del(&ping->ping_list_entry); - pingu_host_verify_status(loop, ping->host); - free(ping); + pingu_ping_free(loop, ping); } static struct pingu_ping *pingu_ping_add(struct ev_loop *loop, @@ -79,10 +85,7 @@ static void pingu_ping_handle_reply(struct ev_loop *loop, log_debug("%s: got seq %i (%i/%i)", ping->host->label, ping->seq, ping->host->burst.pings_replied, ping->host->required_replies); - list_del(&ping->ping_list_entry); - ev_timer_stop(loop, &ping->timeout_watcher); - pingu_host_verify_status(loop, ping->host); - free(ping); + pingu_ping_free(loop, ping); } int pingu_ping_send(struct ev_loop *loop, struct pingu_host *host, |