sd-dhcp-client: refactor client_{free,new}

Make them more simiar to sd_bus and friends. Also factor out the event attachment. In the future,
we will likely want to support external main-loops, so this is a first step. For the time being,
we are still requiring an sd_event to be attached though.
This commit is contained in:
Tom Gundersen
2014-01-18 19:32:45 +01:00
parent 35bbea48dc
commit b25ef18b33
4 changed files with 133 additions and 35 deletions
+7 -3
View File
@@ -588,9 +588,13 @@ static int link_acquire_conf(Link *link) {
assert(link->manager->event);
if (!link->dhcp) {
link->dhcp = sd_dhcp_client_new(link->manager->event);
if (!link->dhcp)
return -ENOMEM;
r = sd_dhcp_client_new(&link->dhcp);
if (r < 0)
return r;
r = sd_dhcp_client_attach_event(link->dhcp, NULL, 0);
if (r < 0)
return r;
r = sd_dhcp_client_set_index(link->dhcp, link->ifindex);
if (r < 0)