Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/uipc_socket.c
Show First 20 Lines • Show All 3,556 Lines • ▼ Show 20 Lines | if (SOLISTENING(so)) { | ||||
if (events & (POLLIN | POLLRDNORM)) | if (events & (POLLIN | POLLRDNORM)) | ||||
if (soreadabledata(so)) | if (soreadabledata(so)) | ||||
revents |= events & (POLLIN | POLLRDNORM); | revents |= events & (POLLIN | POLLRDNORM); | ||||
if (events & (POLLOUT | POLLWRNORM)) | if (events & (POLLOUT | POLLWRNORM)) | ||||
if (sowriteable(so)) | if (sowriteable(so)) | ||||
revents |= events & (POLLOUT | POLLWRNORM); | revents |= events & (POLLOUT | POLLWRNORM); | ||||
if (events & (POLLPRI | POLLRDBAND)) | if (events & (POLLPRI | POLLRDBAND)) | ||||
if (so->so_oobmark || | if (so->so_oobmark || | ||||
(so->so_rcv.sb_state & SBS_RCVATMARK)) | (so->so_rcv.sb_state & SBS_RCVATMARK)) | ||||
kib: Are you sure that the right semantic is to not send POLLRDHUP if POLLINIGNEOF is set? | |||||
Done Inline ActionsThis is only intended to work for stream sockets. If we wanted to make it work for other kinds of descriptors, we'd have to invent the semantics for that because it doesn't work on other OSes either; it's not that clear what 'hangup' even means for a fifo anyway, since it can be opened and closed many times. tmunro: This is only intended to work for stream sockets. If we wanted to make it work for other kinds… | |||||
Done Inline ActionsWell, this is exactly why POLLINIGNEOF does. But if POLLRDHUP is only defined for streams, and POLLINIGNEOF is kernel-set bit for pipes/fifos, shouldn't it be completely ignored for POLLRDHUP? kib: Well, this is exactly why POLLINIGNEOF does.
But if POLLRDHUP is only defined for streams, and… | |||||
revents |= events & (POLLPRI | POLLRDBAND); | revents |= events & (POLLPRI | POLLRDBAND); | ||||
if ((events & POLLINIGNEOF) == 0) { | if ((events & POLLINIGNEOF) == 0) { | ||||
if (so->so_rcv.sb_state & SBS_CANTRCVMORE) { | if (so->so_rcv.sb_state & SBS_CANTRCVMORE) { | ||||
revents |= events & (POLLIN | POLLRDNORM); | revents |= events & (POLLIN | POLLRDNORM); | ||||
if (so->so_snd.sb_state & SBS_CANTSENDMORE) | if (so->so_snd.sb_state & SBS_CANTSENDMORE) | ||||
revents |= POLLHUP; | revents |= POLLHUP; | ||||
} | } | ||||
} | } | ||||
if (so->so_rcv.sb_state & SBS_CANTRCVMORE) | |||||
revents |= events & POLLRDHUP; | |||||
if (revents == 0) { | if (revents == 0) { | ||||
if (events & | if (events & | ||||
(POLLIN | POLLPRI | POLLRDNORM | POLLRDBAND)) { | (POLLIN | POLLPRI | POLLRDNORM | POLLRDBAND | POLLRDHUP)) { | ||||
selrecord(td, &so->so_rdsel); | selrecord(td, &so->so_rdsel); | ||||
so->so_rcv.sb_flags |= SB_SEL; | so->so_rcv.sb_flags |= SB_SEL; | ||||
} | } | ||||
if (events & (POLLOUT | POLLWRNORM)) { | if (events & (POLLOUT | POLLWRNORM)) { | ||||
selrecord(td, &so->so_wrsel); | selrecord(td, &so->so_wrsel); | ||||
so->so_snd.sb_flags |= SB_SEL; | so->so_snd.sb_flags |= SB_SEL; | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 835 Lines • Show Last 20 Lines |
Are you sure that the right semantic is to not send POLLRDHUP if POLLINIGNEOF is set?
POLLINIGNEOF is used to implement required semantic of the generations for named pipes AFAIR,