[systemd-commits] src/libsystemd-network

Tom Gundersen tomegun at kemper.freedesktop.org
Tue May 6 14:01:12 PDT 2014


 src/libsystemd-network/sd-dhcp-client.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

New commits:
commit 22fc2420b2a7220addcee33c2fa17ada44d87f9c
Author: Tom Gundersen <teg at jklm.no>
Date:   Tue May 6 22:59:22 2014 +0200

    sd-dhcp-client: use asynchronous_close()
    
    close() is a blocking call, which may slow things down measurably when running many dhcp
    clients in the same single-threaded main loop. Let's just use the asynchronous version
    instead to avoid the problem.

diff --git a/src/libsystemd-network/sd-dhcp-client.c b/src/libsystemd-network/sd-dhcp-client.c
index ab9f68d..b69927d 100644
--- a/src/libsystemd-network/sd-dhcp-client.c
+++ b/src/libsystemd-network/sd-dhcp-client.c
@@ -30,6 +30,7 @@
 #include "util.h"
 #include "list.h"
 #include "refcnt.h"
+#include "async.h"
 
 #include "dhcp-protocol.h"
 #include "dhcp-internal.h"
@@ -209,7 +210,7 @@ static int client_initialize(sd_dhcp_client *client) {
         client->receive_message =
                 sd_event_source_unref(client->receive_message);
 
-        client->fd = safe_close(client->fd);
+        client->fd = asynchronous_close(client->fd);
 
         client->timeout_resend = sd_event_source_unref(client->timeout_resend);
 
@@ -747,7 +748,7 @@ static int client_timeout_t2(sd_event_source *s, uint64_t usec, void *userdata)
         int r;
 
         client->receive_message = sd_event_source_unref(client->receive_message);
-        client->fd = safe_close(client->fd);
+        client->fd = asynchronous_close(client->fd);
 
         client->state = DHCP_STATE_REBINDING;
         client->attempt = 1;
@@ -1153,7 +1154,7 @@ static int client_handle_message(sd_dhcp_client *client, DHCPMessage *message,
 
                         client->receive_message =
                                 sd_event_source_unref(client->receive_message);
-                        client->fd = safe_close(client->fd);
+                        client->fd = asynchronous_close(client->fd);
                 } else if (r == -ENOMSG)
                         /* invalid message, let's ignore it */
                         return 0;



More information about the systemd-commits mailing list