Commit 77881fff authored by jan.koester's avatar jan.koester
Browse files

thread protection

parent 20f9924d
Loading
Loading
Loading
Loading
+2
Changes for src/connection.h: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *******************************************************************************/

#include <mutex>
#include <vector>
#include <memory>
#include <atomic>
@@ -165,6 +166,7 @@ namespace netplus {
            condata<char> RecvData;
            condata<char> SendData;

            std::mutex event_mutex;
        protected:
            con();
            time_t lasteventime;
+6
Changes for src/event/epoll.cpp: 6 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -216,6 +216,12 @@ namespace netplus {
            con *rcon =  reinterpret_cast<con*>(_Events[pos].data.ptr);
            buffer buf(BLOCKSIZE);

            if (!rcon || !rcon->csock) {
                return;
            }

            std::unique_lock<std::mutex> lock(rcon->event_mutex, std::defer_lock);

            try{

                size_t rcvsize = rcon->csock->recvData(buf, BLOCKSIZE);
+2
Changes for src/event/kqueue.cpp: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -227,6 +227,8 @@ namespace netplus {
                return;
            }

            std::unique_lock<std::mutex> lock(rcon->event_mutex, std::defer_lock);

            try{
                buffer buf(BLOCKSIZE);
                size_t rcvsize = rcon->csock->recvData(buf,0);