mirror of
https://github.com/clearlinux/graphene.git
synced 2026-09-06 13:51:28 +00:00
[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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user