Hi
There is a problem with the WaitForMultipleObjects
(libwinpr/synch/wait.c) function: when an object is waiting for, say,
writing and is ready to read (or vice versa - we are waiting for
reading, the object is ready to write), the maximum CPU utilization occurs.
The fact is that no matter what event we are waiting for, the descriptor
is added to both lists for select() - for reading and writing:
FD_SET(fd, &rfds);
FD_SET(fd, &wfds);
As a result, the select() function may end without waiting for the
descriptor state we need, further verification:
if (Object->Mode & WINPR_FD_READ)
signal_set = FD_ISSET(fd, &rfds) ? 1 : 0;
if (Object->Mode & WINPR_FD_WRITE)
signal_set |= FD_ISSET(fd, &wfds) ? 1 : 0;
gives no results and the loop repeats without falling asleep in select()
at all.
Just replacing a piece of code solved the problem:
#ifdef 1
/*
My modifications.
*/
if (Object->Mode & WINPR_FD_READ)
{
FD_SET(fd, &rfds);
prfds = &rfds;
}
if (Object->Mode & WINPR_FD_WRITE)
{
FD_SET(fd, &wfds);
pwfds = &wfds;
}
#else
/*
Original.
*/
FD_SET(fd, &rfds);
FD_SET(fd, &wfds);
if (Object->Mode & WINPR_FD_READ)
prfds = &rfds;
if (Object->Mode & WINPR_FD_WRITE)
pwfds = &wfds;
#endif
I had this (%subj%) problem when trying to connect to a host that is not
responding or not accepting the connection immediately due to network
delays. Those. when there is a wait in freerdp_tcp_connect_timeout()
function.
_______________________________________________
FreeRDP-devel mailing list
FreeRDP-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freerdp-devel