Commit eed514a8 authored by jan.koester's avatar jan.koester
Browse files

fixed

parent 644665c3
Loading
Loading
Loading
Loading
+13 −1
Changes for src/event/epoll.cpp: 13 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -503,7 +503,11 @@ namespace netplus {
    class EventWorker {
    public:
        EventWorker(int tid, ULONG_PTR args, EventWorkerArgs* eargs) {
            std::vector<std::thread> local_threads;

            for(auto& kv : eargs->ssocket){
                local_threads.emplace_back([&, tid, args, kv] {
                    try {
                        poll pollptr(kv.second, eargs->event, kv.first, eargs->timeout);

                        while (event::Running) {
@@ -529,13 +533,21 @@ namespace netplus {

                                    pollptr.IoEventHandler(fd, flags, tid, args);
                                }

                            } catch (NetException& e) {
                                std::cerr << "Poll Error: " << e.what() << std::endl;
                                usleep(10000);  // 10ms sleep on error to reduce CPU thrashing
                            }
                        }
                    } catch (NetException& e) {
                        std::cerr << "Worker thread " << tid << " exited with exception: " << e.what() << std::endl;
                    } catch (...) {
                        std::cerr << "Worker thread " << tid << " exited with unknown exception." << std::endl;
                    }
                });
            }
 
            for (auto& t : local_threads)
                t.join();
        }
    };