X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fodhcpd.git;a=blobdiff_plain;f=src%2Fodhcpd.c;h=6f034bff4e8a99d383aed5c41a2c607d1d3c8521;hp=9c7f27c4f4ac43b206e8030a05fae44ddba27e2b;hb=44ca70ae6f0fb649cef47d9160ec1ee13e7844f1;hpb=5b12eeba475a3301c362cf59f138ec7aa60d2dd9 diff --git a/src/odhcpd.c b/src/odhcpd.c index 9c7f27c..6f034bf 100644 --- a/src/odhcpd.c +++ b/src/odhcpd.c @@ -367,6 +367,15 @@ static void odhcpd_receive_packets(struct uloop_fd *u, _unused unsigned int even struct sockaddr_nl nl; } addr; + if (u->error) { + int ret = -1; + socklen_t ret_len = sizeof(ret); + getsockopt(u->fd, SOL_SOCKET, SO_ERROR, &ret, &ret_len); + u->error = false; + if (e->handle_error) + e->handle_error(ret); + } + while (true) { struct iovec iov = {data_buf, sizeof(data_buf)}; struct msghdr msg = { @@ -434,7 +443,6 @@ static void odhcpd_receive_packets(struct uloop_fd *u, _unused unsigned int even else if (addr.in.sin_family == AF_INET) inet_ntop(AF_INET, &addr.in.sin_addr, ipbuf, sizeof(ipbuf)); - syslog(LOG_DEBUG, "--"); syslog(LOG_DEBUG, "Received %li Bytes from %s%%%s", (long)len, ipbuf, (iface) ? iface->ifname : "netlink"); @@ -446,7 +454,8 @@ static void odhcpd_receive_packets(struct uloop_fd *u, _unused unsigned int even int odhcpd_register(struct odhcpd_event *event) { event->uloop.cb = odhcpd_receive_packets; - return uloop_fd_add(&event->uloop, ULOOP_READ); + return uloop_fd_add(&event->uloop, ULOOP_READ | + ((event->handle_error) ? ULOOP_ERROR_CB : 0)); } void odhcpd_process(struct odhcpd_event *event)