8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-23 04:43:03 +01:00

Front-ported fix for unregistered bug - check return value of poll() before using it's output structures

This commit is contained in:
alexpeshkoff 2011-10-04 13:43:38 +00:00
parent 5cfb49f79b
commit 4b87ef2341

View File

@ -341,7 +341,7 @@ public:
#endif
}
int select(timeval* timeout)
void select(timeval* timeout)
{
bool hasRequest = false;
@ -357,14 +357,18 @@ public:
if (!hasRequest)
{
errno = NOTASOCKET;
return -1;
slct_count = -1;
return;
}
int milliseconds = timeout ? timeout->tv_sec * 1000 + timeout->tv_usec / 1000 : -1;
slct_count = ::poll(slct_poll.begin(), slct_poll.getCount(), milliseconds);
for (pollfd* pf = slct_poll.begin(); pf < end; ++pf)
pf->events = pf->revents;
if (slct_count >= 0) // in case of error return revents may contain something bad
{
for (pollfd* pf = slct_poll.begin(); pf < end; ++pf)
pf->events = pf->revents;
}
#else
#ifdef WIN_NT
slct_count = ::select(FD_SETSIZE, &slct_fdset, NULL, NULL, timeout);
@ -372,8 +376,6 @@ public:
slct_count = ::select(slct_width, &slct_fdset, NULL, NULL, timeout);
#endif // WIN_NT
#endif // HAVE_POLL
return slct_count;
}
int getCount()