Re: [systemd-devel] [PATCH] sd-dhcp-client: prevent timer related memory leaks
On 21 Feb 2014 03:22, Lennart Poettering lenn...@poettering.net wrote: On Thu, 20.02.14 21:04, Umut Tezduyar Lindskog (umut.tezdu...@axis.com) wrote: Tom commited this. Thanks! Tom, please always do a quick reply on the ML so that it is easy to see what is commited and what is not! Sorry about that. It seems my reply only went to Umut and not the ML... Thanks! --- src/libsystemd-dhcp/sd-dhcp-client.c |4 1 file changed, 4 insertions(+) diff --git a/src/libsystemd-dhcp/sd-dhcp-client.c b/src/libsystemd-dhcp/sd-dhcp-client.c index ec2b53f..53abe22 100644 --- a/src/libsystemd-dhcp/sd-dhcp-client.c +++ b/src/libsystemd-dhcp/sd-dhcp-client.c @@ -392,6 +392,8 @@ static int client_timeout_resend(sd_event_source *s, uint64_t usec, next_timeout += (random_u32() 0x1f); +client-timeout_resend = sd_event_source_unref(client-timeout_resend); + r = sd_event_add_monotonic(client-event, client-timeout_resend, next_timeout, @@ -477,6 +479,8 @@ static int client_initialize_events(sd_dhcp_client *client, if (r 0) goto error; +client-timeout_resend = sd_event_source_unref(client-timeout_resend); + r = sd_event_add_monotonic(client-event, client-timeout_resend, usec, 0, Lennart -- Lennart Poettering, Red Hat ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
[systemd-devel] [PATCH] sd-dhcp-client: prevent timer related memory leaks
--- src/libsystemd-dhcp/sd-dhcp-client.c |6 ++ 1 file changed, 6 insertions(+) diff --git a/src/libsystemd-dhcp/sd-dhcp-client.c b/src/libsystemd-dhcp/sd-dhcp-client.c index ec2b53f..84d38f0 100644 --- a/src/libsystemd-dhcp/sd-dhcp-client.c +++ b/src/libsystemd-dhcp/sd-dhcp-client.c @@ -392,6 +392,9 @@ static int client_timeout_resend(sd_event_source *s, uint64_t usec, next_timeout += (random_u32() 0x1f); +if (client-timeout_resend) +client-timeout_resend = sd_event_source_unref(client-timeout_resend); + r = sd_event_add_monotonic(client-event, client-timeout_resend, next_timeout, @@ -477,6 +480,9 @@ static int client_initialize_events(sd_dhcp_client *client, if (r 0) goto error; +if (client-timeout_resend) +client-timeout_resend = sd_event_source_unref(client-timeout_resend); + r = sd_event_add_monotonic(client-event, client-timeout_resend, usec, 0, -- 1.7.10.4 ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] [PATCH] sd-dhcp-client: prevent timer related memory leaks
On Thu, 20.02.14 19:49, Umut Tezduyar Lindskog (umut.tezdu...@axis.com) wrote: --- src/libsystemd-dhcp/sd-dhcp-client.c |6 ++ 1 file changed, 6 insertions(+) diff --git a/src/libsystemd-dhcp/sd-dhcp-client.c b/src/libsystemd-dhcp/sd-dhcp-client.c index ec2b53f..84d38f0 100644 --- a/src/libsystemd-dhcp/sd-dhcp-client.c +++ b/src/libsystemd-dhcp/sd-dhcp-client.c @@ -392,6 +392,9 @@ static int client_timeout_resend(sd_event_source *s, uint64_t usec, next_timeout += (random_u32() 0x1f); +if (client-timeout_resend) +client-timeout_resend = sd_event_source_unref(client-timeout_resend); + You can drop the if check btw. We explicitly designed all our _unref() calls so that they are happy with a NULL argument and return NULL in that case... r = sd_event_add_monotonic(client-event, client-timeout_resend, next_timeout, @@ -477,6 +480,9 @@ static int client_initialize_events(sd_dhcp_client *client, if (r 0) goto error; +if (client-timeout_resend) +client-timeout_resend = sd_event_source_unref(client-timeout_resend); + r = sd_event_add_monotonic(client-event, client-timeout_resend, usec, 0, Lennart -- Lennart Poettering, Red Hat ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
[systemd-devel] [PATCH] sd-dhcp-client: prevent timer related memory leaks
--- src/libsystemd-dhcp/sd-dhcp-client.c |4 1 file changed, 4 insertions(+) diff --git a/src/libsystemd-dhcp/sd-dhcp-client.c b/src/libsystemd-dhcp/sd-dhcp-client.c index ec2b53f..53abe22 100644 --- a/src/libsystemd-dhcp/sd-dhcp-client.c +++ b/src/libsystemd-dhcp/sd-dhcp-client.c @@ -392,6 +392,8 @@ static int client_timeout_resend(sd_event_source *s, uint64_t usec, next_timeout += (random_u32() 0x1f); +client-timeout_resend = sd_event_source_unref(client-timeout_resend); + r = sd_event_add_monotonic(client-event, client-timeout_resend, next_timeout, @@ -477,6 +479,8 @@ static int client_initialize_events(sd_dhcp_client *client, if (r 0) goto error; +client-timeout_resend = sd_event_source_unref(client-timeout_resend); + r = sd_event_add_monotonic(client-event, client-timeout_resend, usec, 0, -- 1.7.10.4 ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] [PATCH] sd-dhcp-client: prevent timer related memory leaks
From: Lennart Poettering [lenn...@poettering.net] Sent: Thursday, February 20, 2014 8:38 PM To: Umut Tezduyar Lindskog Cc: systemd-devel@lists.freedesktop.org; Umut Tezduyar Lindskog Subject: Re: [systemd-devel] [PATCH] sd-dhcp-client: prevent timer related memory leaks On Thu, 20.02.14 19:49, Umut Tezduyar Lindskog (umut.tezdu...@axis.com) wrote: --- src/libsystemd-dhcp/sd-dhcp-client.c |6 ++ 1 file changed, 6 insertions(+) diff --git a/src/libsystemd-dhcp/sd-dhcp-client.c b/src/libsystemd-dhcp/sd-dhcp-client.c index ec2b53f..84d38f0 100644 --- a/src/libsystemd-dhcp/sd-dhcp-client.c +++ b/src/libsystemd-dhcp/sd-dhcp-client.c @@ -392,6 +392,9 @@ static int client_timeout_resend(sd_event_source *s, uint64_t usec, next_timeout += (random_u32() 0x1f); +if (client-timeout_resend) +client-timeout_resend = sd_event_source_unref(client-timeout_resend); + You can drop the if check btw. We explicitly designed all our _unref() calls so that they are happy with a NULL argument and return NULL in that case... Sure. I also thought about putting an assert on *ret in sd_event_add_monotonic once dhcp is fixed. r = sd_event_add_monotonic(client-event, client-timeout_resend, next_timeout, @@ -477,6 +480,9 @@ static int client_initialize_events(sd_dhcp_client *client, if (r 0) goto error; +if (client-timeout_resend) +client-timeout_resend = sd_event_source_unref(client-timeout_resend); + r = sd_event_add_monotonic(client-event, client-timeout_resend, usec, 0, Lennart -- Lennart Poettering, Red Hat ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] [PATCH] sd-dhcp-client: prevent timer related memory leaks
On Thu, 20.02.14 21:04, Umut Tezduyar Lindskog (umut.tezdu...@axis.com) wrote: Tom commited this. Thanks! Tom, please always do a quick reply on the ML so that it is easy to see what is commited and what is not! Thanks! --- src/libsystemd-dhcp/sd-dhcp-client.c |4 1 file changed, 4 insertions(+) diff --git a/src/libsystemd-dhcp/sd-dhcp-client.c b/src/libsystemd-dhcp/sd-dhcp-client.c index ec2b53f..53abe22 100644 --- a/src/libsystemd-dhcp/sd-dhcp-client.c +++ b/src/libsystemd-dhcp/sd-dhcp-client.c @@ -392,6 +392,8 @@ static int client_timeout_resend(sd_event_source *s, uint64_t usec, next_timeout += (random_u32() 0x1f); +client-timeout_resend = sd_event_source_unref(client-timeout_resend); + r = sd_event_add_monotonic(client-event, client-timeout_resend, next_timeout, @@ -477,6 +479,8 @@ static int client_initialize_events(sd_dhcp_client *client, if (r 0) goto error; +client-timeout_resend = sd_event_source_unref(client-timeout_resend); + r = sd_event_add_monotonic(client-event, client-timeout_resend, usec, 0, Lennart -- Lennart Poettering, Red Hat ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] [PATCH] sd-dhcp-client: prevent timer related memory leaks
-Original Message- From: Lennart Poettering [mailto:lenn...@poettering.net] Sent: den 21 februari 2014 03:22 To: Umut Tezduyar Lindskog Cc: systemd-devel@lists.freedesktop.org; Umut Tezduyar Lindskog Subject: Re: [systemd-devel] [PATCH] sd-dhcp-client: prevent timer related memory leaks On Thu, 20.02.14 21:04, Umut Tezduyar Lindskog (umut.tezdu...@axis.com) wrote: Tom commited this. Thanks! Tom, please always do a quick reply on the ML so that it is easy to see what is commited and what is not! Thanks! Hi, actually he did but maybe there is an oversight. I kept track of it too :) Umut --- src/libsystemd-dhcp/sd-dhcp-client.c |4 1 file changed, 4 insertions(+) diff --git a/src/libsystemd-dhcp/sd-dhcp-client.c b/src/libsystemd-dhcp/sd-dhcp-client.c index ec2b53f..53abe22 100644 --- a/src/libsystemd-dhcp/sd-dhcp-client.c +++ b/src/libsystemd-dhcp/sd-dhcp-client.c @@ -392,6 +392,8 @@ static int client_timeout_resend(sd_event_source *s, uint64_t usec, next_timeout += (random_u32() 0x1f); +client-timeout_resend = + sd_event_source_unref(client-timeout_resend); + r = sd_event_add_monotonic(client-event, client-timeout_resend, next_timeout, @@ -477,6 +479,8 @@ static int client_initialize_events(sd_dhcp_client *client, if (r 0) goto error; +client-timeout_resend = + sd_event_source_unref(client-timeout_resend); + r = sd_event_add_monotonic(client-event, client-timeout_resend, usec, 0, Lennart -- Lennart Poettering, Red Hat ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel