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

small fixes

parent 4c8e767a
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -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)
+6 −2
Original line number Diff line number Diff line
@@ -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();
}
@@ -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){
@@ -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
+4 −0
Original line number Diff line number Diff line
@@ -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;
}
@@ -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;   
}
+3 −1
Original line number Diff line number Diff line
@@ -26,7 +26,8 @@
 *******************************************************************************/

#include <string>
#include <stddef.h>
#include <mutex>
#include <cstddef>

/*
 * Error Statas
@@ -64,6 +65,7 @@ namespace netplus {
    private:
        int curCType;
        std::string msg;
        std::mutex  mlock;
    };
};
+6 −6
Original line number Diff line number Diff line
@@ -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);
        }
@@ -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(),
@@ -199,7 +197,6 @@ namespace netplus {

            if(sended!=0)
                wcon->resizeSendQueue(sended);

            ResponseEvent(wcon);
        }
        catch (NetException& e) {
@@ -225,6 +222,9 @@ namespace netplus {
        }

        DisconnectEvent(delcon);

        delcon->conlock.unlock();

        delete delcon->csock;
        delete delcon;
        _Events[pos].data.ptr=nullptr;