Catch unexpected socket polling errors.
The poll(2) system call may set POLLERR in the returned events. Normally no errors are returned unless specifically requested by setting an appropriate socket option. Nevertheless, the poll(2) API is quite generic, and there is no guarantee that the kernel networking stack might push an error event one day. This patch adds defensive code in order to catch any unexpected error condition. Signed-off-by: Richard Cochran <richardcochran@gmail.com>master
parent
b6fa222201
commit
cb3fbc1010
10
clock.c
10
clock.c
|
@ -1559,8 +1559,14 @@ int clock_poll(struct clock *c)
|
|||
LIST_FOREACH(p, &c->ports, list) {
|
||||
/* Let the ports handle their events. */
|
||||
for (i = 0; i < N_POLLFD; i++) {
|
||||
if (cur[i].revents & (POLLIN|POLLPRI)) {
|
||||
event = port_event(p, i);
|
||||
if (cur[i].revents & (POLLIN|POLLPRI|POLLERR)) {
|
||||
if (cur[i].revents & POLLERR) {
|
||||
pr_err("port %d: unexpected socket error",
|
||||
port_number(p));
|
||||
event = EV_FAULT_DETECTED;
|
||||
} else {
|
||||
event = port_event(p, i);
|
||||
}
|
||||
if (EV_STATE_DECISION_EVENT == event) {
|
||||
c->sde = 1;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue