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

memory fixed

parent 44988452
Loading
Loading
Loading
Loading
+6 −9
Original line number Diff line number Diff line
@@ -61,12 +61,9 @@ namespace netplus {
			api = eapi;
			api->CreateConnetion(&CurCon);
			OpCode = 0;			
			CurCon->csock->_Overlapped=new WSAOVERLAPPED;
			memset((void*)CurCon->csock->_Overlapped, 0, sizeof(WSAOVERLAPPED));
		};

		~client() {
			delete CurCon->csock->_Overlapped;
			api->deleteConnetion(CurCon);
		};

@@ -159,7 +156,7 @@ namespace netplus {
				wbuf.len = BLOCKSIZE;

				int nBytesRecv = WSARecv(pClientContext->CurCon->csock->fd(), &wbuf, 1,
					&dwBytes, &dwFlags,pClientContext->CurCon->csock->_Overlapped, nullptr);
					&dwBytes, &dwFlags,&pClientContext->CurCon->csock->_Overlapped, nullptr);

				if (SOCKET_ERROR == nBytesRecv) {
					if (WSA_IO_PENDING != WSAGetLastError()) {
@@ -321,7 +318,7 @@ namespace netplus {

						//Overlapped send
						ret = WSASend(pClientContext->CurCon->csock->fd(), &wbuf, 1,
							&dwBytes, dwFlags, pClientContext->CurCon->csock->_Overlapped, nullptr);
							&dwBytes, dwFlags, &pClientContext->CurCon->csock->_Overlapped, nullptr);

						if ((SOCKET_ERROR == ret) && (WSA_IO_PENDING != WSAGetLastError())) {
							//Let's not work with this client
@@ -349,7 +346,7 @@ namespace netplus {

						//Get the data.
						ret = WSARecv(pClientContext->CurCon->csock->fd(), &wbuf, 1,
							&dwBytes, &dwFlags, pClientContext->CurCon->csock->_Overlapped, nullptr);
							&dwBytes, &dwFlags, &pClientContext->CurCon->csock->_Overlapped, nullptr);

						if ((SOCKET_ERROR == ret)) {
							std::cerr << "Thread " << tid << " : Error occurred while executing WSARecv()." << std::endl;
@@ -387,7 +384,7 @@ namespace netplus {

						//Overlapped send
						ret = WSASend(pClientContext->CurCon->csock->fd(), &wbuf, 1,
							&dwBytes, dwFlags, pClientContext->CurCon->csock->_Overlapped, NULL);
							&dwBytes, dwFlags, &pClientContext->CurCon->csock->_Overlapped, NULL);
TEST2:
						if (ret == SOCKET_ERROR) {
							std::cerr << "Thread " << tid << " <<: Error occurred while executing WSASend()." << std::endl;
@@ -426,7 +423,7 @@ TEST2:
						//Get the data.
TEST3:
						ret = WSARecv(pClientContext->CurCon->csock->fd(), &wbuf, 1,
							&dwBytes, &dwFlags, pClientContext->CurCon->csock->_Overlapped, nullptr);
							&dwBytes, &dwFlags, &pClientContext->CurCon->csock->_Overlapped, nullptr);

						if ((SOCKET_ERROR == ret)) {							
							if (WSA_IO_PENDING != WSAGetLastError()) {
+1 −1
Original line number Diff line number Diff line
@@ -75,7 +75,7 @@ namespace netplus {
            ULONG_PTR                _Extension;
            static std::atomic<int>  _InitCount;
#ifdef Windows 
            WSAOVERLAPPED           *_Overlapped;
            WSAOVERLAPPED            _Overlapped;
#endif
        protected:
            void copyAddrInfo(ULONG_PTR *dest,ULONG_PTR src);
+1 −1
Original line number Diff line number Diff line
@@ -53,7 +53,7 @@ netplus::socket::socket(){
    _Extension = 0;
    _Type=-1;
    _Socket = -1;
    _Overlapped = nullptr;
    memset(&_Overlapped, 0, sizeof(WSAOVERLAPPED));
    if (_InitCount<1) {
        if (WSAStartup(MAKEWORD(2, 2), &_WSAData) != 0) {
            NetException exception;
+2 −2
Original line number Diff line number Diff line
@@ -170,7 +170,7 @@ size_t netplus::tcp::sendData(void* data, unsigned long size,int flags){
    DWORD dwBytes = 0;
    DWORD dwFlags = 0;

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

    if(rval == SOCKET_ERROR){
        int etype=NetException::Error;
@@ -201,7 +201,7 @@ size_t netplus::tcp::recvData(void* data, unsigned long size,int flags){
    DWORD dwBytes = 0;
    DWORD dwFlags = 0;

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

    if(recvsize<0){
        int etype=NetException::Error;
+2 −2
Original line number Diff line number Diff line
@@ -169,7 +169,7 @@ size_t netplus::udp::sendData(void* data, unsigned long size, int flags) {
    DWORD dwBytes = 0;
    DWORD dwFlags = 0;

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

    if (rval == SOCKET_ERROR) {
        int etype = NetException::Error;
@@ -200,7 +200,7 @@ size_t netplus::udp::recvData(void* data, unsigned long size, int flags) {
    DWORD dwBytes = 0;
    DWORD dwFlags = 0;

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

    if (recvsize < 0) {
        int etype = NetException::Error;