win/vchan: reset the evtchn buffer in case of overflow
In case of evtchn buffer overflow (received more than 1024 events between libvchan_wait calls) further reads returns ERROR_IO_DEVICE. The only way to recover from that is to reset the buffer. Because vchan code doesn't take care of number of fired events - only the fact that some event was fired - lost events here shouldn't break anything. Events reported _after_ libvchan_wait call will be collected and reported correctly. Some more comments in the code (here and in qrexec-agent in the next commit).
This commit is contained in:
parent
2444603ef5
commit
cb5479666c
@ -78,6 +78,14 @@ int libvchan_wait(struct libvchan *ctrl)
|
||||
int ret;
|
||||
|
||||
ret = xc_evtchn_pending_with_flush(ctrl->evfd);
|
||||
// I don't know how to avoid evtchn ring buffer overflow without
|
||||
// introducing any race condition (in qrexec-agent code). Because of that,
|
||||
// handle overflow with ring reset - because we just received some events
|
||||
// (overflow means ring full, so some events was recorded...) the reset
|
||||
// isn't critical here - always after libvchan_wait we check if there is
|
||||
// something to read from the vchan
|
||||
if (ret == -1 && GetLastError() == ERROR_IO_DEVICE)
|
||||
ret = xc_evtchn_reset(ctrl->evfd);
|
||||
if (ret!=-1 && xc_evtchn_unmask(ctrl->evfd, ctrl->evport))
|
||||
return -1;
|
||||
if (ret!=-1 && libvchan_is_eof(ctrl))
|
||||
|
Loading…
Reference in New Issue
Block a user