chiark / gitweb /
sd-dhcp: make sure client->secs > 0
authorTom Gundersen <teg@jklm.no>
Wed, 12 Feb 2014 15:59:52 +0000 (16:59 +0100)
committerTom Gundersen <teg@jklm.no>
Wed, 12 Feb 2014 16:07:31 +0000 (17:07 +0100)
Some DHCP servers will not work correctly if secs == 0, so round up
to at least 1.

src/libsystemd-dhcp/sd-dhcp-client.c

index 4f41b4c06ac425178e74b1df2fec1b19e0b352ac..3b4db1d96ff4f72d783c9630441c422eb60e4265 100644 (file)
@@ -338,7 +338,7 @@ static int client_send_request(sd_dhcp_client *client, uint16_t secs) {
 
 static uint16_t client_update_secs(sd_dhcp_client *client, usec_t time_now)
 {
 
 static uint16_t client_update_secs(sd_dhcp_client *client, usec_t time_now)
 {
-        client->secs = (time_now - client->start_time) / USEC_PER_SEC;
+        client->secs = ((time_now - client->start_time) / USEC_PER_SEC) ? : 1;
 
         return client->secs;
 }
 
         return client->secs;
 }