Commit 6dda7efd authored by jan.koester's avatar jan.koester
Browse files

test

parent 72a98630
Loading
Loading
Loading
Loading
+4 −6
Changes for src/event/iocp.cpp: 4 added lines, 6 removed lines.
Original line number Diff line number Diff line
@@ -103,9 +103,7 @@ namespace netplus {
		}

		void RemoveFromClientList(client* pClientContext) {
			std::lock(g_ClientContextMutex, pClientContext->cltmtx);
			std::lock_guard<std::mutex> lock1(g_ClientContextMutex, std::adopt_lock);
			std::lock_guard<std::mutex> lock2(pClientContext->cltmtx, std::adopt_lock);
			std::lock_guard<std::mutex> lock1(g_ClientContextMutex);

			auto it = std::find(g_ClientContext.begin(), g_ClientContext.end(), pClientContext);
			if (it != g_ClientContext.end()) {
@@ -248,14 +246,14 @@ namespace netplus {

				client* pClientContext = (client*)lpContext;

				if (!bReturn || bReturn && dwBytesTransfered == 0) {
				std::lock_guard<std::mutex> cltLock(pClientContext->cltmtx);

				if (!bReturn || (bReturn && dwBytesTransfered == 0 ) ) {
					eargs->evpoll->RemoveFromClientList(pClientContext);
					continue;
				}

				try {
					std::lock_guard<std::mutex> cltLock(pClientContext->cltmtx);

					auto& curCon = pClientContext->CurCon;					
					
					switch (pClientContext->State) {
+5 −11
Changes for src/windows/tcp.cpp: 5 added lines, 11 removed lines.
Original line number Diff line number Diff line
@@ -196,24 +196,21 @@ void netplus::tcp::bind(){
size_t netplus::tcp::sendData(void* data, unsigned long size,int flags){
    WSABUF buf{0};

    buf.buf = (char*)data;
    buf.buf = reinterpret_cast<char*>(data);
    buf.len = size;

    DWORD dwFlags = 0;
    DWORD dwsend = 0;

    SOCKET rval=::WSASend(_Socket,&buf,1,&dwsend,flags,&_Overlapped,nullptr);

    NetException exception;

	int etype = NetException::Error;

    if(rval == SOCKET_ERROR){
        DWORD lerror=GetLastError();
        if (lerror == WSA_IO_PENDING || lerror == WSAEWOULDBLOCK) {
			etype = NetException::Note;
            return (size_t)dwsend;
        }
        exception[etype] << "Socket senddata failed on Socket: " << (int)_Socket
        exception[NetException::Error] << "Socket senddata failed on Socket: " << (int)_Socket
                << " ErrorMsg: " << lerror;
        throw exception;
    }
@@ -228,19 +225,16 @@ size_t netplus::tcp::recvData(void* data, unsigned long size,int flags){
    buf.buf = reinterpret_cast<char*>(data);
    buf.len = size;

    DWORD dwFlags = 0;
    DWORD dwBytes = 0;

    int rval=::WSARecv(_Socket, &buf, 1,&dwBytes,(LPDWORD) &flags, &_Overlapped, nullptr);

    int etype = NetException::Error;

    if (rval == SOCKET_ERROR) {
        DWORD lerror = GetLastError();
        if (lerror == WSA_IO_PENDING || lerror == WSAEWOULDBLOCK) {
			etype = NetException::Note;
            return (size_t)dwBytes;
        }
        exception[etype] << "Socket senddata failed on Socket: " << (int)_Socket
        exception[NetException::Error] << "Socket Recv failed on Socket: " << (int)_Socket
                << " ErrorMsg: " << lerror;
        throw exception;
    }