event: don't select then write when using eventfd, write directly

This commit is contained in:
hardening 2013-02-01 00:47:44 +01:00
parent f0d5e24979
commit 497041b44e
1 changed files with 11 additions and 10 deletions

View File

@ -35,6 +35,7 @@
#include <unistd.h>
#endif
#ifdef HAVE_EVENTFD_H
#include <sys/eventfd.h>
#include <errno.h>
@ -127,27 +128,27 @@ BOOL SetEvent(HANDLE hEvent)
{
event = (WINPR_EVENT*) Object;
if (!(WaitForSingleObject(hEvent, 0) == WAIT_OBJECT_0))
{
#ifdef HAVE_EVENTFD_H
eventfd_t val = 1;
do
{
length = eventfd_write(event->pipe_fd[0], val);
}
while(length < 0 && errno == EINTR);
status = (length == 0) ? TRUE : FALSE;
eventfd_t val = 1;
do
{
length = eventfd_write(event->pipe_fd[0], val);
}
while(length < 0 && errno == EINTR);
status = (length == 0) ? TRUE : FALSE;
#else
if (WaitForSingleObject(hEvent, 0) != WAIT_OBJECT_0)
{
length = write(event->pipe_fd[1], "-", 1);
if (length == 1)
status = TRUE;
#endif
}
else
{
status = TRUE;
}
#endif
}
LeaveCriticalSection(&cs);