MCPcopy Create free account
hub / github.com/danoon2/Boxedwine / internal_poll

Function internal_poll

source/kernel/kpoll.cpp:34–133  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

32}
33
34S32 internal_poll(KThread* thread, KPollData* data, U32 count, U32 timeout) {
35 KPollData* firstData=data;
36
37 while (true) {
38 S32 result = 0;
39 BOXEDWINE_CRITICAL_SECTION_WITH_CONDITION(thread->pollCond);
40 bool interrupted = !thread->inSignal && thread->interrupted;
41
42 if (interrupted)
43 thread->interrupted = false;
44
45 data = firstData;
46 {
47 BOXEDWINE_CRITICAL_SECTION_WITH_MUTEX(thread->process->fdsMutex);
48 // gather locks before we check the data so that we don't miss one
49 for (U32 i = 0; i < count; i++) {
50 KFileDescriptor* fd;
51
52 data->revents = 0;
53 if (data->fd >= 0) {
54 fd = thread->process->getFileDescriptor_nolock(data->fd);
55 if (fd) {
56 // even if 0, we still don't want to remove it and should still respond to POLLERR and POLLHUP
57 fd->kobject->waitForEvents(thread->pollCond, data->events | K_POLLERR);
58 } else {
59 data->revents = K_POLLNVAL;
60 }
61 }
62 data++;
63 }
64
65 data = firstData;
66 for (U32 i = 0; i < count; i++) {
67 KFileDescriptor* fd = nullptr;
68
69 if (data->fd >= 0) {
70 fd = thread->process->getFileDescriptor_nolock(data->fd);
71 }
72 if (fd) {
73 if (!fd->kobject->isOpen()) {
74 data->revents |= K_POLLHUP;
75 }
76 if ((data->events & K_POLLPRI) && fd->kobject->isPriorityReadReady()) {
77 data->revents |= K_POLLPRI;
78 }
79 if ((data->events & K_POLLIN) != 0 && fd->kobject->isReadReady()) {
80 data->revents |= K_POLLIN;
81 }
82 if ((data->events & K_POLLOUT) != 0 && fd->kobject->isWriteReady()) {
83 data->revents |= K_POLLOUT;
84 }
85 if (data->revents != 0) {
86 result++;
87 }
88 }
89 data++;
90 }
91 }

Callers 3

waitMethod · 0.85
kpollFunction · 0.85
kselectFunction · 0.85

Calls 7

clearPollDataFunction · 0.85
waitForEventsMethod · 0.45
isOpenMethod · 0.45
isPriorityReadReadyMethod · 0.45
isReadReadyMethod · 0.45
isWriteReadyMethod · 0.45

Tested by

no test coverage detected