Commit 3763c72b authored by jan.koester's avatar jan.koester
Browse files

Merge branch 'main' of git.tuxist.de:jan.koester/libnetplus

parents ec100b0b a3582b68
Loading
Loading
Loading
Loading
+2 −7
Original line number Diff line number Diff line
@@ -163,7 +163,7 @@ namespace netplus {

        void ConnectEventHandler(int pos,const int tid,void *args)  {
            NetException exception;
            con *ccon=(con*)_Events[pos].data.ptr;
            con *ccon;

            _evtapi->CreateConnetion(&ccon);

@@ -205,8 +205,6 @@ namespace netplus {
        void ReadEventHandler(int pos,const int tid,void *args) {
            con *rcon = (con*)_Events[pos].data.ptr;

            if(!rcon)
                assert(0);
            try{
                char buf[BLOCKSIZE];
                size_t rcvsize = _ServerSocket->recvData(rcon->csock, buf, BLOCKSIZE);
@@ -278,12 +276,9 @@ namespace netplus {
        void CloseEventHandler(int pos,const int tid,void *args) {
            con *ccon = (con*)_Events[pos].data.ptr;

            if(!ccon)
                return;

            try{

                if(epoll_ctl(_pollFD, EPOLL_CTL_DEL,ccon->csock->fd(), 0)<0){
                if(epoll_ctl(_pollFD, EPOLL_CTL_DEL,ccon->csock->fd(), nullptr)<0){
                    NetException except;
                    char errstr[255];
                    strerror_r_netplus(errno,errstr,255);
+4 −1
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@
#include <chrono>
#include <thread>
#include <cstring>
#include <atomic>

#include <vector>
#include <cstdio>
@@ -48,15 +49,17 @@

#define HIDDEN __attribute__ ((visibility ("hidden")))

int netplus::socket::_InitCount = 0;
std::atomic<int> netplus::socket::_InitCount=0;

netplus::socket::socket(){
    _Socket=-1;
    _SocketPtr=nullptr;
    _Type=-1;
    ++_InitCount;
}

netplus::socket::~socket(){
    --_InitCount;
}

void netplus::socket::setnonblocking(){
+3 −3
Original line number Diff line number Diff line
@@ -123,13 +123,11 @@ netplus::tcp::tcp(const char* addr, int port,int maxconnections,int sockopts) :
}

netplus::tcp::~tcp(){
    if(_Socket>=0)
    ::close(_Socket);
    ::free(_SocketPtr);
}

netplus::tcp::tcp() : socket() {
    ++_InitCount;
    _SocketPtr=::malloc(sizeof(sockaddr));
    _SocketPtrSize=sizeof(sockaddr);
    ((struct sockaddr*)_SocketPtr)->sa_family=AF_UNSPEC;
@@ -214,8 +212,10 @@ size_t netplus::tcp::sendData(socket *csock, void* data, unsigned long size,int
                     );
    if(rval<0){
        int etype=NetException::Error;

        if(errno==EAGAIN)
            etype=NetException::Note;

        char errstr[512];
        strerror_r_netplus(errno,errstr,512);