mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-25 06:34:42 +02:00
parent
deac316a45
commit
c03e458e13
@ -80,18 +80,16 @@ void SocketEvents::ThreadProc(void)
|
|||||||
{
|
{
|
||||||
Utility::SetThreadName("SocketIO");
|
Utility::SetThreadName("SocketIO");
|
||||||
|
|
||||||
pollfd *pfds = NULL;
|
std::vector<pollfd> pfds;
|
||||||
SocketEventDescriptor *descriptors = NULL;
|
std::vector<SocketEventDescriptor> descriptors;
|
||||||
int pfdcount;
|
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
{
|
{
|
||||||
boost::mutex::scoped_lock lock(l_SocketIOMutex);
|
boost::mutex::scoped_lock lock(l_SocketIOMutex);
|
||||||
|
|
||||||
if (pfds == NULL) {
|
if (l_SocketIOFDChanged) {
|
||||||
pfdcount = l_SocketIOSockets.size();
|
pfds.resize(l_SocketIOSockets.size());
|
||||||
pfds = new pollfd[pfdcount];
|
descriptors.resize(l_SocketIOSockets.size());
|
||||||
descriptors = new SocketEventDescriptor[pfdcount];
|
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
@ -111,10 +109,12 @@ void SocketEvents::ThreadProc(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ASSERT(!pfds.empty());
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
(void) WSAPoll(pfds, pfdcount, -1);
|
(void) WSAPoll(&pfds[0], pfds.size(), -1);
|
||||||
#else /* _WIN32 */
|
#else /* _WIN32 */
|
||||||
(void) poll(pfds, pfdcount, -1);
|
(void) poll(&pfds[0], pfds.size(), -1);
|
||||||
#endif /* _WIN32 */
|
#endif /* _WIN32 */
|
||||||
|
|
||||||
std::vector<EventDescription> events;
|
std::vector<EventDescription> events;
|
||||||
@ -122,14 +122,10 @@ void SocketEvents::ThreadProc(void)
|
|||||||
{
|
{
|
||||||
boost::mutex::scoped_lock lock(l_SocketIOMutex);
|
boost::mutex::scoped_lock lock(l_SocketIOMutex);
|
||||||
|
|
||||||
if (l_SocketIOFDChanged) {
|
if (l_SocketIOFDChanged)
|
||||||
delete [] pfds;
|
|
||||||
delete [] descriptors;
|
|
||||||
pfds = NULL;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < pfdcount; i++) {
|
for (int i = 0; i < pfds.size(); i++) {
|
||||||
if ((pfds[i].revents & (POLLIN | POLLOUT | POLLHUP | POLLERR)) == 0)
|
if ((pfds[i].revents & (POLLIN | POLLOUT | POLLHUP | POLLERR)) == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user