- /** An event handler may remove its own descriptor from the list, therefore it is not
- * safe to directly iterate over the list and dispatch events there with STL iterators.
- * Thats a shame because it makes this code slower and more resource intensive, but maybe
- * the user should stop using select(), as select() smells anyway.
- */
- for (int i = 0; i < result; i++)
+int SelectEngine::DispatchEvents()
+{
+ static timeval tval = { 1, 0 };
+
+ fd_set rfdset = ReadSet, wfdset = WriteSet, errfdset = ErrSet;
+
+ int sresult = select(MaxFD + 1, &rfdset, &wfdset, &errfdset, &tval);
+ ServerInstance->UpdateTime();
+
+ /* Nothing to process this time around */
+ if (sresult < 1)
+ return 0;
+
+ for (int i = 0, j = sresult; i <= MaxFD && j > 0; i++)