mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2024-11-26 06:50:06 +00:00
Slight adjustments to the poll() loop
Recheck the entry at the current index after we remove one. This isn't strictly necessary, since the next pass will get it anyway. Using a vector as opposed to our own realloc()'d array means indexing beyond the size() is undefined behavior, so it's better to be safe.
This commit is contained in:
parent
974941f4fa
commit
1474ff10ac
@ -351,8 +351,6 @@ void CNServer::removePollFD(int i) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CNServer::start() {
|
void CNServer::start() {
|
||||||
int oldnfds;
|
|
||||||
|
|
||||||
std::cout << "Starting server at *:" << port << std::endl;
|
std::cout << "Starting server at *:" << port << std::endl;
|
||||||
while (active) {
|
while (active) {
|
||||||
// the timeout is to ensure shard timers are ticking
|
// the timeout is to ensure shard timers are ticking
|
||||||
@ -367,9 +365,7 @@ void CNServer::start() {
|
|||||||
terminate(0);
|
terminate(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
oldnfds = fds.size();
|
for (int i = 0; i < fds.size() && n > 0; i++) {
|
||||||
|
|
||||||
for (int i = 0; i < oldnfds && n > 0; i++) {
|
|
||||||
if (fds[i].revents == 0)
|
if (fds[i].revents == 0)
|
||||||
continue; // nothing in this one; don't decrement n
|
continue; // nothing in this one; don't decrement n
|
||||||
|
|
||||||
@ -427,6 +423,9 @@ void CNServer::start() {
|
|||||||
delete cSock;
|
delete cSock;
|
||||||
|
|
||||||
removePollFD(i);
|
removePollFD(i);
|
||||||
|
|
||||||
|
// a new entry was moved to this position, so we check it again
|
||||||
|
i--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user