[LibOS] Fix ref counting bug in shim_do_poll()

During poll/select emulation, Graphene incremented refcount of polled
handles, but forgot to decrement it in case poll timed out or failed.
This commit is contained in:
Dmitrii Kuvaiskii
2020-11-18 07:30:20 -05:00
parent 7f985631ec
commit d04cf6beeb
+7 -7
View File
@@ -148,12 +148,12 @@ static int _shim_do_poll(struct pollfd* fds, nfds_t nfds, int timeout_ms) {
PAL_BOL polled = DkStreamsWaitEvents(pal_cnt, pals, pal_events, ret_events, timeout_us);
/* update fds.revents, but only if something was actually polled */
if (polled) {
for (nfds_t i = 0; i < nfds; i++) {
if (!fds_mapping[i].hdl)
continue;
for (nfds_t i = 0; i < nfds; i++) {
if (!fds_mapping[i].hdl)
continue;
/* update fds.revents, but only if something was actually polled */
if (polled) {
fds[i].revents = 0;
if (ret_events[fds_mapping[i].idx] & PAL_WAIT_ERROR)
fds[i].revents |= POLLERR | POLLHUP;
@@ -164,9 +164,9 @@ static int _shim_do_poll(struct pollfd* fds, nfds_t nfds, int timeout_ms) {
if (fds[i].revents)
nrevents++;
put_handle(fds_mapping[i].hdl);
}
put_handle(fds_mapping[i].hdl);
}
free(pals);