Properly force a restart if scriptd exists and dies.
Also use designated initializers for the poll structure.
This commit is contained in:
parent
26f81272ee
commit
95c70ba2a7
30
ndhc.c
30
ndhc.c
@ -257,24 +257,21 @@ static void do_ndhc_work(void)
|
|||||||
setup_signals_ndhc();
|
setup_signals_ndhc();
|
||||||
start_dhcp_listen(&cs);
|
start_dhcp_listen(&cs);
|
||||||
|
|
||||||
struct pollfd pfds[6] = {0};
|
struct pollfd pfds[] = {
|
||||||
pfds[0].fd = cs.nlFd;
|
[0] = { .fd = cs.nlFd, .events = POLLIN|POLLHUP|POLLERR|POLLRDHUP },
|
||||||
pfds[0].events = POLLIN|POLLHUP|POLLERR|POLLRDHUP;
|
[1] = { .fd = ifchStream[0], .events = POLLHUP|POLLERR|POLLRDHUP },
|
||||||
pfds[1].fd = ifchStream[0];
|
[2] = { .fd = sockdStream[0], .events = POLLHUP|POLLERR|POLLRDHUP },
|
||||||
pfds[1].events = POLLHUP|POLLERR|POLLRDHUP;
|
[6] = { .fd = scriptdStream[0], .events = POLLHUP|POLLERR|POLLRDHUP },
|
||||||
pfds[2].fd = sockdStream[0];
|
[3] = { .fd = cs.rfkillFd, .events = POLLIN|POLLHUP|POLLERR|POLLRDHUP },
|
||||||
pfds[2].events = POLLHUP|POLLERR|POLLRDHUP;
|
// These can change on the fly.
|
||||||
pfds[3].fd = cs.rfkillFd;
|
[4] = { .events = POLLIN|POLLHUP|POLLERR|POLLRDHUP },
|
||||||
pfds[3].events = POLLIN|POLLHUP|POLLERR|POLLRDHUP;
|
[5] = { .events = POLLIN|POLLHUP|POLLERR|POLLRDHUP },
|
||||||
// These can change on the fly.
|
};
|
||||||
pfds[4].events = POLLIN|POLLHUP|POLLERR|POLLRDHUP;
|
|
||||||
pfds[5].events = POLLIN|POLLHUP|POLLERR|POLLRDHUP;
|
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
pfds[4].fd = cs.arpFd;
|
pfds[4].fd = cs.arpFd;
|
||||||
pfds[5].fd = cs.listenFd;
|
pfds[5].fd = cs.listenFd;
|
||||||
had_event = false;
|
had_event = false;
|
||||||
if (poll(pfds, 6, timeout) < 0) {
|
if (poll(pfds, 7, timeout) < 0) {
|
||||||
if (errno != EINTR) suicide("poll failed");
|
if (errno != EINTR) suicide("poll failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -300,6 +297,9 @@ static void do_ndhc_work(void)
|
|||||||
if (pfds[2].revents & (POLLHUP|POLLERR|POLLRDHUP)) {
|
if (pfds[2].revents & (POLLHUP|POLLERR|POLLRDHUP)) {
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
if (pfds[6].revents & (POLLHUP|POLLERR|POLLRDHUP)) {
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
if (pfds[3].revents & POLLIN) {
|
if (pfds[3].revents & POLLIN) {
|
||||||
had_event = true;
|
had_event = true;
|
||||||
sev_rfk = rfkill_get(&cs, 1, client_config.rfkillIdx);
|
sev_rfk = rfkill_get(&cs, 1, client_config.rfkillIdx);
|
||||||
@ -411,7 +411,7 @@ int ifchStream[2];
|
|||||||
int sockdSock[2];
|
int sockdSock[2];
|
||||||
int sockdStream[2];
|
int sockdStream[2];
|
||||||
int scriptdSock[2];
|
int scriptdSock[2];
|
||||||
int scriptdStream[2];
|
int scriptdStream[2] = { -1, -1 };
|
||||||
|
|
||||||
static void create_ifch_ipc_sockets(void) {
|
static void create_ifch_ipc_sockets(void) {
|
||||||
if (socketpair(AF_UNIX, SOCK_DGRAM, 0, ifchSock) < 0)
|
if (socketpair(AF_UNIX, SOCK_DGRAM, 0, ifchSock) < 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user