File tree Expand file tree Collapse file tree 2 files changed +5
-0
lines changed Expand file tree Collapse file tree 2 files changed +5
-0
lines changed Original file line number Diff line number Diff line change 2727# include < fcntl.h>
2828# include < unistd.h>
2929#endif
30+ #include < mutex>
3031#include " server_p.h"
3132#include " config.h"
3233
@@ -314,6 +315,7 @@ namespace Modbus {
314315
315316 // ---------------------------------------------------------------------------
316317 void Server::Private::close () {
318+ std::lock_guard<std::mutex> lg (d_guard);
317319
318320 if (backend->net () == Tcp) {
319321
@@ -404,6 +406,7 @@ namespace Modbus {
404406 // ---------------------------------------------------------------------------
405407 // static
406408 int Server::Private::receive (Private * d) {
409+ std::lock_guard<std::mutex> lg (d->d_guard );
407410 int rc;
408411 if ( (d->backend ->net () == Tcp) && !d->isConnected ()) {
409412
Original file line number Diff line number Diff line change @@ -50,6 +50,8 @@ namespace Modbus {
5050 std::promise<void > stopDaemon;
5151 Message::Callback messageCB;
5252
53+ std::mutex d_guard;
54+
5355 PIMP_DECLARE_PUBLIC (Server)
5456 };
5557}
You can’t perform that action at this time.
0 commit comments