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

fixed threadrace

parent baf90025
Loading
Loading
Loading
Loading
+8 −5
Changes for src/event/epoll.cpp: 8 added lines, 5 removed lines.
Original line number Diff line number Diff line
@@ -324,9 +324,7 @@ namespace netplus {
            if (!ccon) {
                return;
            }

            {
                std::lock_guard<std::mutex> lock(ccon->event_mutex);
            std::unique_lock<std::mutex> conn_lock(ccon->event_mutex);

            if (ccon->csock) {
                try {
@@ -340,14 +338,19 @@ namespace netplus {

                    evconnection->DisconnectEvent(*ccon, tid, args);

                    ccon->csock->close();

                    CONNECTIONS.erase(ccon->csock->fd());

                } catch (NetException &e) {
                        throw e;
                    }
                    CONNECTIONS.erase(ccon->csock->fd());
                    conn_lock.unlock();
                    throw e;
                }
            }

            _Events[pos].data.ptr  = nullptr;
            conn_lock.unlock();
            delete ccon;
        }

+5 −6
Changes for src/event/kqueue.cpp: 5 added lines, 6 removed lines.
Original line number Diff line number Diff line
@@ -340,9 +340,7 @@ namespace netplus {
            if (!ccon) {
                return;
            }

            {
                std::lock_guard<std::mutex> lock(ccon->event_mutex);
            std::unique_lock<std::mutex> conn_lock(ccon->event_mutex);

            if (ccon->csock) {
                try {
@@ -363,16 +361,17 @@ namespace netplus {

                    ccon->csock->close();


                    CONNECTIONS.erase(ccon->csock->fd());

                } catch (NetException &e) {
                        throw e;
                    }
                    CONNECTIONS.erase(ccon->csock->fd());
                    conn_lock.unlock();
                    throw e;
                }
            }

            _Events[pos].udata  = nullptr;
            conn_lock.unlock();
            delete ccon;
        }