Commit 0d7690b5 authored by jan.koester's avatar jan.koester
Browse files

ops

parent 78dd7541
Loading
Loading
Loading
Loading
+12 −5
Original line number Diff line number Diff line
@@ -515,6 +515,8 @@ namespace netplus {
                    INFINITE
                );

                lpIOContext = (poll::PPER_IO_CONTEXT)lpOverlapped;

                switch (lpIOContext->IOOperation) {
                case poll::ClientIoAccept:

@@ -578,8 +580,7 @@ namespace netplus {
                            args->evpoll->CloseClient(lpAcceptSocketContext, FALSE);
                            throw e;
                        }   
                    }
                    else {
                    } else {

                        //
                        // AcceptEx completes but doesn't read any data so we need to post
@@ -596,15 +597,19 @@ namespace netplus {
                            &dwRecvNumBytes,
                            &dwFlags,
                            &lpAcceptSocketContext->pIOContext->Overlapped, NULL);

                        if (nRet == SOCKET_ERROR && (ERROR_IO_PENDING != WSAGetLastError())) {
                            NetException e;
                            e[NetException::Note] << "WSARecv() failed: " << WSAGetLastError();
                            args->evpoll->CloseClient(lpAcceptSocketContext, FALSE);
                            delete lpAcceptSocketContext->CurCon->csock;
                            lpAcceptSocketContext->CurCon->csock = nullptr;
                            throw e;
                        }
                    }

                    args->event->ConnectEvent(lpPerSocketContext->CurCon, tid, args);
                    args->event->RequestEvent(lpPerSocketContext->CurCon, tid, args);
                    //
                    //Time to post another outstanding AcceptEx
                    //
@@ -640,6 +645,7 @@ namespace netplus {
                        delete lpAcceptSocketContext->CurCon->csock;
                        lpAcceptSocketContext->CurCon->csock = nullptr;
                    }
                    args->event->RequestEvent(lpPerSocketContext->CurCon, tid, args);
                    break;

                case poll::ClientIoWrite:
@@ -696,6 +702,7 @@ namespace netplus {
                        }
                        break;
                    }
                    args->event->ResponseEvent(lpPerSocketContext->CurCon, tid, args);
                }
            } catch (NetException &e) {
                if (e.getErrorType() == NetException::Note || NetException::Warning)
@@ -718,8 +725,6 @@ namespace netplus {
            throw exp;
        }

        _ServerSocket->listen();

        ::CreateIoCompletionPort((HANDLE)_ServerSocket->fd(), iocp, (u_long)0, 0);

        LPFN_ACCEPTEX lpfnAcceptEx = NULL;
@@ -764,6 +769,8 @@ namespace netplus {
            }
        }

        WSAResetEvent(evpoll.g_hCleanupEvent[0]);

        for (auto i = threadpool.begin(); i != threadpool.end(); ++i) {
            i->join();
        }