win: unmask evtchn before checking if libvchan_wait is needed
This should prevent the race, when evtchn is signalled between condition check and libvchan_wait call.
This commit is contained in:
parent
847fe81dcd
commit
ec47c5eb81
12
vchan/io.c
12
vchan/io.c
@ -125,6 +125,12 @@ int libvchan_write(struct libvchan *ctrl, char *data, int size)
|
|||||||
{
|
{
|
||||||
int avail, avail_contig;
|
int avail, avail_contig;
|
||||||
int real_idx;
|
int real_idx;
|
||||||
|
#ifdef WINNT
|
||||||
|
// because of mask-on-fire and do_notify called previously, evtchn must be
|
||||||
|
// unmasked before libvchan_wait. Do it before checking if data is
|
||||||
|
// available to prevent race
|
||||||
|
libvchan_prepare_to_select(ctrl);
|
||||||
|
#endif
|
||||||
while ((avail = libvchan_buffer_space(ctrl)) == 0)
|
while ((avail = libvchan_buffer_space(ctrl)) == 0)
|
||||||
if (libvchan_wait(ctrl) < 0)
|
if (libvchan_wait(ctrl) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
@ -150,6 +156,12 @@ int libvchan_read(struct libvchan *ctrl, char *data, int size)
|
|||||||
{
|
{
|
||||||
int avail, avail_contig;
|
int avail, avail_contig;
|
||||||
int real_idx;
|
int real_idx;
|
||||||
|
#ifdef WINNT
|
||||||
|
// because of mask-on-fire and do_notify called previously, evtchn must be
|
||||||
|
// unmasked before libvchan_wait. Do it before checking if data is
|
||||||
|
// available to prevent race
|
||||||
|
libvchan_prepare_to_select(ctrl);
|
||||||
|
#endif
|
||||||
while ((avail = libvchan_data_ready(ctrl)) == 0)
|
while ((avail = libvchan_data_ready(ctrl)) == 0)
|
||||||
if (libvchan_wait(ctrl) < 0)
|
if (libvchan_wait(ctrl) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
Loading…
Reference in New Issue
Block a user