Loading CMakeLists.txt +4 −0 Original line number Diff line number Diff line Loading @@ -22,4 +22,8 @@ endif() set(LIBV "1") set(Upstream_VERSION 1.0.0) if(${DEBUG} MATCHES TRUE) add_definitions(-DDEBUG) endif() add_subdirectory(src) src/connection.cpp +6 −2 Original line number Diff line number Diff line Loading @@ -32,6 +32,10 @@ #include "eventapi.h" #include "exception.h" #ifdef DEBUG #include <iostream> #endif const char* netplus::con::condata::getData(){ return _Data.c_str(); } Loading Loading @@ -107,7 +111,7 @@ size_t netplus::con::getSendLength(){ netplus::con::condata *netplus::con::addRecvQueue(const char *data,unsigned long datasize){ if(datasize<=0){ NetException excp; excp[NetException::Error] << "addRecvQueue wrong datasize"; excp[NetException::Error] << "addRecvQueue wrong datasize:" << datasize; throw excp; } if(!_ReadDataFirst){ Loading Loading @@ -211,7 +215,7 @@ DELETEBLOCK: << " Planned size: " << qsize << std::endl; if((presize-delsize)!=qsize){ exception[SystemException::Critical] << "_resizeQueue: Calculated wrong size"; exception[NetException::Critical] << "_resizeQueue: Calculated wrong size"; throw exception; } #endif Loading src/exception.cpp +4 −0 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ netplus::NetException::NetException() { }; netplus::NetException::NetException(const NetException &exp){ const std::lock_guard<std::mutex> lock(mlock); msg=exp.msg; curCType = exp.curCType; } Loading @@ -44,14 +45,17 @@ netplus::NetException::~NetException(){ } int netplus::NetException::getErrorType(){ const std::lock_guard<std::mutex> lock(mlock); return curCType; } const char* netplus::NetException::what(){ const std::lock_guard<std::mutex> lock(mlock); return msg.c_str(); } netplus::NetException& netplus::NetException::append(const char *src){ const std::lock_guard<std::mutex> lock(mlock); msg.append(src); return *this; } Loading src/exception.h +3 −1 Original line number Diff line number Diff line Loading @@ -26,7 +26,8 @@ *******************************************************************************/ #include <string> #include <stddef.h> #include <mutex> #include <cstddef> /* * Error Statas Loading Loading @@ -64,6 +65,7 @@ namespace netplus { private: int curCType; std::string msg; std::mutex mlock; }; }; src/linux/event.cpp +6 −6 Original line number Diff line number Diff line Loading @@ -160,12 +160,11 @@ namespace netplus { try { char buf[BLOCKSIZE]; ssize_t rcvsize = _ServerSocket->recvData(rcon->csock, buf, BLOCKSIZE); if (rcvsize < 0) { if (rcvsize <= 0) { NetException exp; exp[NetException::Error] << "ReadEvent: recvData failed at pos: " << pos; throw exp; } rcon->addRecvQueue(buf, rcvsize); RequestEvent(rcon); } Loading @@ -183,9 +182,8 @@ namespace netplus { } try { if(!wcon->getSendData()){ NetException exp; exp[NetException::Note] << "WriteEvent: no data to send!" << pos; throw exp; sendReady(wcon,false); return; } ssize_t sended = _ServerSocket->sendData(wcon->csock, (void*)wcon->getSendData()->getData(), Loading @@ -199,7 +197,6 @@ namespace netplus { if(sended!=0) wcon->resizeSendQueue(sended); ResponseEvent(wcon); } catch (NetException& e) { Loading @@ -225,6 +222,9 @@ namespace netplus { } DisconnectEvent(delcon); delcon->conlock.unlock(); delete delcon->csock; delete delcon; _Events[pos].data.ptr=nullptr; Loading Loading
CMakeLists.txt +4 −0 Original line number Diff line number Diff line Loading @@ -22,4 +22,8 @@ endif() set(LIBV "1") set(Upstream_VERSION 1.0.0) if(${DEBUG} MATCHES TRUE) add_definitions(-DDEBUG) endif() add_subdirectory(src)
src/connection.cpp +6 −2 Original line number Diff line number Diff line Loading @@ -32,6 +32,10 @@ #include "eventapi.h" #include "exception.h" #ifdef DEBUG #include <iostream> #endif const char* netplus::con::condata::getData(){ return _Data.c_str(); } Loading Loading @@ -107,7 +111,7 @@ size_t netplus::con::getSendLength(){ netplus::con::condata *netplus::con::addRecvQueue(const char *data,unsigned long datasize){ if(datasize<=0){ NetException excp; excp[NetException::Error] << "addRecvQueue wrong datasize"; excp[NetException::Error] << "addRecvQueue wrong datasize:" << datasize; throw excp; } if(!_ReadDataFirst){ Loading Loading @@ -211,7 +215,7 @@ DELETEBLOCK: << " Planned size: " << qsize << std::endl; if((presize-delsize)!=qsize){ exception[SystemException::Critical] << "_resizeQueue: Calculated wrong size"; exception[NetException::Critical] << "_resizeQueue: Calculated wrong size"; throw exception; } #endif Loading
src/exception.cpp +4 −0 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ netplus::NetException::NetException() { }; netplus::NetException::NetException(const NetException &exp){ const std::lock_guard<std::mutex> lock(mlock); msg=exp.msg; curCType = exp.curCType; } Loading @@ -44,14 +45,17 @@ netplus::NetException::~NetException(){ } int netplus::NetException::getErrorType(){ const std::lock_guard<std::mutex> lock(mlock); return curCType; } const char* netplus::NetException::what(){ const std::lock_guard<std::mutex> lock(mlock); return msg.c_str(); } netplus::NetException& netplus::NetException::append(const char *src){ const std::lock_guard<std::mutex> lock(mlock); msg.append(src); return *this; } Loading
src/exception.h +3 −1 Original line number Diff line number Diff line Loading @@ -26,7 +26,8 @@ *******************************************************************************/ #include <string> #include <stddef.h> #include <mutex> #include <cstddef> /* * Error Statas Loading Loading @@ -64,6 +65,7 @@ namespace netplus { private: int curCType; std::string msg; std::mutex mlock; }; };
src/linux/event.cpp +6 −6 Original line number Diff line number Diff line Loading @@ -160,12 +160,11 @@ namespace netplus { try { char buf[BLOCKSIZE]; ssize_t rcvsize = _ServerSocket->recvData(rcon->csock, buf, BLOCKSIZE); if (rcvsize < 0) { if (rcvsize <= 0) { NetException exp; exp[NetException::Error] << "ReadEvent: recvData failed at pos: " << pos; throw exp; } rcon->addRecvQueue(buf, rcvsize); RequestEvent(rcon); } Loading @@ -183,9 +182,8 @@ namespace netplus { } try { if(!wcon->getSendData()){ NetException exp; exp[NetException::Note] << "WriteEvent: no data to send!" << pos; throw exp; sendReady(wcon,false); return; } ssize_t sended = _ServerSocket->sendData(wcon->csock, (void*)wcon->getSendData()->getData(), Loading @@ -199,7 +197,6 @@ namespace netplus { if(sended!=0) wcon->resizeSendQueue(sended); ResponseEvent(wcon); } catch (NetException& e) { Loading @@ -225,6 +222,9 @@ namespace netplus { } DisconnectEvent(delcon); delcon->conlock.unlock(); delete delcon->csock; delete delcon; _Events[pos].data.ptr=nullptr; Loading