diff --git a/Socket.cpp b/Socket.cpp
index 05cf652..36c1fc4 100644
--- a/Socket.cpp
+++ b/Socket.cpp
@@ -17,7 +17,6 @@ namespace core {
shutDown = true;
onUnregister();
ePoll.unregisterSocket(this);
-// coreutils::Log(coreutils::LOG_DEBUG_4) << "BMAXFree on socket " << descriptor;
free(buffer);
if(descriptor == -1)
return;
@@ -63,7 +62,7 @@ namespace core {
void Socket::onUnregistered() {}
bool Socket::eventReceived(struct epoll_event event, long long eventId) {
-// coreutils::Log(coreutils::LOG_DEBUG_3) << "eventReceived " << eventId << ": " << descriptor << ":" << event.events;
+ lock.lock();
inHandler = true;
if(event.events & EPOLLRDHUP) {
readHangup = true;
@@ -80,6 +79,7 @@ namespace core {
shutdown();
}
inHandler = false;
+ lock.unlock();
return !shutDown;
}
@@ -138,9 +138,10 @@ namespace core {
outlock.lock();
fifo.emplace(data);
outlock.unlock();
-// coreutils::Log(coreutils::LOG_DEBUG_4) << "inHandler " << descriptor << " " << inHandler << ":" << shutDown << ":[" << data << "]";
- if(!inHandler && sender != this)
+ if(sender != this)
+ lock.lock();
ePoll.resetSocket(this);
+ lock.unlock();
return 1;
}
diff --git a/Socket.h b/Socket.h
index 05734c7..682ff5f 100644
--- a/Socket.h
+++ b/Socket.h
@@ -167,6 +167,7 @@ namespace core {
std::string text;
int descriptor = -1;
std::mutex outlock;
+ std::mutex lock;
bool readHangup = false;
volatile bool inHandler = false;
diff --git a/html/Socket_8h_source.html b/html/Socket_8h_source.html
index 3435fa3..d97372c 100644
--- a/html/Socket_8h_source.html
+++ b/html/Socket_8h_source.html
@@ -147,48 +147,49 @@ $(function() {
- 170 bool readHangup =
false;
- 171 volatile bool inHandler =
false;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 190 std::queue<std::string> fifo;
-
-
-
-
-
-
-
+
+ 171 bool readHangup =
false;
+ 172 volatile bool inHandler =
false;
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 191 std::queue<std::string> fifo;
+
+
+
+
+
+
+
-int getDescriptor()
Get the descriptor for the socket.
Definition: Socket.cpp:44
-bool eventReceived(struct epoll_event event, long long eventId)
Parse epoll event and call specified callbacks.
Definition: Socket.cpp:65
-virtual void onRegistered()
Called after the socket has been registered with epoll processing.
Definition: Socket.cpp:59
+int getDescriptor()
Get the descriptor for the socket.
Definition: Socket.cpp:43
+bool eventReceived(struct epoll_event event, long long eventId)
Parse epoll event and call specified callbacks.
Definition: Socket.cpp:64
+virtual void onRegistered()
Called after the socket has been registered with epoll processing.
Definition: Socket.cpp:58
virtual void receiveData(coreutils::ZString &buffer)
Definition: Socket.cpp:94
Socket(EPoll &ePoll, std::string text="")
Definition: Socket.cpp:11
int write(std::string data, Socket *sender)
Definition: Socket.cpp:137
-virtual void onRegister()
Called before the socket has registered with the epoll processing.
Definition: Socket.cpp:57
+virtual void onRegister()
Called before the socket has registered with the epoll processing.
Definition: Socket.cpp:56
virtual ~Socket()
Definition: Socket.cpp:16
-void setDescriptor(int descriptor)
Set the descriptor for the socket.
Definition: Socket.cpp:29
+void setDescriptor(int descriptor)
Set the descriptor for the socket.
Definition: Socket.cpp:28
virtual void onDataReceived(std::string data)
Called when data is received from the socket.
Definition: Socket.cpp:86
-virtual void onUnregistered()
Called when the socket has finished unregistering for the epoll processing.
Definition: Socket.cpp:63
-void shutdown(std::string text="unknown")
Definition: Socket.cpp:155
+virtual void onUnregistered()
Called when the socket has finished unregistering for the epoll processing.
Definition: Socket.cpp:62
+void shutdown(std::string text="unknown")
Definition: Socket.cpp:156