odhcpd: managed PD wait for 250ms initial period
authorSteven Barth <steven@midlink.org>
Sun, 6 Apr 2014 14:27:27 +0000 (16:27 +0200)
committerSteven Barth <steven@midlink.org>
Sun, 6 Apr 2014 14:27:27 +0000 (16:27 +0200)
src/dhcpv6-ia.c

index 767a546fbe5db0ff776c41cc7c514b1a2479e61c..844dfd30b7d507d119c500b622e223a9b54e7057 100644 (file)
@@ -22,6 +22,7 @@
 #include <errno.h>
 #include <fcntl.h>
 #include <stdio.h>
+#include <poll.h>
 #include <alloca.h>
 #include <resolv.h>
 #include <limits.h>
@@ -464,6 +465,14 @@ static bool assign_pd(struct interface *iface, struct dhcpv6_assignment *assign)
                        assign->managed_size = -1;
                        assign->valid_until = odhcpd_time() + 15;
                        list_add(&assign->head, &iface->ia_assignments);
+
+                       // Wait initial period of up to 250ms for immediate assignment
+                       struct pollfd pfd = { .fd = fd, .events = POLLIN };
+                       poll(&pfd, 1, 250);
+                       managed_handle_pd_data(&assign->managed_sock.stream, 0);
+
+                       if (fcntl(fd, F_GETFL) >= 0 && assign->managed_size > 0)
+                               return true;
                }
 
                return false;