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

test

parent 825bf896
Loading
Loading
Loading
Loading
+11 −15
Original line number Diff line number Diff line
@@ -89,9 +89,12 @@ namespace netplus {
    static std::mutex g_stateMutex;
    static std::unordered_map<event*, std::unique_ptr<EventState>> g_states;


    static EventState* ST(event* ev) {
        std::lock_guard<std::mutex> lk(g_stateMutex);
        return g_states[ev].get();
        auto it = g_states.find(ev);
        if (it == g_states.end()) return nullptr;
        return it->second.get();
    }

    // -------------------------------------------------------------------------
@@ -467,18 +470,9 @@ namespace netplus {
        _ServerSocket->bind();
        _ServerSocket->setNonBlock();
        _ServerSocket->listen();
        SYSTEM_INFO sysinfo;
        GetSystemInfo(&sysinfo);
        threads = sysinfo.dwNumberOfProcessors;


        init_state(this, _ServerSocket);

        // store iocp handle in _pollFD (eventapi has only int)
        // safe on 64-bit: use intptr_t
        EventState* st = ST(this);
        _pollFD = (int)(intptr_t)st->iocp;

        // number of threads like epoll backend
        threads = (int)std::max<unsigned>(1, std::thread::hardware_concurrency());
    }

    event::~event() {
@@ -488,6 +482,8 @@ namespace netplus {
        EventState* st = ST(this);
        if (!st) return;

        st->threads = threads;

        // wake all workers
        for (size_t i = 0; i < st->workers.size(); ++i) {
            PostQueuedCompletionStatus(st->iocp, 0, 0, nullptr);
@@ -509,11 +505,11 @@ namespace netplus {
    }

    void event::runEventloop(ULONG_PTR /*args*/) {
        init_state(this, _ServerSocket);

        EventState* st = ST(this);

        // number of threads like epoll backend
        st->threads = (int)std::max<unsigned>(1, std::thread::hardware_concurrency());
        this->threads = st->threads;
        _pollFD = (int)(intptr_t)st->iocp;

        Running = true;

+1 −1
Original line number Diff line number Diff line
@@ -278,7 +278,7 @@ namespace netplus {
		ssl(const netplus::x509cert& cert, int sock);
		~ssl() {};

		ssl(const std::string& addr, int port, int maxconnections, int sockopts, const netplus::x509cert& cert);
		ssl(const netplus::x509cert& cert,const std::string& addr, int port, int maxconnections, int sockopts);

		void accept(std::unique_ptr<socket>& csock) override;
		void handshake_after_accept();
+3 −2
Original line number Diff line number Diff line
@@ -456,6 +456,7 @@ namespace netplus {


netplus::ssl::ssl(const netplus::x509cert &cert) : 
    tcp(),
    _cert(cert),
    _aes(nullptr),
    _handshakeDone(false)
@@ -472,7 +473,7 @@ netplus::ssl::ssl(const netplus::x509cert &cert,int sock) :
    _Type=sockettype::SSL;
};

netplus::ssl::ssl(const std::string &addr,int port,int maxconnections,int sockopts,const netplus::x509cert &cert) :
netplus::ssl::ssl(const netplus::x509cert& cert,const std::string &addr,int port,int maxconnections,int sockopts) :
    tcp(addr,port,maxconnections,sockopts),
    _cert(cert),
    _aes(nullptr),